MCPcopy Create free account
hub / github.com/editablejs/editable / elements

Function elements

packages/models/src/interfaces/editor.ts:194–216  ·  view source on GitHub ↗
(editor: SlateEditor, at?: Location)

Source from the content-addressed store, hash-verified

192 marks: SlateEditor.marks as (editor: SlateEditor) => EditorMarks,
193
194 elements(editor: SlateEditor, at?: Location) {
195 let caches = EDITOR_ACTIVE_ELEMENTS.get(editor)
196 if (caches && !at) return caches
197 const prevSelection = editor.selection
198 if (at) editor.selection = Editor.range(editor, at)
199 const editorElements: EditorElements = {}
200 editor.normalizeSelection(selection => {
201 if (selection === null) return
202 const nodeEntries = Editor.nodes<Element>(editor, {
203 at: selection,
204 match: n => !Editor.isEditor(n) && Element.isElement(n),
205 })
206
207 for (const entry of nodeEntries) {
208 const type = entry[0].type ?? 'paragraph'
209 if (editorElements[type]) editorElements[type].push(entry)
210 else editorElements[type] = [entry]
211 }
212 })
213 editor.selection = prevSelection
214 if (!at) EDITOR_ACTIVE_ELEMENTS.set(editor, editorElements)
215 return editorElements
216 },
217}
218
219export * from 'slate'

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…