-
-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove legacy forward delete (#7987)
- Loading branch information
1 parent
c273e17
commit 1b2b60c
Showing
12 changed files
with
177 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { EditorHost } from '@blocksuite/block-std'; | ||
import type { InlineEditor } from '@blocksuite/inline'; | ||
|
||
function getDocTitleByEditorHost(editorHost: EditorHost): HTMLElement | null { | ||
const docViewport = editorHost.closest('.affine-page-viewport'); | ||
if (!docViewport) return null; | ||
return docViewport.querySelector('doc-title'); | ||
} | ||
|
||
export function getDocTitleInlineEditor( | ||
editorHost: EditorHost | ||
): InlineEditor | null { | ||
const docTitle = getDocTitleByEditorHost(editorHost); | ||
if (!docTitle) return null; | ||
const titleRichText = docTitle.querySelector< | ||
HTMLElement & { inlineEditor: InlineEditor } | ||
>('rich-text'); | ||
if (!titleRichText || !titleRichText.inlineEditor) return null; | ||
return titleRichText.inlineEditor; | ||
} | ||
|
||
export function focusTitle(editorHost: EditorHost, index = Infinity, len = 0) { | ||
const titleInlineEditor = getDocTitleInlineEditor(editorHost); | ||
if (!titleInlineEditor) { | ||
return; | ||
} | ||
|
||
if (index > titleInlineEditor.yText.length) { | ||
index = titleInlineEditor.yText.length; | ||
} | ||
titleInlineEditor.setInlineRange({ index, length: len }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.