From c2149f218bd55baa37c3b54135148d3051156cc7 Mon Sep 17 00:00:00 2001 From: L-Sun Date: Thu, 16 Jan 2025 17:53:28 +0000 Subject: [PATCH] refactor(editor): enable toc dragging in page mode (#9736) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related [BS-2322](https://linear.app/affine-design/issue/BS-2322/toc-排序坏掉部分的修复) --- .../fragments/outline/body/outline-panel-body.ts | 7 ++----- .../src/fragments/outline/card/outline-card.ts | 16 ++++------------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts index 657a535747..8597740149 100644 --- a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts +++ b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts @@ -317,7 +317,7 @@ export class OutlinePanelBody extends SignalWatcher( notes: OutlineNoteItem[], children: NoteBlockModel[] ) { - if (!this._isEdgelessMode() || !children.length || !this.doc.root) return; + if (!children.length || !this.doc.root) return; const blocks = selected.map( id => (notesMap.get(id) as OutlineNoteItem).note @@ -351,7 +351,6 @@ export class OutlinePanelBody extends SignalWatcher( style=${`transform: translateY(${this._indicatorTranslateY}px)`} >` : nothing} - ${this._renderDocTitle()} ${this._pageVisibleNotes.length ? repeat( this._pageVisibleNotes, @@ -364,7 +363,6 @@ export class OutlinePanelBody extends SignalWatcher( .number=${idx + 1} .index=${note.index} .doc=${this.doc} - .editorMode=${this.editor.mode} .activeHeadingId=${this._activeHeadingId$.value} .status=${selectedNotesSet.has(note.note.id) ? this._dragging @@ -450,8 +448,6 @@ export class OutlinePanelBody extends SignalWatcher( } private _selectNote(e: SelectEvent) { - if (!this._isEdgelessMode()) return; - const { selected, id, multiselect } = e.detail; if (!selected) { @@ -658,6 +654,7 @@ export class OutlinePanelBody extends SignalWatcher( return html`
+ ${this._renderDocTitle()} ${shouldRenderEmptyPanel ? this._EmptyPanel() : this._PanelList(shouldRenderEdgelessOnlyNotes)} diff --git a/blocksuite/presets/src/fragments/outline/card/outline-card.ts b/blocksuite/presets/src/fragments/outline/card/outline-card.ts index f0b43d6245..97a0f02926 100644 --- a/blocksuite/presets/src/fragments/outline/card/outline-card.ts +++ b/blocksuite/presets/src/fragments/outline/card/outline-card.ts @@ -42,7 +42,7 @@ const styles = css` user-select: none; } - .card-preview.edgeless:hover { + .card-preview:hover { background: var(--affine-hover-color); } @@ -217,12 +217,7 @@ export class OutlineNoteCard extends SignalWatcher(WithDisposable(LitElement)) { private _dispatchDragEvent(e: MouseEvent) { e.preventDefault(); - if ( - e.button !== 0 || - this.editorMode === 'page' || - !this.enableNotesSorting - ) - return; + if (e.button !== 0 || !this.enableNotesSorting) return; const { clientX: startX, clientY: startY } = e; const disposeDragStart = on(this.ownerDocument, 'mousemove', e => { @@ -317,7 +312,7 @@ export class OutlineNoteCard extends SignalWatcher(WithDisposable(LitElement)) { class="card-container ${this.status ?? ''} ${this.theme}" >
{ - if (this.editorMode === 'edgeless' || this.invisible) return; + if (this.invisible) return; this._dispatchClickBlockEvent(block); }} >`; @@ -395,9 +390,6 @@ export class OutlineNoteCard extends SignalWatcher(WithDisposable(LitElement)) { @property({ attribute: false }) accessor doc!: Store; - @property({ attribute: false }) - accessor editorMode: 'page' | 'edgeless' = 'page'; - @property({ attribute: false }) accessor enableNotesSorting!: boolean;