Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x 1x 212x 212x 9x 212x 1x 212x 212x 212x | import { createContentModelDocument } from '../modelApi/creators/createContentModelDocument'; import { normalizeContentModel } from '../modelApi/common/normalizeContentModel'; import type { ContentModelDocumentWithPersistedCache } from '../modelApi/selection/iterateSelections'; import type { ContentModelDocument, DomToModelContext } from 'roosterjs-content-model-types'; /** * Create Content Model from DOM tree in this editor * @param root Root element of DOM tree to create Content Model from * @param context Context object for DOM to Content Model conversion * @returns A ContentModelDocument object that contains all the models created from the give root element */ export function domToContentModel( root: HTMLElement | DocumentFragment, context: DomToModelContext ): ContentModelDocument { const model = createContentModelDocument(context.defaultFormat); if (context.selection?.type == 'range' && context.selection.isReverted) { model.hasRevertedRangeSelection = true; } // When allowed, persist cached element and do not clear it if not changed if (context.domIndexer && context.allowCacheElement) { (model as ContentModelDocumentWithPersistedCache).persistCache = true; } context.elementProcessors.child(model, root, context); normalizeContentModel(model); return model; } |