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 34 35 | 1x 1x 1410x 235x 235x 235x 1x 235x | import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';
import type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';
/**
* @internal
* Create a EditorContext object used by ContentModel API
*/
export const createEditorContext: CreateEditorContext = (core, saveIndex) => {
const { lifecycle, format, darkColorHandler, logicalRoot, cache, domHelper } = core;
saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;
const context: EditorContext = {
isDarkMode: lifecycle.isDarkMode,
defaultFormat: format.defaultFormat,
pendingFormat: format.pendingFormat ?? undefined,
darkColorHandler: darkColorHandler,
addDelimiterForEntity: true,
allowCacheElement: true,
allowCacheListItem: !!core.experimentalFeatures?.includes('CacheList'),
domIndexer: saveIndex ? cache.domIndexer : undefined,
zoomScale: domHelper.calculateZoomScale(),
experimentalFeatures: core.experimentalFeatures ?? [],
paragraphMap: core.cache.paragraphMap,
editorViewWidth: domHelper.getClientWidth(),
...getRootComputedStyleForContext(logicalRoot.ownerDocument),
};
if (core.domHelper.isRightToLeft()) {
context.isRootRtl = true;
}
return context;
};
|