(editor: SlateEditor)
| 84 | } |
| 85 | |
| 86 | const marks = (editor: SlateEditor): EditorMarks | null => { |
| 87 | const { selection } = editor |
| 88 | if (!selection) return null |
| 89 | if (Range.isExpanded(selection)) { |
| 90 | const [match] = Editor.nodes(editor, { match: Text.isText }) |
| 91 | |
| 92 | if (match) { |
| 93 | const [node] = match as NodeEntry<Text> |
| 94 | const { text, ...rest } = node |
| 95 | return rest |
| 96 | } else { |
| 97 | return {} |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | const { anchor } = selection |
| 102 | const { path } = anchor |
| 103 | let [node] = Editor.leaf(editor, path) |
| 104 | |
| 105 | if (anchor.offset === 0) { |
| 106 | const prev = Editor.previous(editor, { at: path, match: Text.isText }) |
| 107 | const markedVoid = Editor.above(editor, { |
| 108 | match: n => Element.isElement(n) && Editor.isVoid(editor, n) && editor.markableVoid(n), |
| 109 | }) |
| 110 | if (!markedVoid) { |
| 111 | const block = Editor.above(editor, { |
| 112 | match: n => Element.isElement(n) && Editor.isBlock(editor, n), |
| 113 | }) |
| 114 | |
| 115 | if (prev && block) { |
| 116 | const [prevNode, prevPath] = prev |
| 117 | const [, blockPath] = block |
| 118 | |
| 119 | if (Path.isAncestor(blockPath, prevPath)) { |
| 120 | node = prevNode as Text |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | const { text, ...rest } = node |
| 127 | return rest |
| 128 | } |
| 129 | |
| 130 | SlateEditor.marks = (editor: SlateEditor, at?: Location) => { |
| 131 | const caches = EDITOR_ACTIVE_MARKS.get(editor) |
no outgoing calls
no test coverage detected
searching dependent graphs…