@lofcz/platejs-core 52.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/hotkeys-DI1HPO2Q.js +115 -0
- package/dist/hotkeys-DI1HPO2Q.js.map +1 -0
- package/dist/index-NTp--CEF.d.ts +4294 -0
- package/dist/index-NTp--CEF.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +387 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.d.ts +2056 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +2582 -0
- package/dist/react/index.js.map +1 -0
- package/dist/static/index.d.ts +2 -0
- package/dist/static/index.js +4 -0
- package/dist/static-CVN6JhaR.js +728 -0
- package/dist/static-CVN6JhaR.js.map +1 -0
- package/dist/withSlate-1B0SfAWG.js +2823 -0
- package/dist/withSlate-1B0SfAWG.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withSlate-1B0SfAWG.js","names":["isFunction","value","Function","mergeWith","SlatePlugin","mergePlugins","basePlugin","T","sourcePlugins","objValue","srcValue","key","Array","isArray","Modify","isDefined","SlateEditor","AnyPluginConfig","PluginConfig","SlatePlugin","SlatePluginMethods","SlatePlugins","isFunction","mergePlugins","SlatePluginConfig","Omit","Partial","K","O","A","T","S","node","TSlatePluginConfig","C","createSlatePlugin","config","editor","baseConfig","initialExtension","key","plugin","__apiExtensions","__configuration","__extensions","__selectorExtensions","api","dependencies","handlers","inject","type","options","override","parser","parsers","plugins","priority","render","rules","shortcuts","transforms","isLeaf","isDecoration","configure","newPlugin","ctx","configurePlugin","p","configureNestedPlugin","found","updatedPlugins","map","nestedPlugin","length","result","extendEditorApi","extension","isPluginSpecific","extendSelectors","extendApi","extendEditorTransforms","isTransform","extendTransforms","overrideEditor","isOverride","extend","extendConfig","clone","extendPlugin","extendNestedPlugin","push","withComponent","component","createTSlatePlugin","SlateEditor","AnyPluginConfig","WithRequiredKey","InferConfig","SlatePlugin","SlatePluginContext","getEditorPlugin","editor","p","P","plugin","getPlugin","api","setOption","keyOrOptions","value","setOptions","options","tf","transforms","type","node","getOption","key","args","getOptions","merge","SlateEditor","PluginConfig","AnySlatePlugin","SlatePlugin","getEditorPlugin","mergePlugins","resolvePlugin","editor","_plugin","P","plugin","__resolved","__configuration","configResult","undefined","__extensions","length","extension","targetPluginToInject","inject","targetPlugins","plugins","Object","fromEntries","map","targetPlugin","injectedPlugin","node","component","render","validatePlugin","K","O","A","T","S","api","debug","error","key","isElement","isLeaf","SlateEditor","AnyPluginConfig","PluginConfig","WithRequiredKey","AnySlatePlugin","SlatePlugin","resolvePlugin","createSlatePlugin","getSlatePlugin","editor","p","C","node","plugin","editorPlugin","plugins","key","__resolved","getPluginType","getPlugin","type","getPluginTypes","keys","map","getType","getPluginKey","meta","pluginCache","types","getPluginKeys","pluginKey","filter","Boolean","getPluginByType","getContainerTypes","isContainer","assignLegacyApi","assignLegacyTransforms","syncLegacyMethods","isDefined","merge","createVanillaStore","SlateEditor","SlatePlugin","SlatePlugins","getEditorPlugin","mergePlugins","resolvePlugin","PluginStoreFactory","resolvePlugins","editor","plugins","createStore","meta","pluginList","shortcuts","Record","components","pluginCache","decorate","handlers","onChange","onNodeChange","onTextChange","inject","nodeProps","node","isContainer","isLeaf","isText","leafProps","textProps","types","normalizeInitialValue","render","aboveEditable","aboveNodes","aboveSlate","afterContainer","afterEditable","beforeContainer","beforeEditable","belowNodes","belowRootNodes","rules","match","useHooks","resolvedPlugins","resolveAndSortPlugins","applyPluginsToEditor","resolvePluginOverrides","resolvePluginStores","forEach","plugin","extendEditor","resolvePluginMethods","push","key","type","isDecoration","leaf","resolvePluginShortcuts","store","options","mutative","name","__selectorExtensions","length","extension","extendedOptions","extendSelectors","optionsStore","Object","entries","api","apiKey","apiFunction","__apiExtensions","isOverride","isPluginSpecific","isTransform","newExtensions","transforms","undefined","originalKey","hotkey","namespacedKey","resolvedHotkey","NonNullable","handler","pluginSpecificTransforms","pluginSpecificApi","priority","flattenAndResolvePlugins","Map","pluginMap","processPlugin","resolvedPlugin","existingPlugin","get","set","enabledPlugins","Array","from","values","filter","enabled","sort","a","b","orderedPlugins","visited","Set","visit","has","add","dependencies","depKey","depPlugin","debug","warn","fromEntries","map","applyOverrides","overriddenPlugins","enabledOverrides","componentOverrides","component","pluginOverrides","Partial","override","assign","value","p","updatedPlugin","createSlatePlugin","AstPlugin","key","parser","format","deserialize","data","decoded","decodeURIComponent","window","atob","parsed","JSON","parse","withHistory","SlateEditor","ExtendEditor","createSlatePlugin","withPlateHistory","editor","HistoryPlugin","key","extendEditor","PluginConfig","createSlatePlugin","ParagraphConfig","BaseParagraphPlugin","key","node","isElement","parsers","html","deserializer","rules","validNodeName","query","element","style","fontFamily","merge","removeEmpty","PathApi","OverrideEditor","BreakRules","getPluginByType","withBreakRules","ctx","editor","tf","insertBreak","checkMatchRulesOverride","rule","blockNode","blockPath","matchRulesKeys","meta","pluginCache","rules","match","key","overridePlugin","getPlugin","break","node","path","executeBreakAction","action","resetBlock","at","insertExitBreak","deleteBackward","insertSoftBreak","transforms","selection","api","isCollapsed","block","plugin","type","breakRules","isEmpty","overrideBreakRules","effectiveBreakRules","emptyAction","empty","isAt","end","range","char","string","emptyLineEndAction","emptyLineEnd","overrideDefaultBreakRules","defaultAction","default","overrideSplitResetBreakRules","splitReset","isAtStart","start","next","PointApi","RangeApi","OverrideEditor","DeleteRules","getPluginByType","withDeleteRules","ctx","editor","tf","deleteBackward","deleteForward","deleteFragment","resetMarks","api","isAt","start","removeMarks","checkMatchRulesOverride","rule","blockNode","blockPath","matchRulesKeys","meta","pluginCache","rules","match","key","overridePlugin","getPlugin","delete","node","path","executeDeleteAction","action","resetBlock","at","transforms","unit","selection","isCollapsed","block","plugin","type","deleteRules","overrideDeleteRules","effectiveDeleteRules","startAction","isEmpty","emptyAction","empty","equals","anchor","options","range","reset","children","select","Path","TElement","ElementApi","PathApi","TextApi","OverrideEditor","MergeRules","getPluginByType","withMergeRules","ctx","editor","tf","removeNodes","checkMatchRulesOverride","rule","blockNode","blockPath","matchRulesKeys","meta","pluginCache","rules","match","key","overridePlugin","getPlugin","merge","node","path","api","shouldMergeNodes","prevNodeEntry","nextNodeEntry","reverse","prevNode","prevPath","nextPath","curNode","curPath","targetNode","targetPath","isText","text","at","shouldRemove","plugin","type","mergeRules","removeEmpty","overrideMergeRules","isElement","isVoid","isEmpty","isSibling","transforms","options","event","nodeEntry","shouldNotRemove","ElementApi","NormalizeRules","OverrideEditor","getPluginByType","withNormalizeRules","ctx","editor","tf","normalizeNode","checkMatchRulesOverride","rule","node","path","matchRulesKeys","meta","pluginCache","rules","match","key","overridePlugin","getPlugin","normalize","transforms","isElement","type","plugin","normalizeRules","overridenormalizeRules","effectivenormalizeRules","removeEmpty","api","isEmpty","removeNodes","at","OverrideEditor","getPluginByType","createSlatePlugin","BaseParagraphPlugin","withBreakRules","withDeleteRules","withMergeRules","withNormalizeRules","withOverrides","api","isInline","isSelectable","isVoid","markableVoid","editor","create","block","node","children","text","type","getType","key","element","isMarkableVoid","OverridePlugin","overrideEditor","Descendant","SlateEditor","ParserOptions","AnyEditorPlugin","getEditorPlugin","pipeInsertFragment","editor","injectedPlugins","Partial","fragment","options","tf","withoutNormalizing","some","p","parser","preInsert","insertFragment","SlateEditor","ParserOptions","AnyEditorPlugin","getEditorPlugin","pipeTransformData","editor","plugins","Partial","data","options","forEach","p","transformData","parser","Descendant","SlateEditor","ParserOptions","AnyEditorPlugin","getEditorPlugin","pipeTransformFragment","editor","plugins","Partial","fragment","options","forEach","p","transformFragment","parser","NodeEntry","NodeOf","Path","QueryNodeOptions","TNode","NodeApi","queryNode","ApplyDeepToNodesOptions","apply","node","N","source","Record","path","query","applyDeepToNodes","entry","isAncestor","children","forEach","child","index","concat","isSlateVoid","element","HTMLElement","dataset","slateVoid","isSlateElement","slateNode","isSlateText","isSlateString","slateString","isSlateLeaf","slateLeaf","isSlateEditor","slateEditor","isSlateNode","isSlatePluginElement","pluginKey","classList","contains","isSlatePluginNode","getSlateElements","Array","from","querySelectorAll","TNode","defaults","ApplyDeepToNodesOptions","applyDeepToNodes","defaultsDeepToNodes","options","Omit","N","apply","Path","TNode","ElementApi","SlateEditor","EditorPlugin","getPluginKey","getPluginKeys","getInjectMatch","editor","E","plugin","node","path","inject","excludeBelowPlugins","excludePlugins","isBlock","_isBlock","isElement","_isElement","isLeaf","maxLevel","targetPlugins","element","undefined","api","type","includes","length","excludeTypes","isBelow","above","at","match","n","SlateEditor","AnyEditorPlugin","SlatePlugins","getInjectedPlugins","editor","plugin","Partial","injectedPlugins","meta","pluginList","reverse","forEach","p","injectedPlugin","inject","plugins","key","push","TElement","TText","TextApi","kebabCase","getNodeDataAttributeKeys","node","Object","keys","filter","key","isText","map","keyToDataAttribute","TElement","TText","AnyObject","pick","SlateRenderNodeProps","AnyEditorPlugin","getNodeDataAttributeKeys","getPluginNodeProps","attributes","nodeAttributes","node","plugin","props","newProps","pluginNodeProps","dangerouslyAllowAttributes","Object","keys","forEach","key","undefined","getSlateClass","type","TNode","merge","ApplyDeepToNodesOptions","applyDeepToNodes","mergeDeepToNodes","options","Omit","N","apply","TElement","TText","ElementApi","NodeApi","PathApi","NodeEntry","Path","SlateEditor","EdgeNodes","getPluginByType","getEdgeNodes","editor","api","isCollapsed","cursor","selection","anchor","textRange","range","path","edge","isStart","isEnd","parent","isAffinityInlineElement","isElement","parentAffinity","type","rules","affinity","nodeEntry","get","at","siblingPath","next","previous","siblingNode","siblingEntry","TElement","TText","IS_FIREFOX","NodeApi","isEqual","SlateEditor","EdgeNodes","getMarkBoundaryAffinity","editor","markBoundary","marks","selection","marksMatchLeaf","leaf","extractProps","Object","keys","length","backwardLeafEntry","forwardLeafEntry","leafEntry","affinityIsTowardsLeaf","marksDirection","selectionDirection","anchor","offset","TElement","TText","ElementApi","NodeApi","SlateEditor","EdgeNodes","getPluginByType","isNodeAffinity","editor","node","affinity","marks","Object","keys","extractProps","isElement","type","some","rules","selection","isNodesAffinity","edgeNodes","backwardLeafEntry","forwardLeafEntry","Point","ElementApi","NodeApi","SlateEditor","EdgeNodes","setAffinitySelection","editor","edgeNodes","affinity","setMarks","marks","api","onChange","select","point","tf","setSelection","anchor","focus","before","after","beforeEnd","end","isElement","extractProps","Path","TText","ElementApi","NodeApi","TextApi","PluginConfig","EdgeNodes","createTSlatePlugin","getPluginByType","getEdgeNodes","getMarkBoundaryAffinity","isNodesAffinity","setAffinitySelection","ElementAffinity","affinity","at","type","AffinityConfig","AffinityPlugin","key","overrideEditor","editor","tf","deleteBackward","insertText","move","transforms","unit","apply","api","isCollapsed","start","startText","isText","text","string","edgeNodes","hasElement","length","options","applyOutwardAffinity","selection","isExpanded","textPath","focus","path","textNode","get","marks","Object","keys","extractProps","outwardMarks","filter","rules","isEnd","nextPoint","next","marksToRemove","nextTextNode","nextTextPath","markKey","isBetweenSameMarks","push","removeMarks","distance","reverse","preEdgeNodes","postEdgeNodes","before","after","isElement","Ancestor","OverrideEditor","ChunkingConfig","withChunking","editor","getOptions","chunkSize","query","getChunkSize","ancestor","Ancestor","NodeApi","PluginConfig","createTSlatePlugin","withChunking","ChunkingConfig","chunkSize","contentVisibilityAuto","query","ancestor","ChunkingPlugin","key","options","isEditor","overrideEditor","DebugConfig","createTSlatePlugin","DebugErrorType","LogLevel","PlateError","Error","type","constructor","message","name","DebugPlugin","key","options","isProduction","process","env","NODE_ENV","logger","error","details","console","info","log","warn","logLevel","throwErrors","extendEditorApi","getOptions","logLevels","level","indexOf","debug","ScrollIntoViewOptions","isUndefined","omitBy","SlateEditor","AutoScrollOperationsMap","ScrollMode","AUTO_SCROLL","DOMPlugin","WithAutoScrollOptions","mode","operations","scrollOptions","withScrolling","editor","fn","options","prevOptions","getOptions","prevAutoScroll","get","ops","setOptions","set","Operation","ScrollIntoViewOptions","TRange","bindFirst","SlateEditor","PluginConfig","createTSlatePlugin","withScrolling","AUTO_SCROLL","WeakMap","AutoScrollOperationsMap","Partial","Record","DomConfig","scrollMode","ScrollMode","scrollOperations","scrollOptions","DOMPlugin","key","options","insert_node","insert_text","extendEditorApi","editor","isScrolling","get","extendEditorTransforms","overrideEditor","api","getOption","tf","apply","transforms","operation","type","matched","operations","filter","op","length","mode","targetOp","at","offset","path","scrollTarget","scrollIntoView","properties","dom","prevSelection","currentKeyboardEvent","isHtmlElement","node","Node","Element","nodeType","ELEMENT_NODE","isHtmlText","node","Node","Text","nodeType","TEXT_NODE","inlineTagNames","Set","inlineTagNames","isHtmlElement","isHtmlInlineElement","node","Node","element","HTMLElement","tagNameIsInline","has","tagName","displayProperty","style","display","split","startsWith","parentElement","includes","isHtmlElement","isHtmlInlineElement","isHtmlBlockElement","node","Node","element","HTMLElement","TrimEndRule","TrimStartRule","LEADING_WHITESPACE_REGEX","TRAILING_NEWLINE_REGEX","collapseString","text","shouldCollapseWhiteSpace","trimEnd","trimStart","whiteSpaceIncludesNewlines","result","replace","replaceAll","isHtmlBlockElement","isLastNonEmptyTextOfInlineFormattingContext","initialText","Text","currentNode","Node","nextSibling","parentElement","textContent","length","CollapseWhiteSpaceState","upsertInlineFormattingContext","state","inlineFormattingContext","atStart","lastHasTrailingWhiteSpace","endInlineFormattingContext","CollapseWhiteSpaceState","TrimEndRule","TrimStartRule","collapseString","isLastNonEmptyTextOfInlineFormattingContext","upsertInlineFormattingContext","collapseWhiteSpaceText","text","Text","state","textContent","isWhiteSpaceOnly","trim","inlineFormattingContext","whiteSpaceRule","trimStart","atStart","lastHasTrailingWhiteSpace","trimEnd","shouldCollapseWhiteSpace","normal","pre","whiteSpaceIncludesNewlines","collapsedTextContent","endsWith","CollapseWhiteSpaceState","isHtmlElement","isHtmlText","collapseWhiteSpaceChildren","collapseWhiteSpaceElement","collapseWhiteSpaceText","collapseWhiteSpaceNode","node","Node","state","HTMLElement","Text","CollapseWhiteSpaceState","collapseWhiteSpaceNode","collapseWhiteSpaceChildren","node","Node","state","childNodes","Array","from","childNode","WhiteSpaceRule","inferWhiteSpaceRule","element","HTMLElement","whiteSpaceProperty","style","whiteSpace","tagName","CollapseWhiteSpaceState","isHtmlInlineElement","collapseWhiteSpaceChildren","inferWhiteSpaceRule","endInlineFormattingContext","collapseWhiteSpaceElement","element","HTMLElement","state","isInlineElement","previousWhiteSpaceRule","whiteSpaceRule","inferredWhiteSpaceRule","CollapseWhiteSpaceState","collapseWhiteSpaceElement","collapseWhiteSpace","element","HTMLElement","clonedElement","cloneNode","state","inlineFormattingContext","whiteSpaceRule","SlateEditor","DeserializeHtmlChildren","isSlateNode","deserializeHtmlNode","deserializeHtmlNodeChildren","editor","node","ChildNode","HTMLElement","isSlateParent","Array","from","childNodes","flatMap","child","nodeType","Descendant","jsx","SlateEditor","deserializeHtmlNodeChildren","htmlBodyToFragment","editor","element","HTMLElement","nodeName","htmlBrToNewLine","node","ChildNode","HTMLElement","nodeName","SlateEditor","AnyEditorPlugin","getEditorPlugin","isSlateLeaf","isSlatePluginNode","getDefaultNodeProps","element","type","HTMLElement","dataAttributes","Record","Object","entries","dataset","forEach","key","value","startsWith","includes","attributeKey","slice","charAt","toLowerCase","undefined","parsedValue","Number","isNaN","keys","length","getDataNodeProps","editor","plugin","toNodeProps","parsers","html","deserializer","disableDefaultNodeProps","defaultNodeProps","customNodeProps","AnyObject","Nullable","isDefined","castArray","SlateEditor","AnyEditorPlugin","HtmlDeserializer","getEditorPlugin","isSlateNode","getInjectedPlugins","getDataNodeProps","getDeserializedWithStaticRules","plugin","deserializer","parsers","html","rules","hasSlateRule","some","rule","validClassName","includes","key","staticRules","validNodeName","pluginDeserializeHtml","editor","deserializeLeaf","element","el","HTMLElement","node","isElement","isElementRoot","isLeaf","isLeafRoot","attributeNames","isElementRule","isLeafRule","query","parse","isValid","validAttribute","validStyle","validNodeNames","length","nodeName","classList","contains","value","Object","entries","values","style","defaultNodeValue","inject","nodeProps","getAttributeNames","attributeName","attributeValue","attributeValues","elAttribute","getAttribute","type","parsedNode","dataNodeProps","keys","injectedPlugins","forEach","injectedPlugin","res","elementAttributes","elementAttributeNames","elementAttributeName","attributes","AnyObject","Nullable","SlateEditor","HtmlDeserializer","pluginDeserializeHtml","pipeDeserializeHtmlElement","editor","element","HTMLElement","result","node","meta","pluginList","reverse","some","plugin","Descendant","jsx","SlateEditor","isSlateVoid","deserializeHtmlNodeChildren","pipeDeserializeHtmlElement","htmlElementToElement","editor","element","HTMLElement","isSlate","deserialized","node","withoutChildren","descendants","children","length","text","AnyObject","SlateEditor","pluginDeserializeHtml","pipeDeserializeHtmlLeaf","editor","element","HTMLElement","node","meta","pluginList","reverse","forEach","plugin","deserialized","deserializeLeaf","Descendant","ElementApi","TextApi","jsx","SlateEditor","mergeDeepToNodes","deserializeHtmlNodeChildren","pipeDeserializeHtmlLeaf","htmlElementToLeaf","editor","element","HTMLElement","node","reduce","arr","child","isElement","Object","keys","length","query","filter","n","isText","source","push","attributes","text","forEach","key","isHtmlText","htmlTextNodeToString","node","ChildNode","HTMLElement","parentElement","dataset","platePreventDeserialization","textContent","SlateEditor","DeserializeHtmlNodeReturnType","isSlateNode","htmlBodyToFragment","htmlBrToNewLine","htmlElementToElement","htmlElementToLeaf","htmlTextNodeToString","inlineTagNames","isHtmlElement","_isBlockElement","element","Element","has","tagName","shouldBrBecomeEmptyParagraph","node","nodeName","HTMLBRElement","className","parent","parentElement","hasAdjacentText","sibling","Node","previousSibling","nodeType","TEXT_NODE","textContent","trim","nextSibling","deserializeHtmlNode","editor","ChildNode","HTMLElement","textNode","children","text","type","getType","breakLine","fragment","SlateEditor","DeserializeHtmlNodeReturnType","deserializeHtmlNode","deserializeHtmlElement","editor","element","HTMLElement","htmlStringToDOMNode","rawHtml","node","document","createElement","innerHTML","Descendant","SlateEditor","WithRequiredKey","normalizeDescendantsToDocumentFragment","collapseWhiteSpace","deserializeHtmlElement","htmlStringToDOMNode","deserializeHtml","editor","shouldCollapseWhiteSpace","defaultElementPlugin","element","HTMLElement","fragment","descendants","parseHtmlDocument","html","DOMParser","parseFromString","bindFirst","createSlatePlugin","deserializeHtml","parseHtmlDocument","HtmlPlugin","key","extendApi","editor","deserialize","extend","parser","format","api","data","document","html","element","body","LengthConfig","createTSlatePlugin","LengthPlugin","key","overrideEditor","editor","getOptions","tf","apply","transforms","operation","withoutNormalizing","options","maxLength","length","api","string","overflowLength","delete","distance","reverse","unit","Descendant","NodeEntry","NodeProps","TNode","queryNode","isDefined","castArray","cloneDeep","OverrideEditor","NodeIdConfig","applyDeepToNodes","defaultsDeepToNodes","withNodeId","editor","getOptions","tf","apply","insertNode","insertNodes","idPropsCreator","idKey","idCreator","filterNode","nodeEntry","filter","filterText","type","undefined","removeIdFromNodeIfDuplicate","node","N","reuseId","api","some","at","match","overrideIdIfSet","_id","id","transforms","operation","allow","disableInsertOverrides","exclude","query","source","path","properties","Object","isExtensible","_nodes","options","nodes","length","map","Descendant","QueryNodeOptions","Value","ElementApi","queryNode","nanoid","PluginConfig","createTSlatePlugin","withNodeId","NodeIdOptions","disableInsertOverrides","filterInline","filterText","idKey","normalizeInitialValue","reuseId","idCreator","NormalizeNodeIdOptions","Pick","normalizeNodeId","value","V","options","allow","exclude","filter","normalizeNode","node","path","clonedNode","entry","isElement","inline","children","map","child","index","NodeIdConfig","nodeId","normalize","NodeIdPlugin","key","extendTransforms","editor","getOptions","addNodeId","api","isBlock","existingNode","tf","withoutSaving","setNodes","at","forEach","extend","firstNode","lastNode","id","overrideEditor","Descendant","NodeOperation","SlateEditor","pipeOnNodeChange","editor","node","prevNode","operation","meta","pluginCache","handlers","onNodeChange","some","key","plugin","getPlugin","dom","readOnly","handler","shouldTreatEventAsHandled","Descendant","TextOperation","SlateEditor","pipeOnTextChange","editor","node","text","prevText","operation","meta","pluginCache","handlers","onTextChange","some","key","plugin","getPlugin","dom","readOnly","handler","shouldTreatEventAsHandled","DEFAULT","handlers","inject","normalizeInitialValue","render","isEditOnly","readOnly","plugin","feature","editOnly","SlateEditor","getEditorPlugin","isEditOnly","pipeNormalizeInitialValue","editor","value","meta","isNormalizing","pluginCache","normalizeInitialValue","forEach","key","p","getPlugin","dom","readOnly","children","EditorTransforms","TSelection","Value","SlateEditor","pipeNormalizeInitialValue","InitOptions","autoSelect","selection","shouldNormalizeEditor","value","onReady","ctx","editor","isAsync","init","onValueLoaded","children","length","api","create","edge","target","start","end","tf","select","normalize","force","html","deserialize","element","result","then","resolvedValue","EditorAboveOptions","combineMatchOptions","PathApi","SlateEditor","getPluginByType","InsertExitBreakOptions","match","reverse","insertExitBreak","editor","selection","api","isCollapsed","block","target","above","at","n","p","length","type","node","isStrictSiblings","ancestorPath","targetPath","next","tf","insertNodes","create","select","Path","NodeApi","SlateEditor","BaseParagraphPlugin","resetBlock","editor","at","entry","api","block","path","tf","withoutNormalizing","id","type","otherProps","extractProps","Object","keys","forEach","key","unsetNodes","paragraphType","getType","setNodes","Descendant","EditorTransforms","Value","SlateEditor","setValue","editor","value","V","children","api","html","deserialize","element","length","create","tf","replaceNodes","at","Descendant","NodeOperation","TextOperation","TText","NodeApi","OperationApi","PathApi","OmitFirst","bindFirst","SlateEditor","PluginConfig","createTSlatePlugin","pipeOnNodeChange","pipeOnTextChange","init","insertExitBreak","resetBlock","setValue","SlateExtensionConfig","onNodeChange","options","editor","node","operation","prevNode","onTextChange","prevText","text","SlateExtensionPlugin","key","extendEditorTransforms","getOption","tf","apply","noop","hasNodeHandlers","meta","pluginCache","handlers","length","hasTextHandlers","parentNode","isNodeOperation","type","get","path","isTextOperation","parentPath","parent","textNode","prevPath","previous","newPath","eventIsHandled","textNodeAfter","Descendant","Editor","ElementApi","TextApi","SlateEditor","WithRequiredKey","BaseParagraphPlugin","isInlineNode","editor","node","isText","isElement","api","isInline","makeBlockLazy","type","children","hasDifferentChildNodes","descendants","some","descendant","index","arr","prevDescendant","normalizeDifferentNodeTypes","makeDefaultBlock","hasDifferentNodes","fragment","reduce","memo","block","precedingBlock","push","normalizeEmptyChildren","length","text","normalize","map","normalizeDescendantsToDocumentFragment","defaultElementPlugin","defaultType","getType","key","SlateEditor","ParserOptions","AnyEditorPlugin","getEditorPlugin","pipeInsertDataQuery","editor","plugins","Partial","options","every","p","query","parser","pipeInsertFragment","pipeTransformData","pipeTransformFragment","Parser","createSlatePlugin","getEditorPlugin","getInjectedPlugins","pipeInsertDataQuery","ParserPlugin","key","overrideEditor","editor","tf","insertData","transforms","dataTransfer","DataTransfer","inserted","meta","pluginList","reverse","some","plugin","parser","injectedPlugins","deserialize","format","mimeTypes","formats","Array","isArray","mimeTypeList","map","fmt","includes","mimeType","data","getData","files","length","fragment","AnyPluginConfig","PluginConfig","SlatePlugin","AstPlugin","HistoryPlugin","OverridePlugin","ParserPlugin","DebugErrorType","LogLevel","DebugPlugin","DOMPlugin","HtmlPlugin","LengthPlugin","AffinityPlugin","NodeIdConfig","NodeIdPlugin","BaseParagraphPlugin","SlateExtensionConfig","SlateExtensionPlugin","ChunkingConfig","ChunkingPlugin","CorePlugin","ReturnType","getCorePlugins","GetCorePluginsOptions","affinity","chunking","maxLength","nodeId","plugins","resolvedNodeId","process","env","NODE_ENV","undefined","corePlugins","DebugConfig","configure","options","enabled","customPluginsMap","Map","map","plugin","key","corePlugin","customPlugin","get","index","findIndex","p","splice","CorePluginTransforms","CorePluginApi","isProduction","logger","Partial","Record","LogFunction","logLevel","throwErrors","debug","error","message","type","details","info","log","warn","LengthConfig","Editor","TSelection","Value","createEditor","nanoid","PluginStoreFactory","AnyPluginConfig","NodeComponents","AnySlatePlugin","ChunkingConfig","NodeIdConfig","InferPlugins","SlateEditor","TSlateEditor","resolvePlugins","createSlatePlugin","getPluginType","getSlatePlugin","CorePlugin","getCorePlugins","BaseWithSlateOptions","id","userId","affinity","autoSelect","chunking","components","maxLength","nodeId","optionsStoreFactory","plugins","P","readOnly","selection","shouldNormalizeEditor","skipInitialization","WithSlateOptions","Pick","Partial","value","editor","Promise","V","rootPlugin","plugin","onReady","ctx","isAsync","withSlate","e","pluginConfig","meta","key","isFallback","dom","composing","currentKeyboardEvent","focused","prevSelection","getApi","api","getTransforms","transforms","getPlugin","getType","pluginKey","getInjectProps","nodeProps","inject","nodeKey","styleKey","getOptionsStore","optionsStore","getOptions","store","options","get","getOption","args","selectors","debug","error","setOption","set","setOptions","draft","Object","assign","corePlugins","rootPluginInstance","priority","override","normalizeNode","tf","shouldNormalizeNode","init","CreateSlateEditorOptions","createSlateEditor"],"sources":["../src/internal/utils/isFunction.ts","../src/internal/utils/mergePlugins.ts","../src/lib/plugin/createSlatePlugin.ts","../src/lib/plugin/getEditorPlugin.ts","../src/internal/plugin/resolvePlugin.ts","../src/lib/plugin/getSlatePlugin.ts","../src/internal/plugin/resolvePlugins.ts","../src/lib/plugins/AstPlugin.ts","../src/lib/plugins/HistoryPlugin.ts","../src/lib/plugins/paragraph/BaseParagraphPlugin.ts","../src/lib/plugins/override/withBreakRules.ts","../src/lib/plugins/override/withDeleteRules.ts","../src/lib/plugins/override/withMergeRules.ts","../src/lib/plugins/override/withNormalizeRules.ts","../src/lib/plugins/override/OverridePlugin.ts","../src/internal/plugin/pipeInsertFragment.ts","../src/internal/plugin/pipeTransformData.ts","../src/internal/plugin/pipeTransformFragment.ts","../src/lib/utils/applyDeepToNodes.ts","../src/lib/utils/checkUtils.ts","../src/lib/utils/defaultsDeepToNodes.ts","../src/lib/utils/getInjectMatch.ts","../src/lib/utils/getInjectedPlugins.ts","../src/lib/utils/getNodeDataAttributeKeys.ts","../src/lib/utils/getPluginNodeProps.ts","../src/lib/utils/getSlateClass.ts","../src/lib/utils/mergeDeepToNodes.ts","../src/lib/plugins/affinity/queries/getEdgeNodes.ts","../src/lib/plugins/affinity/queries/getMarkBoundaryAffinity.ts","../src/lib/plugins/affinity/queries/isNodeAffinity.ts","../src/lib/plugins/affinity/transforms/setAffinitySelection.ts","../src/lib/plugins/affinity/AffinityPlugin.ts","../src/lib/plugins/chunking/withChunking.ts","../src/lib/plugins/chunking/ChunkingPlugin.ts","../src/lib/plugins/debug/DebugPlugin.ts","../src/lib/plugins/dom/withScrolling.ts","../src/lib/plugins/dom/DOMPlugin.ts","../src/lib/plugins/html/utils/isHtmlElement.ts","../src/lib/plugins/html/utils/isHtmlText.ts","../src/lib/plugins/html/utils/inlineTagNames.ts","../src/lib/plugins/html/utils/isHtmlInlineElement.ts","../src/lib/plugins/html/utils/isHtmlBlockElement.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseString.ts","../src/lib/plugins/html/utils/collapse-white-space/isLastNonEmptyTextOfInlineFormattingContext.ts","../src/lib/plugins/html/utils/collapse-white-space/stateTransforms.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceText.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceNode.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceChildren.ts","../src/lib/plugins/html/utils/collapse-white-space/inferWhiteSpaceRule.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceElement.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpace.ts","../src/lib/plugins/html/utils/deserializeHtmlNodeChildren.ts","../src/lib/plugins/html/utils/htmlBodyToFragment.ts","../src/lib/plugins/html/utils/htmlBrToNewLine.ts","../src/lib/plugins/html/utils/getDataNodeProps.ts","../src/lib/plugins/html/utils/pluginDeserializeHtml.ts","../src/lib/plugins/html/utils/pipeDeserializeHtmlElement.ts","../src/lib/plugins/html/utils/htmlElementToElement.ts","../src/lib/plugins/html/utils/pipeDeserializeHtmlLeaf.ts","../src/lib/plugins/html/utils/htmlElementToLeaf.ts","../src/lib/plugins/html/utils/htmlTextNodeToString.ts","../src/lib/plugins/html/utils/deserializeHtmlNode.ts","../src/lib/plugins/html/utils/deserializeHtmlElement.ts","../src/lib/plugins/html/utils/htmlStringToDOMNode.ts","../src/lib/plugins/html/utils/deserializeHtml.ts","../src/lib/plugins/html/utils/parseHtmlDocument.ts","../src/lib/plugins/html/HtmlPlugin.ts","../src/lib/plugins/length/LengthPlugin.ts","../src/lib/plugins/node-id/withNodeId.ts","../src/lib/plugins/node-id/NodeIdPlugin.ts","../src/lib/utils/pipeOnNodeChange.ts","../src/lib/utils/pipeOnTextChange.ts","../src/internal/plugin/isEditOnlyDisabled.ts","../src/internal/plugin/pipeNormalizeInitialValue.ts","../src/lib/plugins/slate-extension/transforms/init.ts","../src/lib/plugins/slate-extension/transforms/insertExitBreak.ts","../src/lib/plugins/slate-extension/transforms/resetBlock.ts","../src/lib/plugins/slate-extension/transforms/setValue.ts","../src/lib/plugins/slate-extension/SlateExtensionPlugin.ts","../src/lib/utils/normalizeDescendantsToDocumentFragment.ts","../src/lib/utils/pipeInsertDataQuery.ts","../src/lib/plugins/ParserPlugin.ts","../src/lib/plugins/getCorePlugins.ts","../src/lib/editor/withSlate.ts"],"sourcesContent":["export function isFunction(value: any): value is Function {\n return typeof value === 'function';\n}\n","import mergeWith from 'lodash/mergeWith.js';\n\nimport type { SlatePlugin } from '../../lib';\n\nexport function mergePlugins<T>(basePlugin: T, ...sourcePlugins: any[]): T {\n return mergeWith(\n {},\n basePlugin,\n ...sourcePlugins,\n (objValue: unknown, srcValue: unknown, key: keyof SlatePlugin) => {\n // Overwrite array (including plugins) without cloning\n if (Array.isArray(srcValue)) {\n return srcValue;\n }\n // Shallow merge options\n if (key === 'options') {\n return { ...(objValue as any), ...(srcValue as any) };\n }\n }\n );\n}\n","import { type Modify, isDefined } from '@udecode/utils';\n\nimport type { SlateEditor } from '../editor/SlateEditor';\nimport type { AnyPluginConfig, PluginConfig } from './BasePlugin';\nimport type {\n SlatePlugin,\n SlatePluginMethods,\n SlatePlugins,\n} from './SlatePlugin';\n\nimport { isFunction } from '../../internal/utils/isFunction';\nimport { mergePlugins } from '../../internal/utils/mergePlugins';\n\ntype SlatePluginConfig<\n K extends string = any,\n O = {},\n A = {},\n T = {},\n S = {},\n> = Omit<\n Partial<\n Modify<\n SlatePlugin<PluginConfig<K, O, A, T, S>>,\n { node?: Partial<SlatePlugin<PluginConfig<K, O, A, T, S>>['node']> }\n >\n >,\n keyof SlatePluginMethods | 'optionsStore'\n>;\n\ntype TSlatePluginConfig<C extends AnyPluginConfig = PluginConfig> = Omit<\n Partial<\n Modify<\n SlatePlugin<C>,\n {\n node?: Partial<SlatePlugin<C>['node']>;\n }\n >\n >,\n keyof SlatePluginMethods | 'optionsStore'\n>;\n\n/**\n * Creates a new Plate plugin with the given configuration.\n *\n * @remarks\n * - The plugin's key is required and specified by the K generic.\n * - The `__extensions` array stores functions to be applied when `resolvePlugin`\n * is called with an editor.\n * - The `extend` method adds new extensions to be applied later.\n * - The `extendPlugin` method extends an existing plugin (including nested\n * plugins) or adds a new one if not found.\n *\n * @example\n * const myPlugin = createSlatePlugin<\n * 'myPlugin',\n * MyOptions,\n * MyApi,\n * MyTransforms\n * >({\n * key: 'myPlugin',\n * options: { someOption: true },\n * transforms: { someTransform: () => {} },\n * });\n *\n * const extendedPlugin = myPlugin.extend({\n * options: { anotherOption: false },\n * });\n *\n * const pluginWithNestedExtension = extendedPlugin.extendPlugin(\n * nestedPlugin,\n * { options: { nestedOption: true } }\n * );\n *\n * @template K - The literal type of the plugin key.\n * @template O - The type of the plugin options.\n * @template A - The type of the plugin utilities.\n * @template T - The type of the plugin transforms.\n * @template S - The type of the plugin storage.\n * @param {Partial<SlatePlugin<K, O, A, T, S>>} config - The configuration\n * object for the plugin.\n * @returns {SlatePlugin<K, O, A, T, S>} A new Plate plugin instance with the\n * following properties and methods:\n *\n * - All properties from the input config, merged with default values.\n * - `configure`: A method to create a new plugin instance with updated options.\n * - `extend`: A method to create a new plugin instance with additional\n * configuration.\n * - `extendPlugin`: A method to extend an existing plugin (including nested\n * plugins) or add a new one if not found.\n */\nexport function createSlatePlugin<\n K extends string = any,\n O = {},\n A = {},\n T = {},\n S = {},\n>(\n config:\n | ((editor: SlateEditor) => SlatePluginConfig<K, O, A, T, S>)\n | SlatePluginConfig<K, O, A, T, S> = {}\n): SlatePlugin<PluginConfig<K, O, A, T, S>> {\n let baseConfig: Partial<SlatePlugin<PluginConfig<K, O, A, T, S>>>;\n let initialExtension: any;\n\n if (isFunction(config)) {\n baseConfig = { key: '' as K };\n initialExtension = (editor: any) => config(editor);\n } else {\n baseConfig = config as any;\n }\n\n const key = baseConfig.key ?? '';\n\n const plugin = mergePlugins(\n {\n key,\n __apiExtensions: [],\n __configuration: null,\n __extensions: initialExtension ? [initialExtension] : [],\n __selectorExtensions: [],\n api: {},\n dependencies: [],\n editor: {},\n handlers: {},\n inject: {},\n node: { type: key },\n options: {},\n override: {},\n parser: {},\n parsers: {},\n plugins: [],\n priority: 100,\n render: {},\n rules: {},\n shortcuts: {},\n transforms: {},\n },\n config\n ) as unknown as SlatePlugin<PluginConfig<K, O, A, T, S>>;\n\n if (plugin.node.isLeaf && !isDefined(plugin.node.isDecoration)) {\n plugin.node.isDecoration = true;\n }\n\n plugin.configure = (config) => {\n const newPlugin = { ...plugin };\n newPlugin.__configuration = (ctx) =>\n isFunction(config) ? config(ctx as any) : config;\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.configurePlugin = (p, config) => {\n const newPlugin = { ...plugin };\n\n const configureNestedPlugin = (\n plugins: SlatePlugins\n ): { found: boolean; plugins: SlatePlugins } => {\n let found = false;\n\n const updatedPlugins = plugins.map((nestedPlugin) => {\n if (nestedPlugin.key === p.key) {\n found = true;\n\n return createSlatePlugin({\n ...nestedPlugin,\n __configuration: (ctx: any) =>\n isFunction(config) ? config(ctx) : config,\n } as any);\n }\n if (nestedPlugin.plugins && nestedPlugin.plugins.length > 0) {\n const result = configureNestedPlugin(nestedPlugin.plugins);\n\n if (result.found) {\n found = true;\n\n return { ...nestedPlugin, plugins: result.plugins };\n }\n }\n\n return nestedPlugin;\n });\n\n return { found, plugins: updatedPlugins };\n };\n\n const result = configureNestedPlugin(newPlugin.plugins as any);\n newPlugin.plugins = result.plugins as any;\n\n // We're not adding a new plugin if not found\n\n return createSlatePlugin(newPlugin);\n };\n\n plugin.extendEditorApi = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__apiExtensions = [\n ...(newPlugin.__apiExtensions as any),\n { extension, isPluginSpecific: false },\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.extendSelectors = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__selectorExtensions = [\n ...(newPlugin.__selectorExtensions as any),\n extension,\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.extendApi = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__apiExtensions = [\n ...(newPlugin.__apiExtensions as any),\n { extension, isPluginSpecific: true },\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.extendEditorTransforms = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__apiExtensions = [\n ...(newPlugin.__apiExtensions as any),\n { extension, isPluginSpecific: false, isTransform: true },\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.extendTransforms = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__apiExtensions = [\n ...(newPlugin.__apiExtensions as any),\n { extension, isPluginSpecific: true, isTransform: true },\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.overrideEditor = (extension) => {\n const newPlugin = { ...plugin };\n newPlugin.__apiExtensions = [\n ...(newPlugin.__apiExtensions as any),\n {\n extension,\n isOverride: true,\n isPluginSpecific: false,\n isTransform: true,\n },\n ];\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.extend = (extendConfig) => {\n let newPlugin = { ...plugin };\n\n if (isFunction(extendConfig)) {\n newPlugin.__extensions = [\n ...(newPlugin.__extensions as any),\n extendConfig,\n ];\n } else {\n newPlugin = mergePlugins(newPlugin, extendConfig as any);\n }\n\n return createSlatePlugin(newPlugin) as any;\n };\n\n plugin.clone = () => mergePlugins(plugin);\n\n plugin.extendPlugin = (p, extendConfig) => {\n const newPlugin = { ...plugin };\n\n const extendNestedPlugin = (\n plugins: SlatePlugins\n ): { found: boolean; plugins: SlatePlugins } => {\n let found = false;\n const updatedPlugins = plugins.map((nestedPlugin) => {\n if (nestedPlugin.key === p.key) {\n found = true;\n\n return createSlatePlugin({\n ...nestedPlugin,\n __extensions: [\n ...(nestedPlugin.__extensions as any),\n (ctx: any) =>\n isFunction(extendConfig) ? extendConfig(ctx) : extendConfig,\n ],\n } as any);\n }\n if (nestedPlugin.plugins && nestedPlugin.plugins.length > 0) {\n const result = extendNestedPlugin(nestedPlugin.plugins);\n\n if (result.found) {\n found = true;\n\n return { ...nestedPlugin, plugins: result.plugins };\n }\n }\n\n return nestedPlugin;\n });\n\n return { found, plugins: updatedPlugins };\n };\n\n const result = extendNestedPlugin(newPlugin.plugins as any);\n newPlugin.plugins = result.plugins as any;\n\n // If the plugin wasn't found at any level, add it at the top level\n if (!result.found) {\n newPlugin.plugins.push(\n createSlatePlugin({\n key: p.key,\n __extensions: [\n (ctx: any) =>\n isFunction(extendConfig)\n ? extendConfig(ctx as any)\n : (extendConfig as any),\n ],\n } as any)\n );\n }\n\n return createSlatePlugin(newPlugin);\n };\n\n plugin.withComponent = (component) =>\n plugin.extend({\n node: { component },\n render: { node: component },\n }) as any;\n\n return plugin;\n}\n\n/**\n * Explicitly typed version of `createSlatePlugin`.\n *\n * @remarks\n * While `createSlatePlugin` uses type inference, this function requires an\n * explicit type parameter. Use this when you need precise control over the\n * plugin's type structure or when type inference doesn't provide the desired\n * result.\n */\nexport function createTSlatePlugin<C extends AnyPluginConfig = PluginConfig>(\n config:\n | ((editor: SlateEditor) => TSlatePluginConfig<C>)\n | TSlatePluginConfig<C> = {}\n): SlatePlugin<C> {\n return createSlatePlugin(config as any) as any;\n}\n","import type { SlateEditor } from '../editor';\nimport type { AnyPluginConfig, WithRequiredKey } from './BasePlugin';\nimport type {\n InferConfig,\n SlatePlugin,\n SlatePluginContext,\n} from './SlatePlugin';\n\nexport function getEditorPlugin<\n P extends AnyPluginConfig | SlatePlugin<AnyPluginConfig>,\n>(\n editor: SlateEditor,\n p: WithRequiredKey<P>\n): SlatePluginContext<InferConfig<P> extends never ? P : InferConfig<P>> {\n const plugin = editor.getPlugin(p) as any;\n\n return {\n api: editor.api,\n editor,\n plugin: plugin as any,\n setOption: ((keyOrOptions: any, value: any) =>\n editor.setOption(plugin, keyOrOptions, value)) as any,\n setOptions: ((options: any) => editor.setOptions(plugin, options)) as any,\n tf: editor.transforms,\n type: plugin.node.type,\n getOption: (key: any, ...args: any) =>\n (editor.getOption as any)(plugin, key, ...args),\n getOptions: () => editor.getOptions(plugin),\n };\n}\n","import merge from 'lodash/merge.js';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { PluginConfig } from '../../lib/plugin/BasePlugin';\nimport type { AnySlatePlugin, SlatePlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin/getEditorPlugin';\nimport { mergePlugins } from '../utils/mergePlugins';\n\n/**\n * Resolves and finalizes a plugin configuration for use in a Plate editor.\n *\n * This function processes a given plugin configuration, applying any extensions\n * and resolving nested plugins. It prepares the plugin for integration into the\n * Plate editor system by:\n *\n * 1. Cloning the plugin to avoid mutating the original\n * 2. Applying all stored extensions to the plugin\n * 3. Clearing the extensions array after application\n *\n * @example\n * const plugin = createSlatePlugin({ key: 'myPlugin', ...otherOptions }).extend(...);\n * const resolvedPlugin = resolvePlugin(editor, plugin);\n */\nexport const resolvePlugin = <P extends AnySlatePlugin>(\n editor: SlateEditor,\n _plugin: P\n): P => {\n // Create a deep clone of the plugin\n let plugin = mergePlugins({}, _plugin) as P;\n\n plugin.__resolved = true;\n\n // Apply the stored configuration first\n if (plugin.__configuration) {\n const configResult = plugin.__configuration(\n getEditorPlugin(editor, plugin as any)\n );\n\n plugin = mergePlugins(plugin, configResult);\n\n (plugin as any).__configuration = undefined;\n }\n // Apply all stored extensions\n if (plugin.__extensions && plugin.__extensions.length > 0) {\n for (const extension of plugin.__extensions) {\n plugin = mergePlugins(\n plugin,\n extension(getEditorPlugin(editor, plugin as any))\n );\n }\n plugin.__extensions = [];\n }\n\n const targetPluginToInject = plugin.inject?.targetPluginToInject;\n const targetPlugins = plugin.inject?.targetPlugins;\n\n if (targetPluginToInject && targetPlugins && targetPlugins.length > 0) {\n plugin.inject = plugin.inject || {};\n plugin.inject.plugins = merge(\n {},\n plugin.inject.plugins,\n Object.fromEntries(\n targetPlugins.map((targetPlugin) => {\n const injectedPlugin = targetPluginToInject({\n ...getEditorPlugin(editor, plugin as any),\n targetPlugin,\n });\n\n return [targetPlugin, injectedPlugin];\n })\n )\n );\n }\n if (plugin.node?.component) {\n plugin.render.node = plugin.node.component;\n }\n if (plugin.render?.node) {\n plugin.node.component = plugin.render.node;\n }\n\n validatePlugin(editor, plugin);\n\n return plugin;\n};\n\nexport const validatePlugin = <\n K extends string = any,\n O = {},\n A = {},\n T = {},\n S = {},\n>(\n editor: SlateEditor,\n plugin: SlatePlugin<PluginConfig<K, O, A, T, S>>\n) => {\n if (!plugin.__extensions) {\n editor.api.debug.error(\n `Invalid plugin '${plugin.key}', you should use createSlatePlugin.`,\n 'USE_CREATE_PLUGIN'\n );\n }\n if (plugin.node.isElement && plugin.node.isLeaf) {\n editor.api.debug.error(\n `Plugin ${plugin.key} cannot be both an element and a leaf.`,\n 'PLUGIN_NODE_TYPE'\n );\n }\n};\n","import type { SlateEditor } from '../editor';\nimport type {\n AnyPluginConfig,\n PluginConfig,\n WithRequiredKey,\n} from './BasePlugin';\nimport type { AnySlatePlugin, SlatePlugin } from './SlatePlugin';\n\nimport { resolvePlugin } from '../../internal/plugin/resolvePlugin';\nimport { createSlatePlugin } from './createSlatePlugin';\n\n/** Get editor plugin by key or plugin object. */\nexport function getSlatePlugin<C extends AnyPluginConfig = PluginConfig>(\n editor: SlateEditor,\n p: WithRequiredKey<C>\n): C extends { node: any } ? C : SlatePlugin<C> {\n let plugin = p as any;\n\n const editorPlugin = editor.plugins[p.key] as any;\n\n if (!editorPlugin) {\n // When passing only { key }\n if (!plugin.node) {\n plugin = createSlatePlugin(plugin);\n }\n\n // Resolve is need when passing an external plugin with extensions (e.g. in withLink)\n return plugin.__resolved ? plugin : resolvePlugin(editor, plugin);\n }\n\n return editorPlugin;\n}\n\n/** Get editor plugin type by key or plugin object. */\nexport function getPluginType(editor: SlateEditor, key: string): string {\n const p = editor.getPlugin<AnySlatePlugin>({ key });\n\n return p.node.type ?? p.key ?? '';\n}\n\n/** Get editor plugin types by key. */\nexport const getPluginTypes = (editor: SlateEditor, keys: string[]) =>\n keys.map((key) => editor.getType(key));\n\nexport const getPluginKey = (\n editor: SlateEditor,\n type: string\n): string | undefined => editor.meta.pluginCache.node.types[type];\n\nexport const getPluginKeys = (editor: SlateEditor, types: string[]): string[] =>\n types\n .map((type) => {\n const pluginKey = getPluginKey(editor, type);\n return pluginKey ?? type;\n })\n .filter(Boolean);\n\nexport const getPluginByType = (editor: SlateEditor, type: string) => {\n const key = getPluginKey(editor, type);\n if (!key) return null;\n\n return editor.getPlugin({ key });\n};\n\nexport const getContainerTypes = (editor: SlateEditor) =>\n getPluginTypes(editor, editor.meta.pluginCache.node.isContainer);\n","import {\n assignLegacyApi,\n assignLegacyTransforms,\n syncLegacyMethods,\n} from '@platejs/slate';\nimport { isDefined } from '@udecode/utils';\nimport merge from 'lodash/merge.js';\nimport { createVanillaStore } from 'zustand-x/vanilla';\n\nimport type { SlateEditor, SlatePlugin, SlatePlugins } from '../../lib';\n\nimport { getEditorPlugin } from '../../lib/plugin';\nimport { mergePlugins } from '../utils/mergePlugins';\nimport { resolvePlugin } from './resolvePlugin';\n\n/**\n * Initialize and configure the editor's plugin system. This function sets up\n * the editor's plugins, resolving core and custom plugins, and applying any\n * overrides specified in the plugins.\n */\nexport type PluginStoreFactory = typeof createVanillaStore;\n\nexport const resolvePlugins = (\n editor: SlateEditor,\n plugins: SlatePlugins = [],\n createStore: PluginStoreFactory = createVanillaStore\n) => {\n editor.plugins = {};\n editor.meta.pluginList = [];\n editor.meta.shortcuts = {} as Record<\n string,\n SlatePlugin['shortcuts'][string]\n >;\n editor.meta.components = {};\n editor.meta.pluginCache = {\n decorate: [],\n handlers: {\n onChange: [],\n onNodeChange: [],\n onTextChange: [],\n },\n inject: {\n nodeProps: [],\n },\n node: {\n isContainer: [],\n isLeaf: [],\n isText: [],\n leafProps: [],\n textProps: [],\n types: {},\n },\n normalizeInitialValue: [],\n render: {\n aboveEditable: [],\n aboveNodes: [],\n aboveSlate: [],\n afterContainer: [],\n afterEditable: [],\n beforeContainer: [],\n beforeEditable: [],\n belowNodes: [],\n belowRootNodes: [],\n },\n rules: {\n match: [],\n },\n useHooks: [],\n };\n\n const resolvedPlugins = resolveAndSortPlugins(editor, plugins);\n\n applyPluginsToEditor(editor, resolvedPlugins);\n\n resolvePluginOverrides(editor);\n\n resolvePluginStores(editor, createStore);\n\n // Last pass\n editor.meta.pluginList.forEach((plugin: SlatePlugin) => {\n if (plugin.extendEditor) {\n // biome-ignore lint/style/noParameterAssign: Intentional editor extension pattern\n editor = plugin.extendEditor(getEditorPlugin(editor, plugin) as any);\n\n // Sync any editor methods that were modified by extendEditor\n syncLegacyMethods(editor);\n }\n\n // Sync overridden plugin methods to legacy editor methods\n resolvePluginMethods(editor, plugin);\n\n if (plugin.node?.isContainer) {\n editor.meta.pluginCache.node.isContainer.push(plugin.key);\n }\n\n editor.meta.pluginCache.node.types[plugin.node.type] = plugin.key;\n\n if (plugin.inject?.nodeProps) {\n editor.meta.pluginCache.inject.nodeProps.push(plugin.key);\n }\n\n if (plugin.render?.node) {\n editor.meta.components[plugin.key] = plugin.render.node;\n }\n\n if (\n plugin.node?.isLeaf &&\n (plugin.node?.isDecoration === true || plugin.render.leaf)\n ) {\n editor.meta.pluginCache.node.isLeaf.push(plugin.key);\n }\n\n if (plugin.node.isLeaf && plugin.node.isDecoration === false) {\n editor.meta.pluginCache.node.isText.push(plugin.key);\n }\n\n if (plugin.node?.leafProps) {\n editor.meta.pluginCache.node.leafProps.push(plugin.key);\n }\n\n if (plugin.node.textProps) {\n editor.meta.pluginCache.node.textProps.push(plugin.key);\n }\n\n if (plugin.render.aboveEditable) {\n editor.meta.pluginCache.render.aboveEditable.push(plugin.key);\n }\n\n if (plugin.render.aboveSlate) {\n editor.meta.pluginCache.render.aboveSlate.push(plugin.key);\n }\n\n if (plugin.render.afterEditable) {\n editor.meta.pluginCache.render.afterEditable.push(plugin.key);\n }\n\n if (plugin.render.beforeEditable) {\n editor.meta.pluginCache.render.beforeEditable.push(plugin.key);\n }\n\n if (plugin.rules?.match) {\n editor.meta.pluginCache.rules.match.push(plugin.key);\n }\n\n if (plugin.render.afterContainer) {\n editor.meta.pluginCache.render.afterContainer.push(plugin.key);\n }\n\n if (plugin.render.beforeContainer) {\n editor.meta.pluginCache.render.beforeContainer.push(plugin.key);\n }\n\n if (plugin.render.belowRootNodes) {\n editor.meta.pluginCache.render.belowRootNodes.push(plugin.key);\n }\n\n if (plugin.normalizeInitialValue) {\n editor.meta.pluginCache.normalizeInitialValue.push(plugin.key);\n }\n\n if (plugin.decorate) {\n editor.meta.pluginCache.decorate.push(plugin.key);\n }\n\n if (plugin.render.aboveNodes) {\n editor.meta.pluginCache.render.aboveNodes.push(plugin.key);\n }\n\n if (plugin.render.belowNodes) {\n editor.meta.pluginCache.render.belowNodes.push(plugin.key);\n }\n\n if ((plugin as any).useHooks) {\n editor.meta.pluginCache.useHooks.push(plugin.key);\n }\n\n if ((plugin as any).handlers?.onChange) {\n editor.meta.pluginCache.handlers.onChange.push(plugin.key);\n }\n if ((plugin as any).handlers?.onNodeChange) {\n editor.meta.pluginCache.handlers.onNodeChange.push(plugin.key);\n }\n if ((plugin as any).handlers?.onTextChange) {\n editor.meta.pluginCache.handlers.onTextChange.push(plugin.key);\n }\n });\n\n resolvePluginShortcuts(editor);\n\n return editor;\n};\n\nconst resolvePluginStores = (\n editor: SlateEditor,\n createStore: PluginStoreFactory\n) => {\n // Create zustand stores for each plugin\n editor.meta.pluginList.forEach((plugin) => {\n let store = createStore(plugin.options, {\n mutative: true,\n name: plugin.key,\n });\n\n // Apply option extensions\n if (\n (plugin as any).__selectorExtensions &&\n (plugin as any).__selectorExtensions.length > 0\n ) {\n (plugin as any).__selectorExtensions.forEach((extension: any) => {\n const extendedOptions = extension(getEditorPlugin(editor, plugin));\n\n store = store.extendSelectors(() => extendedOptions);\n });\n }\n\n plugin.optionsStore = store;\n });\n};\n\nconst resolvePluginMethods = (editor: SlateEditor, plugin: any) => {\n // Merge APIs\n Object.entries(plugin.api).forEach(([apiKey, apiFunction]) => {\n (editor.api as any)[apiKey] = apiFunction;\n });\n\n // Apply API and transform extensions\n if (plugin.__apiExtensions && plugin.__apiExtensions.length > 0) {\n plugin.__apiExtensions.forEach(\n ({ extension, isOverride, isPluginSpecific, isTransform }: any) => {\n const newExtensions = extension(getEditorPlugin(editor, plugin) as any);\n\n if (isOverride) {\n // Handle combined API and transforms override\n if (newExtensions.api) {\n merge(editor.api, newExtensions.api);\n merge(plugin.api, newExtensions.api);\n assignLegacyApi(editor, editor.api);\n }\n if (newExtensions.transforms) {\n merge(editor.transforms, newExtensions.transforms);\n merge(plugin.transforms, newExtensions.transforms);\n assignLegacyTransforms(editor, newExtensions.transforms);\n }\n } else if (isTransform) {\n // Handle transforms\n if (isPluginSpecific) {\n // Plugin-specific transform\n if (!(editor.transforms as any)[plugin.key]) {\n (editor.transforms as any)[plugin.key] = {};\n }\n if (!(plugin.transforms as any)[plugin.key]) {\n (plugin.transforms as any)[plugin.key] = {};\n }\n\n merge((editor.transforms as any)[plugin.key], newExtensions);\n merge((plugin.transforms as any)[plugin.key], newExtensions);\n } else {\n // Editor-wide transform\n merge(editor.transforms, newExtensions);\n merge(plugin.transforms, newExtensions);\n assignLegacyTransforms(editor, newExtensions);\n }\n } else if (isPluginSpecific) {\n // Handle APIs - Plugin-specific API\n if (!(editor.api as any)[plugin.key]) {\n (editor.api as any)[plugin.key] = {};\n }\n if (!(plugin.api as any)[plugin.key]) {\n (plugin.api as any)[plugin.key] = {};\n }\n\n merge((editor.api as any)[plugin.key], newExtensions);\n merge((plugin.api as any)[plugin.key], newExtensions);\n } else {\n // Handle APIs - Editor-wide API\n merge(editor.api, newExtensions);\n merge(plugin.api, newExtensions);\n assignLegacyApi(editor, editor.api);\n }\n }\n );\n plugin.__apiExtensions = undefined;\n }\n};\n\nconst resolvePluginShortcuts = (editor: SlateEditor) => {\n editor.meta.shortcuts = {} as Record<\n string,\n SlatePlugin['shortcuts'][string]\n >; // Initialize with a more specific type\n\n editor.meta.pluginList.forEach((plugin) => {\n Object.entries(plugin.shortcuts).forEach(([originalKey, hotkey]) => {\n const namespacedKey = `${plugin.key}.${originalKey}`;\n\n if (hotkey === null) {\n // If hotkey is null, remove the namespaced shortcut\n delete (\n editor.meta.shortcuts as Record<\n string,\n SlatePlugin['shortcuts'][string]\n >\n )[namespacedKey];\n } else if (hotkey && typeof hotkey === 'object') {\n const resolvedHotkey = { ...hotkey } as NonNullable<\n SlatePlugin['shortcuts'][string]\n >;\n\n // If no custom handler is provided, try to use plugin transform method as handler\n if (!resolvedHotkey.handler) {\n const pluginSpecificTransforms = (plugin.transforms as any)?.[\n plugin.key\n ];\n const pluginSpecificApi = (plugin.api as any)?.[plugin.key];\n\n if (pluginSpecificTransforms?.[originalKey]) {\n resolvedHotkey.handler = () =>\n pluginSpecificTransforms[originalKey]();\n } else if (pluginSpecificApi?.[originalKey]) {\n resolvedHotkey.handler = () => pluginSpecificApi[originalKey]();\n }\n }\n\n // Set shortcut priority, falling back to plugin priority\n resolvedHotkey.priority = resolvedHotkey.priority ?? plugin.priority;\n\n (\n editor.meta.shortcuts as Record<\n string,\n SlatePlugin['shortcuts'][string]\n >\n )[namespacedKey] = resolvedHotkey;\n }\n });\n });\n};\n\nconst flattenAndResolvePlugins = (\n editor: SlateEditor,\n plugins: SlatePlugins\n): Map<string, SlatePlugin> => {\n const pluginMap = new Map<string, SlatePlugin>();\n\n const processPlugin = (plugin: SlatePlugin) => {\n const resolvedPlugin = resolvePlugin(editor, plugin);\n\n if (resolvedPlugin.key) {\n const existingPlugin = pluginMap.get(resolvedPlugin.key);\n\n if (existingPlugin) {\n pluginMap.set(\n resolvedPlugin.key,\n mergePlugins(existingPlugin, resolvedPlugin)\n );\n } else {\n pluginMap.set(resolvedPlugin.key, resolvedPlugin);\n }\n } else {\n // If the plugin has no key, we just just skip it.\n }\n\n if (resolvedPlugin.plugins && resolvedPlugin.plugins.length > 0) {\n resolvedPlugin.plugins.forEach(processPlugin);\n }\n };\n\n plugins.forEach(processPlugin);\n\n return pluginMap;\n};\n\nexport const resolveAndSortPlugins = (\n editor: SlateEditor,\n plugins: SlatePlugins\n): SlatePlugins => {\n // Step 1: Resolve, flatten, and merge all plugins\n const pluginMap = flattenAndResolvePlugins(editor, plugins);\n\n // Step 2: Filter out disabled plugins\n const enabledPlugins = Array.from(pluginMap.values()).filter(\n (plugin) => plugin.enabled !== false\n );\n\n // Step 3: Sort plugins by priority\n enabledPlugins.sort((a, b) => b.priority - a.priority);\n\n // Step 4: Reorder based on dependencies\n const orderedPlugins: SlatePlugins = [];\n const visited = new Set<string>();\n\n const visit = (plugin: SlatePlugin) => {\n if (visited.has(plugin.key)) return;\n\n visited.add(plugin.key);\n\n plugin.dependencies?.forEach((depKey) => {\n const depPlugin = pluginMap.get(depKey);\n\n if (depPlugin) {\n visit(depPlugin);\n } else {\n editor.api.debug.warn(\n `Plugin \"${plugin.key}\" depends on missing plugin \"${depKey}\"`,\n 'PLUGIN_DEPENDENCY_MISSING'\n );\n }\n });\n\n orderedPlugins.push(plugin);\n };\n\n enabledPlugins.forEach(visit);\n\n return orderedPlugins;\n};\n\nexport const applyPluginsToEditor = (\n editor: SlateEditor,\n plugins: SlatePlugins\n) => {\n editor.meta.pluginList = plugins;\n editor.plugins = Object.fromEntries(\n plugins.map((plugin) => [plugin.key, plugin])\n );\n};\n\nexport const resolvePluginOverrides = (editor: SlateEditor) => {\n const applyOverrides = (plugins: SlatePlugin[]): SlatePlugin[] => {\n let overriddenPlugins = [...plugins];\n\n const enabledOverrides: Record<string, boolean> = {};\n const componentOverrides: Record<\n string,\n { component: any; priority: number }\n > = {};\n const pluginOverrides: Record<string, Partial<SlatePlugin>> = {};\n\n // Collect all overrides\n for (const plugin of plugins) {\n if (plugin.override.enabled) {\n Object.assign(enabledOverrides, plugin.override.enabled);\n }\n // TODO react\n if ((plugin.override as any).components) {\n Object.entries((plugin.override as any).components).forEach(\n ([key, component]) => {\n if (\n !componentOverrides[key] ||\n plugin.priority > componentOverrides[key].priority\n ) {\n componentOverrides[key] = {\n component,\n priority: plugin.priority,\n };\n }\n }\n );\n }\n if (plugin.override.plugins) {\n Object.entries(plugin.override.plugins).forEach(([key, value]) => {\n pluginOverrides[key] = mergePlugins(pluginOverrides[key], value);\n\n if (value.enabled !== undefined) {\n enabledOverrides[key] = value.enabled;\n }\n });\n }\n }\n\n // Apply overrides\n overriddenPlugins = overriddenPlugins.map((p) => {\n let updatedPlugin = { ...p };\n\n // Apply plugin overrides\n if (pluginOverrides[p.key]) {\n updatedPlugin = mergePlugins(updatedPlugin, pluginOverrides[p.key]);\n }\n // Apply component overrides\n // TODO react\n if (\n componentOverrides[p.key] &&\n ((!(p as any).render.node && !(p as any).node.component) ||\n componentOverrides[p.key].priority > p.priority)\n ) {\n (updatedPlugin as any).render.node =\n componentOverrides[p.key].component;\n (updatedPlugin as any).node.component =\n componentOverrides[p.key].component;\n }\n\n // Apply enabled overrides\n const enabled = enabledOverrides[p.key] ?? updatedPlugin.enabled;\n\n if (isDefined(enabled)) {\n updatedPlugin.enabled = enabled;\n }\n\n return updatedPlugin;\n });\n\n return overriddenPlugins\n .filter((p) => p.enabled !== false)\n .map((plugin) => ({\n ...plugin,\n plugins: applyOverrides(plugin.plugins || []),\n }));\n };\n\n editor.meta.pluginList = applyOverrides(editor.meta.pluginList as any);\n editor.plugins = Object.fromEntries(\n editor.meta.pluginList.map((plugin) => [plugin.key, plugin])\n );\n};\n","import { createSlatePlugin } from '../plugin';\n\n/**\n * Enables support for deserializing inserted content from Slate Ast format to\n * Slate format while apply a small bug fix.\n */\nexport const AstPlugin = createSlatePlugin({\n key: 'ast',\n parser: {\n format: 'application/x-slate-fragment',\n deserialize: ({ data }) => {\n const decoded = decodeURIComponent(window.atob(data));\n let parsed: any;\n\n try {\n parsed = JSON.parse(decoded);\n } catch {\n /* empty */\n }\n\n return parsed;\n },\n },\n});\n","import { withHistory } from '@platejs/slate';\n\nimport type { SlateEditor } from '../editor';\n\nimport { type ExtendEditor, createSlatePlugin } from '../plugin';\n\nexport const withPlateHistory: ExtendEditor = ({ editor }) =>\n withHistory(editor as any) as any as SlateEditor;\n\n/** @see {@link withHistory} */\nexport const HistoryPlugin = createSlatePlugin({\n key: 'history',\n extendEditor: withPlateHistory,\n});\n","import { type PluginConfig, createSlatePlugin } from '../../plugin';\n\nexport type ParagraphConfig = PluginConfig<'p'>;\n\nexport const BaseParagraphPlugin = createSlatePlugin({\n key: 'p',\n node: {\n isElement: true,\n },\n parsers: {\n html: {\n deserializer: {\n rules: [\n {\n validNodeName: 'P',\n },\n ],\n query: ({ element }) => element.style.fontFamily !== 'Consolas',\n },\n },\n },\n rules: {\n merge: { removeEmpty: true },\n },\n});\n","import { PathApi } from '@platejs/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { BreakRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withBreakRules: OverrideEditor = (ctx) => {\n const {\n editor,\n tf: { insertBreak },\n } = ctx;\n const checkMatchRulesOverride = (\n rule: string,\n blockNode: any,\n blockPath: any\n ): BreakRules | null => {\n const matchRulesKeys = editor.meta.pluginCache.rules.match;\n for (const key of matchRulesKeys) {\n const overridePlugin = editor.getPlugin({ key });\n if (\n overridePlugin.rules?.break &&\n overridePlugin.rules?.match?.({\n ...ctx,\n node: blockNode,\n path: blockPath,\n rule: rule as any,\n })\n ) {\n return overridePlugin.rules.break;\n }\n }\n return null;\n };\n\n const executeBreakAction = (\n action: string | undefined,\n blockPath: any\n ): boolean => {\n if (action === 'reset') {\n editor.tf.resetBlock({ at: blockPath });\n return true;\n }\n if (action === 'exit') {\n editor.tf.insertExitBreak();\n return true;\n }\n if (action === 'deleteExit') {\n editor.tf.deleteBackward('character');\n editor.tf.insertExitBreak();\n return true;\n }\n if (action === 'lineBreak') {\n editor.tf.insertSoftBreak();\n return true;\n }\n return false;\n };\n\n return {\n transforms: {\n insertBreak() {\n if (editor.selection && editor.api.isCollapsed()) {\n const block = editor.api.block();\n if (block) {\n const [blockNode, blockPath] = block;\n const plugin = getPluginByType(editor, blockNode.type);\n\n const breakRules = plugin?.rules.break;\n\n // Handle 'empty' scenario\n if (\n editor.api.isEmpty(editor.selection, {\n block: true,\n })\n ) {\n const overrideBreakRules = checkMatchRulesOverride(\n 'break.empty',\n blockNode,\n blockPath\n );\n const effectiveBreakRules = overrideBreakRules || breakRules;\n const emptyAction = effectiveBreakRules?.empty;\n\n if (executeBreakAction(emptyAction, blockPath)) return;\n // if 'default', fall through to breakRules.default or standard behavior\n }\n\n // Handle 'emptyLineEnd' scenario\n if (\n !editor.api.isEmpty(editor.selection, {\n block: true,\n }) &&\n editor.api.isAt({ end: true })\n ) {\n const range = editor.api.range('before', editor.selection!);\n if (range) {\n const char = editor.api.string(range);\n if (char === '\\n') {\n const overrideBreakRules = checkMatchRulesOverride(\n 'break.emptyLineEnd',\n blockNode,\n blockPath\n );\n const effectiveBreakRules = overrideBreakRules || breakRules;\n const emptyLineEndAction = effectiveBreakRules?.emptyLineEnd;\n\n if (executeBreakAction(emptyLineEndAction, blockPath)) return;\n }\n }\n }\n\n // Handle 'default' scenario (or fallthrough from 'empty: default' or 'emptyLineEnd: default')\n const overrideDefaultBreakRules = checkMatchRulesOverride(\n 'break.default',\n blockNode,\n blockPath\n );\n const defaultAction = (overrideDefaultBreakRules || breakRules)\n ?.default;\n\n if (executeBreakAction(defaultAction, blockPath)) return;\n\n const overrideSplitResetBreakRules = checkMatchRulesOverride(\n 'break.splitReset',\n blockNode,\n blockPath\n );\n const splitReset =\n overrideSplitResetBreakRules?.splitReset ??\n breakRules?.splitReset;\n\n if (splitReset) {\n const isAtStart = editor.api.isAt({ start: true });\n\n insertBreak();\n\n editor.tf.resetBlock({\n at: isAtStart ? blockPath : PathApi.next(blockPath),\n });\n return;\n }\n }\n }\n\n // Standard Slate insertBreak if no custom breakRules handled it\n insertBreak();\n },\n },\n };\n};\n","import { PointApi, RangeApi } from '@platejs/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { DeleteRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withDeleteRules: OverrideEditor = (ctx) => {\n const {\n editor,\n tf: { deleteBackward, deleteForward, deleteFragment },\n } = ctx;\n\n const resetMarks = () => {\n if (editor.api.isAt({ start: true })) {\n editor.tf.removeMarks();\n }\n };\n\n const checkMatchRulesOverride = (\n rule: string,\n blockNode: any,\n blockPath: any\n ): DeleteRules | null => {\n const matchRulesKeys = editor.meta.pluginCache.rules.match;\n for (const key of matchRulesKeys) {\n const overridePlugin = editor.getPlugin({ key });\n if (\n overridePlugin.rules?.delete &&\n overridePlugin.rules?.match?.({\n ...ctx,\n node: blockNode,\n path: blockPath,\n rule: rule as any,\n })\n ) {\n return overridePlugin.rules.delete;\n }\n }\n return null;\n };\n\n const executeDeleteAction = (\n action: string | undefined,\n blockPath: any\n ): boolean => {\n if (action === 'reset') {\n editor.tf.resetBlock({ at: blockPath });\n return true;\n }\n return false;\n };\n\n return {\n transforms: {\n deleteBackward(unit) {\n if (editor.selection && editor.api.isCollapsed()) {\n const block = editor.api.block();\n if (block) {\n const [blockNode, blockPath] = block;\n const plugin = getPluginByType(editor, blockNode.type);\n\n const deleteRules = plugin?.rules.delete;\n\n // Handle 'start' scenario\n if (editor.api.isAt({ start: true })) {\n const overrideDeleteRules = checkMatchRulesOverride(\n 'delete.start',\n blockNode,\n blockPath\n );\n const effectiveDeleteRules = overrideDeleteRules || deleteRules;\n const startAction = effectiveDeleteRules?.start;\n\n if (executeDeleteAction(startAction, blockPath)) {\n return;\n }\n }\n\n // Handle 'empty' scenario\n if (editor.api.isEmpty(editor.selection, { block: true })) {\n const overrideDeleteRules = checkMatchRulesOverride(\n 'delete.empty',\n blockNode,\n blockPath\n );\n const effectiveDeleteRules = overrideDeleteRules || deleteRules;\n const emptyAction = effectiveDeleteRules?.empty;\n\n if (executeDeleteAction(emptyAction, blockPath)) return;\n }\n }\n\n // Default behavior: reset first block when deleting at start of the document\n if (\n PointApi.equals(editor.selection!.anchor, editor.api.start([])!)\n ) {\n editor.tf.resetBlock({ at: [0] });\n return;\n }\n }\n\n deleteBackward(unit);\n resetMarks();\n },\n deleteForward(unit) {\n deleteForward(unit);\n resetMarks();\n },\n deleteFragment(options) {\n // Default behavior: reset entire editor when deleting full selection\n if (\n editor.selection &&\n RangeApi.equals(editor.selection, editor.api.range([])!)\n ) {\n editor.tf.reset({\n children: true,\n select: true,\n });\n return;\n }\n\n deleteFragment(options);\n resetMarks();\n },\n },\n };\n};\n","import {\n type Path,\n type TElement,\n ElementApi,\n PathApi,\n TextApi,\n} from '@platejs/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { MergeRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withMergeRules: OverrideEditor = (ctx) => {\n const {\n editor,\n tf: { removeNodes },\n } = ctx;\n\n const checkMatchRulesOverride = (\n rule: string,\n blockNode: any,\n blockPath: any\n ): MergeRules | null => {\n const matchRulesKeys = editor.meta.pluginCache.rules.match;\n for (const key of matchRulesKeys) {\n const overridePlugin = editor.getPlugin({ key });\n if (\n overridePlugin.rules.merge &&\n overridePlugin.rules?.match?.({\n ...ctx,\n node: blockNode,\n path: blockPath,\n rule: rule as any,\n })\n ) {\n return overridePlugin.rules.merge;\n }\n }\n return null;\n };\n\n return {\n api: {\n shouldMergeNodes(prevNodeEntry, nextNodeEntry, { reverse } = {}) {\n const [prevNode, prevPath] = prevNodeEntry;\n const [, nextPath] = nextNodeEntry;\n const [curNode, curPath] = reverse ? prevNodeEntry : nextNodeEntry;\n const [targetNode, targetPath] = reverse\n ? nextNodeEntry\n : prevNodeEntry;\n\n if (\n TextApi.isText(prevNode) &&\n prevNode.text === '' &&\n prevPath.at(-1) !== 0\n ) {\n editor.tf.removeNodes({ at: prevPath });\n return false;\n }\n\n const shouldRemove = (node: TElement, path: Path) => {\n // Override Slate's default: typically only pure text blocks like paragraph and heading nodes want this to be true, so plugin default is false.\n const plugin = getPluginByType(editor, node.type);\n if (!plugin) {\n return true;\n }\n\n const mergeRules = plugin.rules.merge;\n if (!mergeRules?.removeEmpty) {\n return false;\n }\n\n // Check if any plugin with matchRules overrides the merge behavior\n const overrideMergeRules = checkMatchRulesOverride(\n 'merge.removeEmpty',\n node,\n path\n );\n\n if (overrideMergeRules?.removeEmpty === false) {\n return false;\n }\n\n return true;\n };\n\n // Don't delete target void blocks by default\n if (ElementApi.isElement(targetNode) && editor.api.isVoid(targetNode)) {\n // Remove if plugin allows it\n if (shouldRemove(targetNode, targetPath)) {\n editor.tf.removeNodes({ at: prevPath });\n }\n // Remove current node if empty before selecting the void block\n else if (\n ElementApi.isElement(curNode) &&\n editor.api.isEmpty(curNode)\n ) {\n editor.tf.removeNodes({ at: curPath });\n }\n return false;\n }\n\n // Not void, remove prevNode if sibling and empty\n if (\n ElementApi.isElement(prevNode) &&\n editor.api.isEmpty(prevNode) &&\n PathApi.isSibling(prevPath, nextPath) &&\n shouldRemove(prevNode, prevPath)\n ) {\n editor.tf.removeNodes({ at: prevPath });\n return false;\n }\n\n return true;\n },\n },\n transforms: {\n removeNodes(options = {}) {\n if (options.event?.type === 'mergeNodes' && options.at) {\n const nodeEntry = editor.api.node(options.at);\n if (nodeEntry) {\n const [node, path] = nodeEntry;\n\n if (ElementApi.isElement(node)) {\n // Check if this node should be removed based on merge rules\n const plugin = getPluginByType(editor, node.type);\n if (plugin) {\n const mergeRules = plugin.rules.merge;\n\n // Check for override rules\n const overrideMergeRules = checkMatchRulesOverride(\n 'merge.removeEmpty',\n node,\n path\n );\n\n const shouldNotRemove =\n overrideMergeRules?.removeEmpty === false ||\n mergeRules?.removeEmpty === false;\n\n if (shouldNotRemove) {\n // Don't remove the node, just return without calling removeNodes\n return;\n }\n }\n }\n }\n }\n\n removeNodes(options);\n },\n },\n };\n};\n","import { ElementApi } from '@platejs/slate';\n\nimport type { NormalizeRules } from '../../plugin/BasePlugin';\nimport type { OverrideEditor } from '../../plugin/SlatePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withNormalizeRules: OverrideEditor = (ctx) => {\n const {\n editor,\n tf: { normalizeNode },\n } = ctx;\n\n const checkMatchRulesOverride = (\n rule: string,\n node: any,\n path: any\n ): NormalizeRules | null => {\n const matchRulesKeys = editor.meta.pluginCache.rules.match;\n for (const key of matchRulesKeys) {\n const overridePlugin = editor.getPlugin({ key });\n if (\n overridePlugin.rules?.normalize &&\n overridePlugin.rules?.match?.({\n ...ctx,\n node,\n path,\n rule: rule as any,\n })\n ) {\n return overridePlugin.rules.normalize;\n }\n }\n return null;\n };\n\n return {\n transforms: {\n normalizeNode([node, path]) {\n if (ElementApi.isElement(node) && node.type) {\n const plugin = getPluginByType(editor, node.type);\n const normalizeRules = plugin?.rules.normalize;\n\n // Handle 'removeEmpty' scenario\n const overridenormalizeRules = checkMatchRulesOverride(\n 'normalize.removeEmpty',\n node,\n path\n );\n const effectivenormalizeRules =\n overridenormalizeRules || normalizeRules;\n\n if (\n effectivenormalizeRules?.removeEmpty &&\n editor.api.isEmpty(node)\n ) {\n editor.tf.removeNodes({ at: path });\n return;\n }\n }\n\n normalizeNode([node, path]);\n },\n },\n };\n};\n","import { type OverrideEditor, getPluginByType } from '../../plugin';\nimport { createSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { BaseParagraphPlugin } from '../paragraph';\nimport { withBreakRules } from './withBreakRules';\nimport { withDeleteRules } from './withDeleteRules';\nimport { withMergeRules } from './withMergeRules';\nimport { withNormalizeRules } from './withNormalizeRules';\n\n/**\n * Merge and register all the inline types and void types from the plugins and\n * options, using `editor.api.isInline`, `editor.api.markableVoid` and\n * `editor.api.isVoid`\n */\nexport const withOverrides: OverrideEditor = ({\n api: { isInline, isSelectable, isVoid, markableVoid },\n editor,\n}) => {\n // Use pre-computed arrays from plugin resolution\n return {\n api: {\n create: {\n block: (node) => ({\n children: [{ text: '' }],\n type: editor.getType(BaseParagraphPlugin.key),\n ...node,\n }),\n },\n isInline(element) {\n return getPluginByType(editor, element.type as string)?.node.isInline\n ? true\n : isInline(element);\n },\n isSelectable(element) {\n return getPluginByType(editor, element.type as string)?.node\n .isSelectable === false\n ? false\n : isSelectable(element);\n },\n isVoid(element) {\n return getPluginByType(editor, element.type as string)?.node.isVoid\n ? true\n : isVoid(element);\n },\n markableVoid(element) {\n return getPluginByType(editor, element.type as string)?.node\n .isMarkableVoid\n ? true\n : markableVoid(element);\n },\n },\n };\n};\n\n/** Override the editor api and transforms based on the plugins. */\nexport const OverridePlugin = createSlatePlugin({\n key: 'override',\n})\n .overrideEditor(withOverrides)\n .overrideEditor(withBreakRules)\n .overrideEditor(withDeleteRules)\n .overrideEditor(withMergeRules)\n .overrideEditor(withNormalizeRules);\n","import type { Descendant } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe preInsert then insertFragment. */\nexport const pipeInsertFragment = (\n editor: SlateEditor,\n injectedPlugins: Partial<AnyEditorPlugin>[],\n { fragment, ...options }: ParserOptions & { fragment: Descendant[] }\n) => {\n editor.tf.withoutNormalizing(() => {\n injectedPlugins.some(\n (p) =>\n p.parser?.preInsert?.({\n ...getEditorPlugin(editor, p as any),\n fragment,\n ...options,\n }) === true\n );\n\n editor.tf.insertFragment(fragment);\n });\n};\n","import type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe editor.tf.insertData.transformData */\nexport const pipeTransformData = (\n editor: SlateEditor,\n plugins: Partial<AnyEditorPlugin>[],\n { data, ...options }: ParserOptions\n) => {\n plugins.forEach((p) => {\n const transformData = p.parser?.transformData;\n\n if (!transformData) return;\n\n data = transformData({\n ...getEditorPlugin(editor, p as any),\n data,\n ...options,\n });\n });\n\n return data;\n};\n","import type { Descendant } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe editor.tf.insertData.transformFragment */\nexport const pipeTransformFragment = (\n editor: SlateEditor,\n plugins: Partial<AnyEditorPlugin>[],\n { fragment, ...options }: ParserOptions & { fragment: Descendant[] }\n) => {\n plugins.forEach((p) => {\n const transformFragment = p.parser?.transformFragment;\n\n if (!transformFragment) return;\n\n fragment = transformFragment({\n fragment,\n ...options,\n ...getEditorPlugin(editor, p as any),\n });\n });\n\n return fragment;\n};\n","import {\n type NodeEntry,\n type NodeOf,\n type Path,\n type QueryNodeOptions,\n type TNode,\n NodeApi,\n queryNode,\n} from '@platejs/slate';\n\nexport type ApplyDeepToNodesOptions<N extends TNode> = {\n // Function to call on each node following the query.\n apply: (\n node: NodeOf<N>,\n source: (() => Record<string, any>) | Record<string, any>\n ) => void;\n // The destination node object.\n node: N;\n // The source object. Can be a factory.\n source: (() => Record<string, any>) | Record<string, any>;\n path?: Path;\n // Query to filter the nodes.\n query?: QueryNodeOptions;\n};\n\n/** Recursively apply an operation to children nodes with a query. */\nexport const applyDeepToNodes = <N extends TNode>({\n apply,\n node,\n path = [],\n query,\n source,\n}: ApplyDeepToNodesOptions<N>) => {\n const entry: NodeEntry<N> = [node, path];\n\n if (queryNode<N>(entry, query)) {\n if (typeof source === 'function') {\n apply(node, source());\n } else {\n apply(node, source);\n }\n }\n if (!NodeApi.isAncestor(node)) return;\n\n node.children.forEach((child, index) => {\n applyDeepToNodes({\n apply,\n node: child as any,\n path: path.concat([index]),\n query,\n source,\n });\n });\n};\n","export const isSlateVoid = (element: HTMLElement) =>\n element.dataset.slateVoid === 'true';\n\nexport const isSlateElement = (element: HTMLElement) =>\n element.dataset.slateNode === 'element';\n\nexport const isSlateText = (element: HTMLElement) =>\n element.dataset.slateNode === 'text';\n\nexport const isSlateString = (element: HTMLElement) =>\n element.dataset.slateString === 'true';\n\nexport const isSlateLeaf = (element: HTMLElement) =>\n element.dataset.slateLeaf === 'true';\n\nexport const isSlateEditor = (element: HTMLElement) =>\n element.dataset.slateEditor === 'true';\n\nexport const isSlateNode = (element: HTMLElement) =>\n isSlateLeaf(element) ||\n isSlateElement(element) ||\n isSlateVoid(element) ||\n isSlateString(element) ||\n isSlateText(element);\n\nexport const isSlatePluginElement = (element: HTMLElement, pluginKey: string) =>\n element.dataset.slateNode === 'element' &&\n element.classList.contains(`slate-${pluginKey}`);\n\nexport const isSlatePluginNode = (element: HTMLElement, pluginKey: string) =>\n element.classList.contains(`slate-${pluginKey}`);\n\nexport const getSlateElements = (element: HTMLElement): HTMLElement[] =>\n Array.from(element.querySelectorAll('[data-slate-node=\"element\"]'));\n","import type { TNode } from '@platejs/slate';\n\nimport defaults from 'lodash/defaults.js';\n\nimport {\n type ApplyDeepToNodesOptions,\n applyDeepToNodes,\n} from './applyDeepToNodes';\n\n/** Recursively merge a source object to children nodes with a query. */\nexport const defaultsDeepToNodes = <N extends TNode>(\n options: Omit<ApplyDeepToNodesOptions<N>, 'apply'>\n) => {\n applyDeepToNodes({ ...options, apply: defaults });\n};\n","import { type Path, type TNode, ElementApi } from '@platejs/slate';\n\nimport type { SlateEditor } from '../editor';\n\nimport { type EditorPlugin, getPluginKey, getPluginKeys } from '../plugin';\n\nexport const getInjectMatch = <E extends SlateEditor>(\n editor: E,\n plugin: EditorPlugin\n) => {\n return (node: TNode, path: Path) => {\n const {\n inject: {\n excludeBelowPlugins,\n excludePlugins,\n isBlock: _isBlock,\n isElement: _isElement,\n isLeaf,\n maxLevel,\n targetPlugins,\n },\n } = plugin;\n\n const element = ElementApi.isElement(node) ? node : undefined;\n\n if (_isElement && !element) return false;\n if (_isBlock && (!element || !editor.api.isBlock(element))) return false;\n if (isLeaf && element) return false;\n if (element?.type) {\n // Exclude plugins\n if (excludePlugins?.includes(getPluginKey(editor, element.type)!)) {\n return false;\n }\n // Target plugins\n if (\n targetPlugins &&\n !targetPlugins.includes(getPluginKey(editor, element.type)!)\n ) {\n return false;\n }\n }\n // Exclude below plugins\n if (excludeBelowPlugins || maxLevel) {\n if (maxLevel && path.length > maxLevel) {\n return false;\n }\n if (excludeBelowPlugins) {\n const excludeTypes = getPluginKeys(editor, excludeBelowPlugins);\n const isBelow = editor.api.above({\n at: path,\n match: (n) =>\n ElementApi.isElement(n) && excludeTypes.includes(n.type),\n });\n\n if (isBelow) return false;\n }\n }\n\n return true;\n };\n};\n","import type { SlateEditor } from '../editor';\nimport type { AnyEditorPlugin, SlatePlugins } from '../plugin/SlatePlugin';\n\n/**\n * Get all plugins having a defined `inject.plugins[plugin.key]`. It includes\n * `plugin` itself.\n */\nexport const getInjectedPlugins = (\n editor: SlateEditor,\n plugin: AnyEditorPlugin\n): Partial<AnyEditorPlugin>[] => {\n const injectedPlugins: SlatePlugins = [];\n\n [...editor.meta.pluginList].reverse().forEach((p) => {\n const injectedPlugin = p.inject.plugins?.[plugin.key];\n\n if (injectedPlugin) injectedPlugins.push(injectedPlugin as any);\n });\n\n return [plugin, ...injectedPlugins];\n};\n","import { type TElement, type TText, TextApi } from '@platejs/slate';\nimport kebabCase from 'lodash/kebabCase.js';\n\nexport const getNodeDataAttributeKeys = (node: TElement | TText) =>\n Object.keys(node)\n .filter(\n (key) =>\n typeof node[key] !== 'object' &&\n (!TextApi.isText(node) || key !== 'text')\n )\n .map((key) => keyToDataAttribute(key));\n\nexport const keyToDataAttribute = (key: string) =>\n `data-slate-${kebabCase(key)}`;\n","import type { TElement, TText } from '@platejs/slate';\nimport type { AnyObject } from '@udecode/utils';\n\nimport pick from 'lodash/pick.js';\n\nimport type { SlateRenderNodeProps } from '../../static/types';\nimport type { AnyEditorPlugin } from '../plugin';\n\nimport { getNodeDataAttributeKeys } from './getNodeDataAttributeKeys';\n\nexport const getPluginNodeProps = ({\n attributes: nodeAttributes,\n node,\n plugin,\n props,\n}: {\n props: SlateRenderNodeProps;\n attributes?: AnyObject;\n node?: TElement | TText;\n plugin?: AnyEditorPlugin;\n}): any => {\n const newProps: any = { ...props, attributes: { ...props.attributes } };\n\n if (plugin?.node.props) {\n const pluginNodeProps =\n (typeof plugin.node.props === 'function'\n ? plugin.node.props(newProps as any)\n : plugin.node.props) ?? {};\n\n newProps.attributes = {\n ...newProps.attributes,\n ...pluginNodeProps,\n };\n }\n if (nodeAttributes && plugin) {\n // Add data attributes to attributes if attributes is already set\n newProps.attributes = {\n ...newProps.attributes,\n ...pick(\n nodeAttributes,\n /**\n * WARNING: Improper use of `dangerouslyAllowAttributes` WILL make your\n * application vulnerable to cross-site scripting (XSS) or information\n * exposure attacks.\n *\n * @see {@link BasePluginNode.dangerouslyAllowAttributes}\n */\n ...(plugin.node.dangerouslyAllowAttributes ?? []),\n [...(node ? getNodeDataAttributeKeys(node) : [])]\n ),\n };\n }\n\n // remove attributes values that are undefined\n Object.keys(newProps.attributes).forEach((key) => {\n if (newProps.attributes?.[key] === undefined) {\n delete newProps.attributes?.[key];\n }\n });\n\n return newProps;\n};\n","/** Get slate class name: slate-<type> */\nexport const getSlateClass = (type?: string) => (type ? `slate-${type}` : '');\n","import type { TNode } from '@platejs/slate';\n\nimport merge from 'lodash/merge.js';\n\nimport {\n type ApplyDeepToNodesOptions,\n applyDeepToNodes,\n} from './applyDeepToNodes';\n\n/** Recursively merge a source object to children nodes with a query. */\nexport const mergeDeepToNodes = <N extends TNode>(\n options: Omit<ApplyDeepToNodesOptions<N>, 'apply'>\n) => {\n applyDeepToNodes({ ...options, apply: merge });\n};\n","import {\n type TElement,\n type TText,\n ElementApi,\n NodeApi,\n PathApi,\n} from '@platejs/slate';\nimport { type NodeEntry, Path } from 'slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nimport { getPluginByType } from '../../../plugin/getSlatePlugin';\n\n/**\n * When the cursor is at a mark edge, this function returns the inward node and\n * the outward node (if any). If the cursor is at the start of the text, then\n * the node before the text is returned. If the cursor is at the end of the\n * text, then the node after the text is returned. Otherwise, null is returned.\n */\nexport const getEdgeNodes = (editor: SlateEditor): EdgeNodes | null => {\n if (!editor.api.isCollapsed()) return null;\n\n const cursor = editor.selection!.anchor;\n\n const textRange = editor.api.range(cursor.path);\n\n if (!textRange) return null;\n\n const edge = editor.api.isStart(cursor, textRange)\n ? 'start'\n : editor.api.isEnd(cursor, textRange)\n ? 'end'\n : null;\n\n if (!edge) return null;\n\n const parent: TElement | null = (NodeApi.parent(editor, cursor.path) ??\n null) as TElement | null;\n\n /** Inline elements */\n\n const isAffinityInlineElement = (() => {\n if (!parent || !ElementApi.isElement(parent)) return false;\n\n const parentAffinity = getPluginByType(editor, parent.type)?.rules.selection\n ?.affinity;\n\n return parentAffinity === 'hard' || parentAffinity === 'directional';\n })();\n\n const nodeEntry: NodeEntry<TElement | TText> = isAffinityInlineElement\n ? [parent!, PathApi.parent(cursor.path)]\n : [NodeApi.get(editor, cursor.path)!, cursor.path];\n\n if (\n edge === 'start' &&\n cursor.path.at(-1) === 0 &&\n !isAffinityInlineElement\n ) {\n return [null, nodeEntry];\n }\n\n const siblingPath =\n edge === 'end' ? Path.next(nodeEntry[1]) : Path.previous(nodeEntry[1]);\n const siblingNode = NodeApi.get<TText>(editor, siblingPath);\n\n const siblingEntry: NodeEntry<TText> | null = siblingNode\n ? [siblingNode, siblingPath]\n : null;\n\n return edge === 'end' ? [nodeEntry, siblingEntry] : [siblingEntry, nodeEntry];\n};\n","import type { TElement, TText } from '@platejs/slate';\n\nimport { IS_FIREFOX, NodeApi } from '@platejs/slate';\nimport isEqual from 'lodash/isEqual.js';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nexport const getMarkBoundaryAffinity = (\n editor: SlateEditor,\n markBoundary: EdgeNodes\n): 'backward' | 'forward' | undefined => {\n const { marks, selection } = editor;\n if (!selection) return;\n\n const marksMatchLeaf = (leaf: TElement | TText) =>\n marks &&\n isEqual(NodeApi.extractProps(leaf), marks) &&\n Object.keys(marks).length > 1;\n\n const [backwardLeafEntry, forwardLeafEntry] = markBoundary;\n\n if (!backwardLeafEntry || !forwardLeafEntry) {\n const leafEntry = backwardLeafEntry || forwardLeafEntry;\n const affinityIsTowardsLeaf = !marks || marksMatchLeaf(leafEntry[0]);\n\n if (affinityIsTowardsLeaf) {\n return leafEntry === backwardLeafEntry ? 'backward' : 'forward';\n }\n return;\n }\n\n const marksDirection: 'backward' | 'forward' | null =\n marks &&\n (() => {\n if (backwardLeafEntry && marksMatchLeaf(backwardLeafEntry[0]))\n return 'backward';\n if (forwardLeafEntry && marksMatchLeaf(forwardLeafEntry[0]))\n return 'forward';\n return null;\n })();\n\n const selectionDirection =\n selection.anchor.offset === 0 ? 'forward' : 'backward';\n\n if (selectionDirection === 'backward' && marksDirection === 'forward')\n return 'forward';\n\n if (\n IS_FIREFOX &&\n selectionDirection === 'forward' &&\n marksDirection !== 'backward'\n )\n return 'forward';\n\n return 'backward';\n};\n","import { type TElement, type TText, ElementApi, NodeApi } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nimport { getPluginByType } from '../../../plugin/getSlatePlugin';\n\nexport const isNodeAffinity = (\n editor: SlateEditor,\n node: TElement | TText,\n affinity: 'directional' | 'hard' | 'outward'\n) => {\n const marks = Object.keys(NodeApi.extractProps(node));\n const keys = ElementApi.isElement(node) ? [node.type] : marks;\n return keys.some(\n (type) =>\n getPluginByType(editor, type)?.rules.selection?.affinity === affinity\n );\n};\n\nexport const isNodesAffinity = (\n editor: SlateEditor,\n edgeNodes: EdgeNodes,\n affinity: 'directional' | 'hard' | 'outward'\n) => {\n const [backwardLeafEntry, forwardLeafEntry] = edgeNodes;\n\n return (\n (backwardLeafEntry &&\n isNodeAffinity(editor, backwardLeafEntry[0], affinity)) ||\n (forwardLeafEntry && isNodeAffinity(editor, forwardLeafEntry[0], affinity))\n );\n};\n","import type { Point } from 'slate';\n\nimport { ElementApi, NodeApi } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nexport const setAffinitySelection = (\n editor: SlateEditor,\n edgeNodes: EdgeNodes,\n affinity: 'backward' | 'forward'\n) => {\n const setMarks = (marks: typeof editor.marks) => {\n editor.marks = marks;\n editor.api.onChange();\n };\n\n const select = (point: Point) => {\n editor.tf.setSelection({ anchor: point, focus: point });\n };\n\n const [before, after] = edgeNodes;\n\n if (affinity === 'backward') {\n if (before === null) {\n setMarks({});\n return;\n }\n\n const beforeEnd = editor.api.end(before[1]);\n if (beforeEnd) {\n select(beforeEnd);\n }\n\n if (ElementApi.isElement(before[0])) return;\n setMarks(null);\n\n return;\n }\n\n if (before === null) {\n setMarks(null);\n return;\n }\n\n if (after === null) {\n setMarks({});\n return;\n }\n\n const beforeEnd = editor.api.end(before[1])!;\n select(beforeEnd);\n\n if (ElementApi.isElement(after[0])) {\n return;\n }\n setMarks(NodeApi.extractProps(after[0]));\n};\n","import {\n type Path,\n type TText,\n ElementApi,\n NodeApi,\n TextApi,\n} from '@platejs/slate';\n\nimport type { PluginConfig } from '../../plugin/BasePlugin';\nimport type { EdgeNodes } from './types';\n\nimport { createTSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\nimport { getEdgeNodes } from './queries';\nimport { getMarkBoundaryAffinity } from './queries/getMarkBoundaryAffinity';\nimport { isNodesAffinity } from './queries/isNodeAffinity';\nimport { setAffinitySelection } from './transforms/setAffinitySelection';\n\nexport type ElementAffinity = {\n affinity: 'backward' | 'forward';\n at: Path;\n type: string;\n};\n\nexport type AffinityConfig = PluginConfig<'affinity'>;\n\n// REVIEW: performance\nexport const AffinityPlugin = createTSlatePlugin<AffinityConfig>({\n key: 'affinity',\n}).overrideEditor(({ editor, tf: { deleteBackward, insertText, move } }) => ({\n transforms: {\n /**\n * On backspace, if the deletion results in the cursor being at a mark\n * boundary, then the affinity should be forward. If the deletion removes a\n * character from the left mark, then the affinity should be backward.\n */\n deleteBackward: (unit) => {\n const apply = () => {\n if (unit === 'character' && editor.api.isCollapsed()) {\n const [start] = getEdgeNodes(editor) ?? [null];\n\n const startText =\n start &&\n (TextApi.isText(start[0])\n ? start[0].text\n : NodeApi.string(start[0]));\n\n deleteBackward(unit);\n\n const edgeNodes = getEdgeNodes(editor);\n\n if (\n edgeNodes &&\n isNodesAffinity(editor, edgeNodes, 'directional') &&\n !hasElement(edgeNodes)\n ) {\n const affinity =\n startText && startText.length > 1 ? 'backward' : 'forward';\n setAffinitySelection(editor, edgeNodes, affinity);\n }\n return true;\n }\n };\n\n if (apply()) return;\n\n deleteBackward(unit);\n },\n insertText(text, options) {\n /** This will be computed only for text nodes with marks. */\n const applyOutwardAffinity = () => {\n if (!editor.selection || editor.api.isExpanded()) {\n return;\n }\n\n const textPath = editor.selection.focus.path;\n const textNode = NodeApi.get<TText>(editor, textPath);\n\n if (!textNode) {\n return;\n }\n\n const marks = Object.keys(NodeApi.extractProps(textNode));\n const outwardMarks = marks.filter(\n (type) =>\n getPluginByType(editor, type)?.rules.selection?.affinity ===\n 'outward'\n );\n\n if (\n !outwardMarks.length ||\n !editor.api.isEnd(editor.selection.focus, textPath)\n ) {\n return;\n }\n\n const nextPoint = editor.api.start(textPath, { next: true });\n const marksToRemove: string[] = [];\n\n // Get next text node once outside the loop\n let nextTextNode: TText | null = null;\n if (nextPoint) {\n const nextTextPath = nextPoint.path;\n nextTextNode = NodeApi.get<TText>(editor, nextTextPath) || null;\n }\n\n // Check each mark individually\n for (const markKey of outwardMarks) {\n if (!textNode[markKey]) {\n continue; // Skip marks not present on current node\n }\n\n const isBetweenSameMarks = nextTextNode?.[markKey];\n\n if (!isBetweenSameMarks) {\n marksToRemove.push(markKey);\n }\n }\n\n if (marksToRemove.length > 0) {\n editor.tf.removeMarks(marksToRemove);\n }\n };\n\n applyOutwardAffinity();\n\n return insertText(text, options);\n },\n move: (options) => {\n const apply = () => {\n const {\n distance = 1,\n reverse = false,\n unit = 'character',\n } = options || {};\n\n if (\n unit === 'character' &&\n distance === 1 &&\n editor.api.isCollapsed()\n ) {\n const preEdgeNodes = getEdgeNodes(editor);\n\n if (preEdgeNodes && isNodesAffinity(editor, preEdgeNodes, 'hard')) {\n if (\n preEdgeNodes &&\n preEdgeNodes[reverse ? 0 : 1] === null &&\n getMarkBoundaryAffinity(editor, preEdgeNodes) ===\n (reverse ? 'forward' : 'backward')\n ) {\n setAffinitySelection(\n editor,\n preEdgeNodes,\n reverse ? 'backward' : 'forward'\n );\n\n return true;\n }\n\n move({ ...options, unit: 'offset' });\n return true;\n }\n\n move(options);\n\n const postEdgeNodes = getEdgeNodes(editor);\n\n /**\n * If the move places the cursor at a mark boundary, then the affinity\n * should be set to the direction the cursor came from.\n */\n if (\n postEdgeNodes &&\n isNodesAffinity(editor, postEdgeNodes, 'directional') &&\n !hasElement(postEdgeNodes)\n ) {\n setAffinitySelection(\n editor,\n postEdgeNodes,\n reverse ? 'forward' : 'backward'\n );\n }\n\n return true;\n }\n };\n\n if (apply()) return;\n\n move(options);\n },\n },\n}));\n\nconst hasElement = (edgeNodes: EdgeNodes) => {\n const [before, after] = edgeNodes;\n\n return (\n (before && ElementApi.isElement(before[0])) ||\n (after && ElementApi.isElement(after[0]))\n );\n};\n","import type { Ancestor } from '@platejs/slate';\n\nimport type { OverrideEditor } from '../../plugin/SlatePlugin';\nimport type { ChunkingConfig } from './ChunkingPlugin';\n\nexport const withChunking: OverrideEditor<ChunkingConfig> = ({\n editor,\n getOptions,\n}) => {\n const { chunkSize, query } = getOptions();\n editor.getChunkSize = (ancestor: Ancestor) =>\n query!(ancestor) ? chunkSize! : null;\n return {};\n};\n","import { type Ancestor, NodeApi } from '@platejs/slate';\n\nimport type { PluginConfig } from '../../plugin/BasePlugin';\n\nimport { createTSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { withChunking } from './withChunking';\n\nexport type ChunkingConfig = PluginConfig<\n 'chunking',\n {\n /**\n * The number of blocks per chunk.\n *\n * @default 1000\n */\n chunkSize?: number;\n /**\n * Whether to render each chunk as a DOM element with `content-visibility:\n * auto`, which optimizes DOM painting. When set to `false`, no DOM element\n * will be rendered for each chunk.\n *\n * @default true\n */\n contentVisibilityAuto?: boolean;\n /**\n * Determine which ancestors should have chunking applied to their children.\n * Only blocks containing other blocks can have chunking applied.\n *\n * @default NodeApi.isEditor\n */\n query?: (ancestor: Ancestor) => boolean;\n }\n>;\n\nexport const ChunkingPlugin = createTSlatePlugin<ChunkingConfig>({\n key: 'chunking',\n options: {\n chunkSize: 1000,\n contentVisibilityAuto: true,\n query: NodeApi.isEditor,\n },\n}).overrideEditor(withChunking);\n","import type { DebugConfig } from '../getCorePlugins';\n\nimport { createTSlatePlugin } from '../../plugin';\n\nexport type DebugErrorType =\n | (string & {})\n | 'DEFAULT'\n | 'OPTION_UNDEFINED'\n | 'OVERRIDE_MISSING'\n | 'PLUGIN_DEPENDENCY_MISSING'\n | 'PLUGIN_MISSING'\n | 'USE_CREATE_PLUGIN'\n | 'USE_ELEMENT_CONTEXT';\n\nexport type LogLevel = 'error' | 'info' | 'log' | 'warn';\n\nexport class PlateError extends Error {\n type: DebugErrorType;\n\n constructor(message: string, type: DebugErrorType = 'DEFAULT') {\n super(`[${type}] ${message}`);\n this.name = 'PlateError';\n this.type = type;\n }\n}\n\nexport const DebugPlugin = createTSlatePlugin<DebugConfig>({\n key: 'debug',\n options: {\n isProduction: process.env.NODE_ENV === 'production',\n logger: {\n error: (message, type, details) =>\n console.error(`${type ? `[${type}] ` : ''}${message}`, details),\n info: (message, type, details) =>\n console.info(`${type ? `[${type}] ` : ''}${message}`, details),\n log: (message, type, details) =>\n // biome-ignore lint/suspicious/noConsole: lib\n console.log(`${type ? `[${type}] ` : ''}${message}`, details),\n warn: (message, type, details) =>\n console.warn(`${type ? `[${type}] ` : ''}${message}`, details),\n },\n logLevel:\n process.env.NODE_ENV === 'production' ? 'error' : ('log' as LogLevel),\n throwErrors: true,\n },\n}).extendEditorApi<DebugConfig['api']>(({ getOptions }) => {\n const logLevels: LogLevel[] = ['error', 'warn', 'info', 'log'];\n\n const log = (\n level: LogLevel,\n message: any,\n type?: DebugErrorType,\n details?: any\n ) => {\n if (process.env.NODE_ENV === 'production') return;\n\n const options = getOptions();\n\n if (options.isProduction && level === 'log') return;\n if (logLevels.indexOf(level) <= logLevels.indexOf(options.logLevel!)) {\n if (level === 'error' && options.throwErrors) {\n throw new PlateError(message, type);\n }\n options.logger[level]?.(message, type, details);\n }\n };\n\n return {\n debug: {\n error: (message, type, details) => log('error', message, type, details),\n info: (message, type, details) => log('info', message, type, details),\n log: (message, type, details) => log('log', message, type, details),\n warn: (message, type, details) => log('warn', message, type, details),\n },\n };\n});\n","import type { ScrollIntoViewOptions } from '@platejs/slate';\n\nimport isUndefined from 'lodash/isUndefined.js';\nimport omitBy from 'lodash/omitBy.js';\n\nimport type { SlateEditor } from '../../editor';\nimport type { AutoScrollOperationsMap, ScrollMode } from './DOMPlugin';\n\nimport { AUTO_SCROLL, DOMPlugin } from './DOMPlugin';\n\nexport type WithAutoScrollOptions = {\n mode?: ScrollMode;\n operations?: AutoScrollOperationsMap;\n scrollOptions?: ScrollIntoViewOptions;\n};\n\nexport const withScrolling = (\n editor: SlateEditor,\n fn: () => void,\n options?: WithAutoScrollOptions\n) => {\n const prevOptions = editor.getOptions(DOMPlugin);\n const prevAutoScroll = AUTO_SCROLL.get(editor) ?? false;\n\n if (options) {\n const ops = {\n ...prevOptions,\n ...omitBy(options, isUndefined),\n };\n\n editor.setOptions(DOMPlugin, ops);\n }\n AUTO_SCROLL.set(editor, true);\n fn();\n // reset\n AUTO_SCROLL.set(editor, prevAutoScroll);\n editor.setOptions(DOMPlugin, prevOptions);\n};\n","import type { Operation, ScrollIntoViewOptions, TRange } from '@platejs/slate';\n\nimport { bindFirst } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../';\n\nimport { type PluginConfig, createTSlatePlugin } from '../../plugin';\nimport { withScrolling } from './withScrolling';\n\nexport const AUTO_SCROLL = new WeakMap<SlateEditor, boolean>();\n\nexport type AutoScrollOperationsMap = Partial<\n Record<Operation['type'], boolean>\n>;\n\nexport type DomConfig = PluginConfig<\n 'dom',\n {\n /** Choose the first or last matching operation as the scroll target */\n scrollMode?: ScrollMode;\n /**\n * Operations map; false to disable an operation, true or undefined to\n * enable\n */\n scrollOperations?: AutoScrollOperationsMap;\n /** Options passed to scrollIntoView */\n scrollOptions?: ScrollIntoViewOptions;\n }\n>;\n\n/** Mode for picking target op when multiple enabled */\nexport type ScrollMode = 'first' | 'last';\n\n/**\n * Placeholder plugin for DOM interaction, that could be replaced with\n * ReactPlugin.\n */\nexport const DOMPlugin = createTSlatePlugin<DomConfig>({\n key: 'dom',\n options: {\n scrollMode: 'last',\n scrollOperations: {\n insert_node: true,\n insert_text: true,\n },\n scrollOptions: {\n scrollMode: 'if-needed',\n },\n },\n})\n .extendEditorApi(({ editor }) => ({\n isScrolling: () => AUTO_SCROLL.get(editor) ?? false,\n }))\n .extendEditorTransforms(({ editor }) => ({\n withScrolling: bindFirst(withScrolling, editor),\n }))\n .overrideEditor(({ api, editor, getOption, tf: { apply } }) => ({\n transforms: {\n apply(operation) {\n if (api.isScrolling()) {\n apply(operation);\n\n // Check if this op type is enabled (default true)\n const scrollOperations = getOption('scrollOperations')!;\n\n if (!scrollOperations[operation.type]) return;\n\n // Gather enabled ops in this batch\n const matched = editor.operations.filter(\n (op) => !!scrollOperations[op.type]\n );\n\n if (matched.length === 0) return;\n\n const mode = getOption('scrollMode')!;\n\n // Pick target\n const targetOp = mode === 'first' ? matched[0] : matched.at(-1);\n\n if (!targetOp) return;\n\n const { offset, path } = (targetOp as any).path\n ? (targetOp as any as { path: number[]; offset?: number })\n : {};\n\n if (!path) return;\n\n const scrollOptions = getOption('scrollOptions')!;\n\n const scrollTarget = {\n offset: offset ?? 0,\n path,\n };\n\n api.scrollIntoView(scrollTarget, scrollOptions);\n\n return;\n }\n\n return apply(operation);\n },\n },\n }))\n .overrideEditor(({ editor, tf: { apply } }) => ({\n transforms: {\n apply(operation) {\n if (operation.type === 'set_selection') {\n const { properties } = operation;\n editor.dom.prevSelection = properties as TRange | null;\n apply(operation);\n editor.dom.currentKeyboardEvent = null;\n return;\n }\n\n apply(operation);\n },\n },\n }));\n","export const isHtmlElement = (node: Node): node is Element =>\n node.nodeType === Node.ELEMENT_NODE;\n","export const isHtmlText = (node: Node): node is Text =>\n node.nodeType === Node.TEXT_NODE;\n","/**\n * # Methodology\n *\n * ## Step 1. Get the list of all standard tag names\n *\n * Go to https://developer.mozilla.org/en-US/docs/Web/HTML/Element and run the\n * following in the console to generate a JSON array of tag names:\n *\n * ```js\n * JSON.stringify(\n * Array.from(document.querySelectorAll('article table td:first-child'))\n * .map((td) => {\n * const body = document.createElement('body');\n * body.innerHTML = td.textContent;\n * return body.firstChild?.tagName;\n * })\n * .filter((tagName) => tagName)\n * );\n * ```\n *\n * Output (as of 2023-11-06):\n *\n * ```json\n * '[\"BASE\",\"LINK\",\"META\",\"STYLE\",\"TITLE\",\"ADDRESS\",\"ARTICLE\",\"ASIDE\",\"FOOTER\",\"HEADER\",\"H1\",\"HGROUP\",\"MAIN\",\"NAV\",\"SECTION\",\"SEARCH\",\"BLOCKQUOTE\",\"DD\",\"DIV\",\"DL\",\"DT\",\"FIGCAPTION\",\"FIGURE\",\"HR\",\"LI\",\"MENU\",\"OL\",\"P\",\"PRE\",\"UL\",\"A\",\"ABBR\",\"B\",\"BDI\",\"BDO\",\"BR\",\"CITE\",\"CODE\",\"DATA\",\"DFN\",\"EM\",\"I\",\"KBD\",\"MARK\",\"Q\",\"RP\",\"RT\",\"RUBY\",\"S\",\"SAMP\",\"SMALL\",\"SPAN\",\"STRONG\",\"SUB\",\"SUP\",\"TIME\",\"U\",\"VAR\",\"WBR\",\"AREA\",\"AUDIO\",\"IMG\",\"MAP\",\"TRACK\",\"VIDEO\",\"EMBED\",\"IFRAME\",\"OBJECT\",\"PICTURE\",\"PORTAL\",\"SOURCE\",\"svg\",\"math\",\"CANVAS\",\"NOSCRIPT\",\"SCRIPT\",\"DEL\",\"INS\",\"TABLE\",\"BUTTON\",\"DATALIST\",\"FIELDSET\",\"FORM\",\"INPUT\",\"LABEL\",\"LEGEND\",\"METER\",\"OPTGROUP\",\"OPTION\",\"OUTPUT\",\"PROGRESS\",\"SELECT\",\"TEXTAREA\",\"DETAILS\",\"DIALOG\",\"SUMMARY\",\"SLOT\",\"TEMPLATE\",\"ACRONYM\",\"BIG\",\"CENTER\",\"CONTENT\",\"DIR\",\"FONT\",\"IMG\",\"MARQUEE\",\"MENUITEM\",\"NOBR\",\"NOEMBED\",\"NOFRAMES\",\"PARAM\",\"PLAINTEXT\",\"RB\",\"RTC\",\"SHADOW\",\"STRIKE\",\"TT\",\"XMP\"]'\n * ```\n *\n * ## Step 2. For each tag name, determine the default browser style\n *\n * Open an empty HTML file in the browser and run the following in the console:\n *\n * ```js\n * const tagNames = JSON.parse(<JSON string from step 1>);\n *\n * JSON.stringify(\n * tagNames.filter((tagName) => {\n * const element = document.createElement(tagName);\n * document.body.appendChild(element);\n * const display = window.getComputedStyle(element).display;\n * element.remove();\n * return display.startsWith('inline');\n * })\n * );\n * ```\n *\n * Place the result in the array below (accurate as of 2023-11-06).\n */\n\nexport const inlineTagNames = new Set([\n 'A',\n 'ABBR',\n 'ACRONYM',\n 'B',\n 'BDI',\n 'BDO',\n 'BIG',\n 'BR',\n 'BUTTON',\n 'CANVAS',\n 'CITE',\n 'CODE',\n 'CONTENT',\n 'DATA',\n 'DEL',\n 'DFN',\n 'EM',\n 'EMBED',\n 'FONT',\n 'I',\n 'IFRAME',\n 'IMG',\n 'IMG',\n 'INPUT',\n 'INS',\n 'KBD',\n 'LABEL',\n 'MAP',\n 'MARK',\n 'MARQUEE',\n 'math',\n 'MENUITEM',\n 'METER',\n 'NOBR',\n 'OBJECT',\n 'OUTPUT',\n 'PICTURE',\n 'PORTAL',\n 'PROGRESS',\n 'Q',\n 'S',\n 'SAMP',\n 'SELECT',\n 'SHADOW',\n 'SMALL',\n 'SOURCE',\n 'SPAN',\n 'STRIKE',\n 'STRONG',\n 'SUB',\n 'SUP',\n 'svg',\n 'TEXTAREA',\n 'TIME',\n 'TRACK',\n 'TT',\n 'U',\n 'VAR',\n 'VIDEO',\n 'WBR',\n]);\n","import { inlineTagNames } from './inlineTagNames';\nimport { isHtmlElement } from './isHtmlElement';\n\nexport const isHtmlInlineElement = (node: Node): boolean => {\n if (!isHtmlElement(node)) return false;\n\n const element = node as HTMLElement;\n\n const tagNameIsInline = inlineTagNames.has(element.tagName);\n\n /**\n * Valid display values include 'inline flow'. We only care about the first\n * part.\n */\n const displayProperty = element.style.display.split(' ')[0];\n\n if (displayProperty === '') {\n return tagNameIsInline;\n }\n if (displayProperty.startsWith('inline')) {\n return true;\n }\n if (displayProperty === 'inherit' && element.parentElement) {\n return isHtmlInlineElement(element.parentElement);\n }\n /**\n * Handle all special values manually, so that any unhandled values can be\n * assumed to be block.\n *\n * Note: Ideally, content inside `display: none` elements should not be\n * parsed. However, if such elements are parsed, it's best for their inline or\n * block status to be left unchanged.\n */\n if (\n ['contents', 'initial', 'none', 'revert', 'revert-layer', 'unset'].includes(\n displayProperty\n )\n ) {\n return tagNameIsInline;\n }\n\n return false;\n};\n","import { isHtmlElement } from './isHtmlElement';\nimport { isHtmlInlineElement } from './isHtmlInlineElement';\n\nexport const isHtmlBlockElement = (node: Node): boolean => {\n if (!isHtmlElement(node)) return false;\n\n const element = node as HTMLElement;\n\n return !isHtmlInlineElement(element);\n};\n","import type { TrimEndRule, TrimStartRule } from './types';\n\nconst LEADING_WHITESPACE_REGEX = /^\\s+/;\nconst TRAILING_NEWLINE_REGEX = /\\n$/;\n\nexport const collapseString = (\n text: string,\n {\n shouldCollapseWhiteSpace = true,\n trimEnd = 'collapse',\n trimStart = 'collapse',\n whiteSpaceIncludesNewlines = true,\n }: {\n shouldCollapseWhiteSpace?: boolean;\n trimEnd?: TrimEndRule;\n trimStart?: TrimStartRule;\n whiteSpaceIncludesNewlines?: boolean;\n } = {}\n) => {\n let result = text;\n\n if (trimStart === 'all') {\n result = result.replace(LEADING_WHITESPACE_REGEX, '');\n }\n if (trimEnd === 'single-newline') {\n // Strip at most one newline from the end\n result = result.replace(TRAILING_NEWLINE_REGEX, '');\n }\n if (shouldCollapseWhiteSpace) {\n if (whiteSpaceIncludesNewlines) {\n result = result.replaceAll(/\\s+/g, ' ');\n } else {\n // Collapse horizontal whitespace\n result = result.replaceAll(/[^\\S\\n\\r]+/g, ' ');\n\n /**\n * Trim horizontal whitespace from the start and end of lines (behavior of\n * pre-line).\n */\n result = result.replaceAll(/^[^\\S\\n\\r]+/gm, '');\n result = result.replaceAll(/[^\\S\\n\\r]+$/gm, '');\n }\n }\n\n return result;\n};\n","import { isHtmlBlockElement } from '../isHtmlBlockElement';\n\nexport const isLastNonEmptyTextOfInlineFormattingContext = (\n initialText: Text\n): boolean => {\n let currentNode: Node | null = initialText;\n\n while (true) {\n if (currentNode.nextSibling) {\n currentNode = currentNode.nextSibling;\n } else {\n // If there is no next sibling, ascend to the parent node\n currentNode = currentNode.parentElement;\n\n // If the parent node is a block, we've reached the end\n if (currentNode && isHtmlBlockElement(currentNode)) {\n return true;\n }\n\n // Otherwise, continue to the next sibling of the parent node\n currentNode = currentNode?.nextSibling || null;\n }\n // If there's no next node, we've reached the end\n if (!currentNode) {\n return true;\n }\n // If the next node is a block, we've reached the end\n if (isHtmlBlockElement(currentNode)) {\n return true;\n }\n // If the next node is a non-empty text node, we're not at the end\n if ((currentNode.textContent || '').length > 0) {\n return false;\n }\n\n // Otherwise, continue to the next node\n }\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nexport const upsertInlineFormattingContext = (\n state: CollapseWhiteSpaceState\n) => {\n if (state.inlineFormattingContext) {\n state.inlineFormattingContext.atStart = false;\n } else {\n state.inlineFormattingContext = {\n atStart: true,\n lastHasTrailingWhiteSpace: false,\n };\n }\n};\n\nexport const endInlineFormattingContext = (state: CollapseWhiteSpaceState) => {\n state.inlineFormattingContext = null;\n};\n","import type {\n CollapseWhiteSpaceState,\n TrimEndRule,\n TrimStartRule,\n} from './types';\n\nimport { collapseString } from './collapseString';\nimport { isLastNonEmptyTextOfInlineFormattingContext } from './isLastNonEmptyTextOfInlineFormattingContext';\nimport { upsertInlineFormattingContext } from './stateTransforms';\n\nexport const collapseWhiteSpaceText = (\n text: Text,\n state: CollapseWhiteSpaceState\n) => {\n const textContent = text.textContent || '';\n const isWhiteSpaceOnly = textContent.trim() === '';\n\n /**\n * Do not start an inline formatting context with a text node containing only\n * white space.\n */\n if (state.inlineFormattingContext || !isWhiteSpaceOnly) {\n upsertInlineFormattingContext(state);\n }\n\n const { whiteSpaceRule } = state;\n\n /**\n * Note: Due to the way HTML strings are parsed in htmlStringToDOMNode, up to\n * one newline is already trimmed from the start of text nodes inside <pre>\n * elements. If we do so again here, we may remove too many newlines. This\n * only applies to actual <pre> elements, not elements with the white-space\n * CSS property.\n */\n const trimStart: TrimStartRule = (() => {\n if (whiteSpaceRule !== 'normal') return 'collapse';\n if (\n !state.inlineFormattingContext ||\n state.inlineFormattingContext.atStart ||\n state.inlineFormattingContext.lastHasTrailingWhiteSpace\n )\n return 'all';\n\n return 'collapse';\n })();\n\n const trimEnd: TrimEndRule = (() => {\n if (whiteSpaceRule === 'normal') return 'collapse';\n if (isLastNonEmptyTextOfInlineFormattingContext(text))\n return 'single-newline';\n\n return 'collapse';\n })();\n\n const shouldCollapseWhiteSpace: boolean = {\n normal: true,\n pre: false,\n 'pre-line': true,\n }[whiteSpaceRule];\n\n const whiteSpaceIncludesNewlines = whiteSpaceRule !== 'pre-line';\n\n const collapsedTextContent = collapseString(textContent || '', {\n shouldCollapseWhiteSpace,\n trimEnd,\n trimStart,\n whiteSpaceIncludesNewlines,\n });\n\n if (state.inlineFormattingContext && shouldCollapseWhiteSpace) {\n state.inlineFormattingContext.lastHasTrailingWhiteSpace =\n collapsedTextContent.endsWith(' ');\n }\n\n text.textContent = collapsedTextContent;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { isHtmlElement } from '../isHtmlElement';\nimport { isHtmlText } from '../isHtmlText';\nimport { collapseWhiteSpaceChildren } from './collapseWhiteSpaceChildren';\nimport { collapseWhiteSpaceElement } from './collapseWhiteSpaceElement';\nimport { collapseWhiteSpaceText } from './collapseWhiteSpaceText';\n\nexport const collapseWhiteSpaceNode = (\n node: Node,\n state: CollapseWhiteSpaceState\n) => {\n if (isHtmlElement(node)) {\n collapseWhiteSpaceElement(node as HTMLElement, state);\n\n return;\n }\n if (isHtmlText(node)) {\n collapseWhiteSpaceText(node as Text, state);\n\n return;\n }\n\n collapseWhiteSpaceChildren(node, state);\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { collapseWhiteSpaceNode } from './collapseWhiteSpaceNode';\n\nexport const collapseWhiteSpaceChildren = (\n node: Node,\n state: CollapseWhiteSpaceState\n) => {\n const childNodes = Array.from(node.childNodes);\n\n for (const childNode of childNodes) {\n collapseWhiteSpaceNode(childNode, state);\n }\n};\n","import type { WhiteSpaceRule } from './types';\n\nexport const inferWhiteSpaceRule = (\n element: HTMLElement\n): WhiteSpaceRule | null => {\n const whiteSpaceProperty = element.style.whiteSpace;\n\n switch (whiteSpaceProperty) {\n case 'break-spaces':\n case 'pre':\n case 'pre-wrap': {\n return 'pre';\n }\n case 'normal':\n case 'nowrap': {\n return 'normal';\n }\n case 'pre-line': {\n return 'pre-line';\n }\n }\n\n if (element.tagName === 'PRE') {\n return 'pre';\n }\n if (whiteSpaceProperty === 'initial') {\n return 'normal';\n }\n\n return null;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { isHtmlInlineElement } from '../isHtmlInlineElement';\nimport { collapseWhiteSpaceChildren } from './collapseWhiteSpaceChildren';\nimport { inferWhiteSpaceRule } from './inferWhiteSpaceRule';\nimport { endInlineFormattingContext } from './stateTransforms';\n\n/**\n * Note: We do not want to start an inline formatting context until we encounter\n * a text node.\n */\nexport const collapseWhiteSpaceElement = (\n element: HTMLElement,\n state: CollapseWhiteSpaceState\n) => {\n const isInlineElement = isHtmlInlineElement(element);\n const previousWhiteSpaceRule = state.whiteSpaceRule;\n const inferredWhiteSpaceRule = inferWhiteSpaceRule(element);\n\n if (inferredWhiteSpaceRule) {\n state.whiteSpaceRule = inferredWhiteSpaceRule;\n }\n // End any existing inline formatting context\n if (!isInlineElement) {\n endInlineFormattingContext(state);\n }\n\n collapseWhiteSpaceChildren(element, state);\n\n // Do not let inline formatting context break out of block elements\n if (!isInlineElement) {\n endInlineFormattingContext(state);\n }\n\n // Restore previous whiteSpaceRule\n state.whiteSpaceRule = previousWhiteSpaceRule;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { collapseWhiteSpaceElement } from './collapseWhiteSpaceElement';\n\n// Entrypoint\nexport const collapseWhiteSpace = (element: HTMLElement) => {\n const clonedElement = element.cloneNode(true) as HTMLElement;\n\n // Mutable state object\n const state: CollapseWhiteSpaceState = {\n inlineFormattingContext: null,\n whiteSpaceRule: 'normal',\n };\n\n collapseWhiteSpaceElement(clonedElement, state);\n\n return clonedElement;\n};\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlChildren } from '../types';\n\nimport { isSlateNode } from '../../../utils';\nimport { deserializeHtmlNode } from './deserializeHtmlNode';\n\nexport const deserializeHtmlNodeChildren = (\n editor: SlateEditor,\n node: ChildNode | HTMLElement,\n isSlateParent = false\n): DeserializeHtmlChildren[] =>\n Array.from(node.childNodes).flatMap((child) => {\n if (\n child.nodeType === 1 &&\n !isSlateNode(child as HTMLElement) &&\n isSlateParent\n ) {\n return deserializeHtmlNodeChildren(\n editor,\n child as HTMLElement,\n isSlateParent\n );\n }\n\n return deserializeHtmlNode(editor)(child);\n }) as DeserializeHtmlChildren[];\n","import type { Descendant } from '@platejs/slate';\n\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\n\n/** Deserialize HTML body element to Fragment. */\nexport const htmlBodyToFragment = (\n editor: SlateEditor,\n element: HTMLElement\n): Descendant[] | undefined => {\n if (element.nodeName === 'BODY') {\n return jsx(\n 'fragment',\n {},\n deserializeHtmlNodeChildren(editor, element)\n ) as Descendant[];\n }\n};\n","/** Deserialize HTML to break line. */\nexport const htmlBrToNewLine = (node: ChildNode | HTMLElement) => {\n if (node.nodeName === 'BR') {\n return '\\n';\n }\n};\n","import type { SlateEditor } from '../../../editor';\n\nimport { type AnyEditorPlugin, getEditorPlugin } from '../../../plugin';\nimport { isSlateLeaf, isSlatePluginNode } from '../../../utils';\n\nconst getDefaultNodeProps = ({\n element,\n type,\n}: {\n element: HTMLElement;\n type: string;\n}) => {\n if (!isSlatePluginNode(element, type) && !isSlateLeaf(element)) return;\n\n const dataAttributes: Record<string, any> = {};\n\n // Get all data-slate-* attributes from dataset\n Object.entries(element.dataset).forEach(([key, value]) => {\n if (\n key.startsWith('slate') &&\n value &&\n // Ignore slate default attributes\n !['slateInline', 'slateLeaf', 'slateNode', 'slateVoid'].includes(key)\n ) {\n // Remove 'slate' prefix and convert to camelCase\n const attributeKey = key.slice(5).charAt(0).toLowerCase() + key.slice(6);\n\n // Parse value if it's a boolean or number string\n\n if (value === undefined) return;\n\n let parsedValue: any = value;\n\n if (value === 'true') parsedValue = true;\n else if (value === 'false') parsedValue = false;\n else if (!Number.isNaN(Number(value))) parsedValue = Number(value);\n\n dataAttributes[attributeKey] = parsedValue;\n }\n });\n\n if (Object.keys(dataAttributes).length > 0) {\n return dataAttributes;\n }\n};\n\nexport const getDataNodeProps = ({\n editor,\n element,\n plugin,\n}: {\n editor: SlateEditor;\n element: HTMLElement;\n plugin: AnyEditorPlugin;\n}) => {\n const toNodeProps = plugin.parsers.html?.deserializer?.toNodeProps;\n\n const disableDefaultNodeProps =\n plugin.parsers.html?.deserializer?.disableDefaultNodeProps ?? false;\n\n const defaultNodeProps = disableDefaultNodeProps\n ? {}\n : getDefaultNodeProps({\n ...(getEditorPlugin(editor, plugin) as any),\n element,\n });\n\n if (!toNodeProps) return defaultNodeProps;\n\n const customNodeProps =\n toNodeProps({\n ...(getEditorPlugin(editor, plugin) as any),\n element,\n }) ?? {};\n\n return {\n ...defaultNodeProps,\n ...customNodeProps,\n };\n};\n","import { type AnyObject, type Nullable, isDefined } from '@udecode/utils';\nimport castArray from 'lodash/castArray.js';\n\nimport type { SlateEditor } from '../../../editor';\nimport type {\n AnyEditorPlugin,\n HtmlDeserializer,\n} from '../../../plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../../plugin';\nimport { isSlateNode } from '../../../utils/checkUtils';\nimport { getInjectedPlugins } from '../../../utils/getInjectedPlugins';\nimport { getDataNodeProps } from './getDataNodeProps';\n\n/**\n * Get a deserializer and add default rules for deserializing plate static\n * elements\n */\nconst getDeserializedWithStaticRules = (plugin: AnyEditorPlugin) => {\n let deserializer = plugin.parsers?.html?.deserializer;\n\n const rules = deserializer?.rules ?? [];\n\n // Check if rules already contain slate-xxx className\n const hasSlateRule = rules.some((rule) =>\n rule.validClassName?.includes(`slate-${plugin.key}`)\n );\n\n const staticRules = hasSlateRule\n ? rules\n : [\n {\n validClassName: `slate-${plugin.key}`,\n validNodeName: '*',\n },\n ...rules,\n ];\n\n if (!deserializer) deserializer = { rules: staticRules };\n\n deserializer.rules = staticRules;\n\n return deserializer;\n};\n\n/** Get a deserializer by type, node names, class names and styles. */\nexport const pluginDeserializeHtml = (\n editor: SlateEditor,\n plugin: AnyEditorPlugin,\n {\n deserializeLeaf,\n element: el,\n }: { element: HTMLElement; deserializeLeaf?: boolean }\n): (Nullable<HtmlDeserializer> & { node: AnyObject }) | undefined => {\n const {\n node: { isElement: isElementRoot, isLeaf: isLeafRoot },\n } = plugin;\n\n const deserializer = getDeserializedWithStaticRules(plugin);\n\n if (!deserializer) return;\n\n const {\n attributeNames,\n isElement: isElementRule,\n isLeaf: isLeafRule,\n query,\n rules,\n } = deserializer;\n let { parse } = deserializer;\n\n const isElement = isElementRule || isElementRoot;\n const isLeaf = isLeafRule || isLeafRoot;\n\n if (!deserializeLeaf && !isElement) {\n return;\n }\n if (deserializeLeaf && !isLeaf) {\n return;\n }\n if (rules) {\n const isValid = rules.some(\n ({ validAttribute, validClassName, validNodeName = '*', validStyle }) => {\n if (validNodeName) {\n const validNodeNames = castArray<string>(validNodeName);\n\n // Ignore if el nodeName is not included in rule validNodeNames (except *).\n if (\n validNodeNames.length > 0 &&\n !validNodeNames.includes(el.nodeName) &&\n validNodeName !== '*'\n )\n return false;\n }\n // Ignore if the rule className is not in el class list.\n if (validClassName && !el.classList.contains(validClassName))\n return false;\n if (validStyle) {\n for (const [key, value] of Object.entries(validStyle)) {\n const values = castArray<string>(value);\n\n // Ignore if el style value is not included in rule style values (except *)\n if (!values.includes((el.style as any)[key]) && value !== '*')\n return false;\n // Ignore if el style value is falsy (for value *)\n if (value === '*' && !(el.style as any)[key]) return false;\n\n const defaultNodeValue = plugin.inject.nodeProps?.defaultNodeValue;\n\n // Ignore if the style value = plugin.inject.nodeProps.defaultNodeValue\n if (\n defaultNodeValue &&\n defaultNodeValue === (el.style as any)[key]\n ) {\n return false;\n }\n }\n }\n if (validAttribute) {\n if (typeof validAttribute === 'string') {\n if (!el.getAttributeNames().includes(validAttribute)) return false;\n } else {\n for (const [attributeName, attributeValue] of Object.entries(\n validAttribute\n )) {\n const attributeValues = castArray<string>(attributeValue);\n const elAttribute = el.getAttribute(attributeName);\n\n if (\n !isDefined(elAttribute) ||\n !attributeValues.includes(elAttribute)\n )\n return false;\n }\n }\n }\n\n return true;\n }\n );\n\n if (!isValid) return;\n }\n if (\n query &&\n !query({ ...(getEditorPlugin(editor, plugin) as any), element: el })\n ) {\n return;\n }\n if (!parse)\n if (isElement) {\n parse = ({ type }) => ({ type });\n } else if (isLeaf) {\n parse = ({ type }) => ({ [type!]: true });\n } else {\n return;\n }\n\n const parsedNode = (() => {\n if (isSlateNode(el)) {\n return {};\n }\n\n return (\n parse({\n ...(getEditorPlugin(editor, plugin) as any),\n element: el,\n node: {},\n }) ?? {}\n );\n })();\n\n const dataNodeProps = getDataNodeProps({\n editor,\n element: el,\n plugin,\n });\n\n let node = {\n ...parsedNode,\n ...dataNodeProps,\n };\n\n if (Object.keys(node).length === 0) return;\n\n const injectedPlugins = getInjectedPlugins(editor, plugin);\n\n injectedPlugins.forEach((injectedPlugin) => {\n const res = injectedPlugin.parsers?.html?.deserializer?.parse?.({\n ...(getEditorPlugin(editor, plugin) as any),\n element: el,\n node,\n });\n\n if (res && !isSlateNode(el)) {\n node = {\n ...node,\n ...res,\n };\n }\n });\n\n if (attributeNames) {\n const elementAttributes = {};\n\n const elementAttributeNames = el.getAttributeNames();\n\n for (const elementAttributeName of elementAttributeNames) {\n if (attributeNames.includes(elementAttributeName)) {\n (elementAttributes as any)[elementAttributeName] =\n el.getAttribute(elementAttributeName);\n }\n }\n\n if (Object.keys(elementAttributes).length > 0) {\n node.attributes = elementAttributes;\n }\n }\n\n return { ...deserializer, node };\n};\n","import type { AnyObject, Nullable } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { HtmlDeserializer } from '../../../plugin/SlatePlugin';\n\nimport { pluginDeserializeHtml } from './pluginDeserializeHtml';\n\nexport const pipeDeserializeHtmlElement = (\n editor: SlateEditor,\n element: HTMLElement\n) => {\n let result: (Nullable<HtmlDeserializer> & { node: AnyObject }) | undefined;\n\n [...editor.meta.pluginList].reverse().some((plugin) => {\n result = pluginDeserializeHtml(editor, plugin, { element });\n\n return !!result;\n });\n\n return result;\n};\n","import type { Descendant } from '@platejs/slate';\n\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { isSlateVoid } from '../../../utils/checkUtils';\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\nimport { pipeDeserializeHtmlElement } from './pipeDeserializeHtmlElement';\n\n/** Deserialize HTML to Element. */\nexport const htmlElementToElement = (\n editor: SlateEditor,\n element: HTMLElement,\n isSlate = false\n) => {\n const deserialized = pipeDeserializeHtmlElement(editor, element);\n\n if (deserialized) {\n const { node, withoutChildren } = deserialized;\n\n let descendants =\n node.children ??\n (deserializeHtmlNodeChildren(editor, element, isSlate) as Descendant[]);\n\n if (descendants.length === 0 || withoutChildren || isSlateVoid(element)) {\n descendants = [{ text: '' }];\n }\n\n return jsx('element', node, descendants) as Descendant;\n }\n};\n","import type { AnyObject } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { pluginDeserializeHtml } from './pluginDeserializeHtml';\n\nexport const pipeDeserializeHtmlLeaf = (\n editor: SlateEditor,\n element: HTMLElement\n) => {\n let node: AnyObject = {};\n\n [...editor.meta.pluginList].reverse().forEach((plugin) => {\n const deserialized = pluginDeserializeHtml(editor, plugin, {\n deserializeLeaf: true,\n element,\n });\n\n if (!deserialized) return;\n\n node = { ...node, ...deserialized.node };\n });\n\n return node;\n};\n","import { type Descendant, ElementApi, TextApi } from '@platejs/slate';\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { mergeDeepToNodes } from '../../../utils';\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\nimport { pipeDeserializeHtmlLeaf } from './pipeDeserializeHtmlLeaf';\n\n/**\n * Deserialize HTML to Descendant[] with marks on Text. Build the leaf from the\n * leaf deserializers of each plugin.\n */\nexport const htmlElementToLeaf = (\n editor: SlateEditor,\n element: HTMLElement\n) => {\n const node = pipeDeserializeHtmlLeaf(editor, element);\n\n return deserializeHtmlNodeChildren(editor, element).reduce(\n (arr: Descendant[], child) => {\n if (!child) return arr;\n if (ElementApi.isElement(child)) {\n if (Object.keys(node).length > 0) {\n mergeDeepToNodes({\n node: child,\n query: {\n filter: ([n]) => TextApi.isText(n),\n },\n source: node,\n });\n }\n\n arr.push(child);\n } else {\n const attributes = { ...node };\n\n // attributes should not override child attributes\n if (TextApi.isText(child) && child.text) {\n Object.keys(attributes).forEach((key) => {\n if (attributes[key] && child[key]) {\n attributes[key] = child[key];\n }\n });\n }\n\n arr.push(jsx('text', attributes, child) as any);\n }\n\n return arr;\n },\n []\n ) as Descendant[];\n};\n","/** Deserialize HTML text node to text. */\nimport { isHtmlText } from './isHtmlText';\n\nexport const htmlTextNodeToString = (node: ChildNode | HTMLElement) => {\n if (isHtmlText(node)) {\n if (node.parentElement?.dataset.platePreventDeserialization) return '';\n\n return node.textContent || '';\n }\n};\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlNodeReturnType } from '../types';\n\nimport { isSlateNode } from '../../../utils';\nimport { htmlBodyToFragment } from './htmlBodyToFragment';\nimport { htmlBrToNewLine } from './htmlBrToNewLine';\nimport { htmlElementToElement } from './htmlElementToElement';\nimport { htmlElementToLeaf } from './htmlElementToLeaf';\nimport { htmlTextNodeToString } from './htmlTextNodeToString';\nimport { inlineTagNames } from './inlineTagNames';\nimport { isHtmlElement } from './isHtmlElement';\n\n/** Check if an element is a block-level element. */\nconst _isBlockElement = (element: Element | null): boolean => {\n if (!element) return false;\n\n return !inlineTagNames.has(element.tagName);\n};\n\n/** Check if a BR tag should be converted to an empty paragraph. */\nconst shouldBrBecomeEmptyParagraph = (node: Element): boolean => {\n if (node.nodeName !== 'BR') return false;\n\n // Skip Apple-interchange-newline BR tags\n if ((node as HTMLBRElement).className === 'Apple-interchange-newline') {\n return false;\n }\n\n const parent = node.parentElement;\n if (!parent) return false;\n\n // Check immediate parent for text-containing elements\n // BR tags inside P or SPAN should remain as line breaks\n if (parent.tagName === 'P' || parent.tagName === 'SPAN') {\n return false;\n }\n\n // Check if BR has adjacent text content at the same DOM level\n const hasAdjacentText = () => {\n // Check previous siblings for direct text nodes only\n let sibling: Node | null = node.previousSibling;\n while (sibling) {\n if (sibling.nodeType === Node.TEXT_NODE && sibling.textContent?.trim()) {\n return true;\n }\n // Don't check element content, only direct text nodes\n sibling = sibling.previousSibling;\n }\n\n // Check next siblings for direct text nodes only\n sibling = node.nextSibling;\n while (sibling) {\n if (sibling.nodeType === Node.TEXT_NODE && sibling.textContent?.trim()) {\n return true;\n }\n // Don't check element content, only direct text nodes\n sibling = sibling.nextSibling;\n }\n\n return false;\n };\n\n // If BR has adjacent text, it should be a line break\n if (hasAdjacentText()) {\n return false;\n }\n\n // For Google Docs: standalone BR tags inside structural elements (B, TD, DIV, etc.)\n // should become empty paragraphs\n return true;\n};\n\n/** Deserialize HTML element or child node. */\nexport const deserializeHtmlNode =\n (editor: SlateEditor) =>\n (node: ChildNode | HTMLElement): DeserializeHtmlNodeReturnType => {\n const textNode = htmlTextNodeToString(node);\n\n if (textNode) return textNode;\n if (!isHtmlElement(node)) return null;\n\n // Convert BR tags to empty paragraphs when appropriate (e.g., from Google Docs)\n if (shouldBrBecomeEmptyParagraph(node)) {\n return {\n children: [{ text: '' }],\n type: editor.getType('p'),\n };\n }\n\n // Skip Apple-interchange-newline BR tags (already handled in shouldBrBecomeEmptyParagraph)\n if (\n node.nodeName === 'BR' &&\n (node as HTMLBRElement).className === 'Apple-interchange-newline'\n ) {\n return null;\n }\n\n // break line\n const breakLine = htmlBrToNewLine(node);\n\n if (breakLine) return breakLine;\n\n // body\n const fragment = htmlBodyToFragment(editor, node as HTMLElement);\n\n if (fragment) return fragment;\n\n // element\n const element = htmlElementToElement(\n editor,\n node as HTMLElement,\n isSlateNode(node as HTMLElement)\n );\n\n if (element) return element;\n\n // leaf\n return htmlElementToLeaf(editor, node as HTMLElement);\n };\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlNodeReturnType } from '../types';\n\nimport { deserializeHtmlNode } from './deserializeHtmlNode';\n\n/** Deserialize HTML element to fragment. */\nexport const deserializeHtmlElement = (\n editor: SlateEditor,\n element: HTMLElement\n): DeserializeHtmlNodeReturnType => deserializeHtmlNode(editor)(element);\n","/** Convert HTML string into HTML element. */\nexport const htmlStringToDOMNode = (rawHtml: string) => {\n const node = document.createElement('body');\n node.innerHTML = rawHtml;\n\n return node;\n};\n","import type { Descendant } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { WithRequiredKey } from '../../../plugin';\n\nimport { normalizeDescendantsToDocumentFragment } from '../../../utils/normalizeDescendantsToDocumentFragment';\nimport { collapseWhiteSpace } from './collapse-white-space';\nimport { deserializeHtmlElement } from './deserializeHtmlElement';\nimport { htmlStringToDOMNode } from './htmlStringToDOMNode';\n\n/** Deserialize HTML element to a valid document fragment. */\nexport const deserializeHtml = (\n editor: SlateEditor,\n {\n collapseWhiteSpace: shouldCollapseWhiteSpace = true,\n defaultElementPlugin,\n element,\n }: {\n element: HTMLElement | string;\n collapseWhiteSpace?: boolean;\n defaultElementPlugin?: WithRequiredKey;\n }\n): Descendant[] => {\n // for serializer\n if (typeof element === 'string') {\n element = htmlStringToDOMNode(element);\n }\n\n if (shouldCollapseWhiteSpace) {\n element = collapseWhiteSpace(element);\n }\n\n const fragment = deserializeHtmlElement(editor, element) as Descendant[];\n\n return normalizeDescendantsToDocumentFragment(editor, {\n defaultElementPlugin,\n descendants: fragment,\n });\n};\n","export const parseHtmlDocument = (html: string) =>\n new DOMParser().parseFromString(html, 'text/html');\n","import { bindFirst } from '@udecode/utils';\n\nimport { createSlatePlugin } from '../../plugin';\nimport { deserializeHtml, parseHtmlDocument } from './utils';\n\n/**\n * Enables support for deserializing inserted content from HTML format to Slate\n * format and serializing Slate content to HTML format.\n */\nexport const HtmlPlugin = createSlatePlugin({\n key: 'html',\n})\n .extendApi(({ editor }) => ({\n deserialize: bindFirst(deserializeHtml, editor),\n }))\n .extend({\n parser: {\n format: 'text/html',\n deserialize: ({ api, data }) => {\n const document = parseHtmlDocument(data);\n\n return api.html.deserialize({\n element: document.body,\n });\n },\n },\n });\n","import type { LengthConfig } from '../getCorePlugins';\n\nimport { createTSlatePlugin } from '../../plugin';\n\nexport const LengthPlugin = createTSlatePlugin<LengthConfig>({\n key: 'length',\n}).overrideEditor(({ editor, getOptions, tf: { apply } }) => ({\n transforms: {\n apply(operation) {\n editor.tf.withoutNormalizing(() => {\n apply(operation);\n\n const options = getOptions();\n\n if (options.maxLength) {\n const length = editor.api.string([]).length;\n\n // Make sure to remove overflow of text beyond character limit\n if (length > options.maxLength) {\n const overflowLength = length - options.maxLength;\n\n editor.tf.delete({\n distance: overflowLength,\n reverse: true,\n unit: 'character',\n });\n }\n }\n });\n },\n },\n}));\n","import {\n type Descendant,\n type NodeEntry,\n type NodeProps,\n type TNode,\n queryNode,\n} from '@platejs/slate';\nimport { isDefined } from '@udecode/utils';\nimport castArray from 'lodash/castArray.js';\nimport cloneDeep from 'lodash/cloneDeep.js';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { NodeIdConfig } from './NodeIdPlugin';\n\nimport { applyDeepToNodes, defaultsDeepToNodes } from '../../utils';\n\n/** Enables support for inserting nodes with an id key. */\nexport const withNodeId: OverrideEditor<NodeIdConfig> = ({\n editor,\n getOptions,\n tf: { apply, insertNode, insertNodes },\n}) => {\n const idPropsCreator = () => ({\n [getOptions().idKey ?? '']: getOptions().idCreator!(),\n });\n\n const filterNode = (nodeEntry: NodeEntry) => {\n const { filter, filterText } = getOptions();\n\n return (\n filter!(nodeEntry) && (!filterText || nodeEntry[0]?.type !== undefined)\n );\n };\n\n const removeIdFromNodeIfDuplicate = <N extends Descendant>(node: N) => {\n const { idKey = '', reuseId } = getOptions();\n\n if (\n !reuseId &&\n editor.api.some({ at: [], match: { [idKey]: node[idKey] } })\n ) {\n delete node[idKey];\n }\n };\n\n const overrideIdIfSet = (node: TNode) => {\n const { idKey = '' } = getOptions();\n\n if (isDefined(node._id)) {\n const id = node._id;\n node._id = undefined;\n\n if (!editor.api.some({ at: [], match: { [idKey]: id } })) {\n node[idKey] = id;\n }\n }\n };\n\n return {\n transforms: {\n apply(operation) {\n const {\n allow,\n disableInsertOverrides,\n exclude,\n idCreator,\n idKey = '',\n reuseId,\n } = getOptions();\n\n const query = {\n allow,\n exclude,\n filter: filterNode,\n };\n\n if (operation.type === 'insert_node') {\n // clone to be able to write (read-only)\n const node = cloneDeep(operation.node);\n\n // Delete ids from node that are already being used\n applyDeepToNodes({\n apply: removeIdFromNodeIfDuplicate,\n node,\n query,\n source: {},\n });\n\n defaultsDeepToNodes({\n node,\n path: operation.path,\n query,\n source: idPropsCreator,\n });\n\n if (!disableInsertOverrides) {\n applyDeepToNodes({\n apply: overrideIdIfSet,\n node,\n query,\n source: {},\n });\n }\n\n return apply({\n ...operation,\n node,\n });\n }\n if (operation.type === 'split_node') {\n const node = operation.properties as NodeProps<TNode>;\n let id = (operation.properties as any)[idKey];\n\n // only for elements (node with a type) or all nodes if `filterText=false`\n\n if (queryNode([node as any, operation.path], query)) {\n /**\n * Create a new id if:\n *\n * - The id in the new node is already being used in the editor or,\n * - The node has no id\n */\n if (\n !reuseId ||\n id === undefined ||\n editor.api.some({\n at: [],\n match: { [idKey]: id },\n })\n ) {\n id = idCreator!();\n }\n\n return apply({\n ...operation,\n properties: {\n ...operation.properties,\n [idKey]: id,\n },\n });\n }\n // if the node is allowed, we don't want to use the same id\n if (id) {\n delete (operation.properties as any)[idKey];\n }\n }\n\n return apply(operation);\n },\n\n insertNode(node) {\n const { disableInsertOverrides, idKey = '' } = getOptions();\n\n if (!disableInsertOverrides && node[idKey]) {\n if (!Object.isExtensible(node)) {\n // biome-ignore lint/style/noParameterAssign: Need to clone and reassign if node is not extensible\n node = cloneDeep(node);\n }\n\n node._id = node[idKey];\n }\n\n insertNode(node);\n },\n\n insertNodes(_nodes, options) {\n const nodes = castArray<Descendant>(_nodes as any).filter(\n (node) => !!node\n );\n\n if (nodes.length === 0) return;\n\n const { disableInsertOverrides, idKey = '' } = getOptions();\n\n insertNodes(\n nodes.map((node) => {\n if (!disableInsertOverrides && node[idKey]) {\n if (!Object.isExtensible(node)) {\n // biome-ignore lint/style/noParameterAssign: Need to clone and reassign if node is not extensible\n node = cloneDeep(node);\n }\n\n node._id = node[idKey];\n }\n\n return node;\n }),\n options\n );\n },\n },\n };\n};\n","import {\n type Descendant,\n type QueryNodeOptions,\n type Value,\n ElementApi,\n queryNode,\n} from '@platejs/slate';\nimport { nanoid } from 'nanoid';\n\nimport type { PluginConfig } from '../../plugin/BasePlugin';\n\nimport { createTSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { withNodeId } from './withNodeId';\n\nexport type NodeIdOptions = {\n /**\n * By default, when a node inserted using editor.tf.insertNode(s) has an id,\n * it will be used instead of the id generator, except if it already exists in\n * the document. Set this option to true to disable this behavior.\n */\n disableInsertOverrides?: boolean;\n /**\n * Filter inline `Element` nodes.\n *\n * @default true\n */\n filterInline?: boolean;\n /**\n * Filter `Text` nodes.\n *\n * @default true\n */\n filterText?: boolean;\n /**\n * Node key to store the id.\n *\n * @default 'id'\n */\n idKey?: string;\n /**\n * Normalize initial value. If false, normalize only the first and last node\n * are missing id. To disable this behavior, use `NodeIdPlugin.configure({\n * normalizeInitialValue: null })`.\n *\n * @default false\n */\n normalizeInitialValue?: boolean;\n /**\n * Reuse ids on undo/redo and copy/pasting if not existing in the document.\n * This is disabled by default to avoid duplicate ids across documents.\n *\n * @default false\n */\n reuseId?: boolean;\n /**\n * A function that generates and returns a unique ID.\n *\n * @default () => nanoid(10)\n */\n idCreator?: () => any;\n} & QueryNodeOptions;\n\nexport type NormalizeNodeIdOptions = Pick<\n NodeIdOptions,\n | 'allow'\n | 'exclude'\n | 'filter'\n | 'filterInline'\n | 'filterText'\n | 'idCreator'\n | 'idKey'\n>;\n\n/**\n * Normalize node IDs in a value without using editor operations. This is a pure\n * function that returns a new normalized value.\n */\nexport const normalizeNodeId = <V extends Value>(\n value: V,\n options: NormalizeNodeIdOptions = {}\n): V => {\n const {\n allow,\n exclude,\n filter = () => true,\n filterInline = true,\n filterText = true,\n idCreator = () => nanoid(10),\n idKey = 'id',\n } = options;\n\n const normalizeNode = (node: Descendant, path: number[]): Descendant => {\n // Clone the node to avoid mutating the original\n const clonedNode = { ...node };\n\n // Check if we should add ID to this node\n if (\n !clonedNode[idKey] &&\n queryNode([clonedNode, path], {\n allow,\n exclude,\n filter: (entry) => {\n const [node] = entry;\n\n if (filterText && !ElementApi.isElement(node)) {\n return false;\n }\n if (\n filterInline &&\n ElementApi.isElement(node) &&\n // For static normalization, we can't use editor.api.isBlock\n // so we'll assume all elements with children are blocks unless inline is explicitly set\n (node as any).inline === true\n ) {\n return false;\n }\n\n return filter(entry);\n },\n })\n ) {\n clonedNode[idKey] = idCreator();\n }\n\n // Recursively normalize children if it's an element\n if (ElementApi.isElement(clonedNode)) {\n clonedNode.children = clonedNode.children.map((child, index) =>\n normalizeNode(child as Descendant, [...path, index])\n );\n }\n\n return clonedNode;\n };\n\n // Normalize all top-level nodes\n return value.map((node, index) => normalizeNode(node, [index])) as V;\n};\n\nexport type NodeIdConfig = PluginConfig<\n 'nodeId',\n NodeIdOptions,\n {},\n {\n nodeId: {\n normalize: () => void;\n };\n }\n>;\n\n/** @see {@link withNodeId} */\nexport const NodeIdPlugin = createTSlatePlugin<NodeIdConfig>({\n key: 'nodeId',\n options: {\n filterInline: true,\n filterText: true,\n idKey: 'id',\n normalizeInitialValue: false,\n filter: () => true,\n idCreator: () => nanoid(10),\n },\n})\n .extendTransforms(({ editor, getOptions }) => ({\n normalize() {\n const { allow, exclude, filter, filterInline, filterText, idKey } =\n getOptions();\n\n const addNodeId = (entry: [Descendant, number[]]) => {\n const [node, path] = entry;\n\n if (\n !node[idKey!] &&\n queryNode([node, path], {\n allow,\n exclude,\n filter: (entry) => {\n const [node] = entry;\n\n if (filterText && !ElementApi.isElement(node)) {\n return false;\n }\n if (\n filterInline &&\n ElementApi.isElement(node) &&\n !editor.api.isBlock(node)\n ) {\n return false;\n }\n\n return filter!(entry);\n },\n })\n ) {\n // Verify node exists at path before attempting to modify\n const existingNode = editor.api.node(path);\n if (!existingNode) {\n return;\n }\n\n editor.tf.withoutSaving(() => {\n editor.tf.setNodes(\n { [idKey!]: getOptions().idCreator!() },\n { at: path }\n );\n });\n }\n\n // Only traverse children if this is an Element node\n if (ElementApi.isElement(node)) {\n node.children.forEach((child: any, index: number) => {\n addNodeId([child, [...path, index]]);\n });\n }\n };\n\n // Process top-level nodes in place\n editor.children.forEach((node, index) => {\n addNodeId([node, [index]]);\n });\n },\n }))\n .extend({\n normalizeInitialValue: ({ editor, getOptions, tf }) => {\n const { normalizeInitialValue } = getOptions();\n\n // Perf: check if normalization is needed by looking at the first node and last node\n if (!normalizeInitialValue) {\n const firstNode = editor.children[0];\n const lastNode = editor.children.at(-1);\n\n if (firstNode?.id && lastNode?.id) {\n return;\n }\n }\n\n tf.nodeId.normalize();\n },\n })\n .overrideEditor(withNodeId);\n","import type { Descendant, NodeOperation } from '@platejs/slate';\n\nimport type { SlateEditor } from '../editor/SlateEditor';\n\nexport const pipeOnNodeChange = (\n editor: SlateEditor,\n node: Descendant,\n prevNode: Descendant,\n operation: NodeOperation\n) => {\n return editor.meta.pluginCache.handlers.onNodeChange.some((key) => {\n const plugin = editor.getPlugin({ key });\n\n // Skip if plugin not found or readOnly\n if (!plugin || editor.dom?.readOnly) {\n return false;\n }\n\n const handler = plugin.handlers?.onNodeChange;\n if (!handler) {\n return false;\n }\n\n // The custom event handler may return a boolean to specify whether the event\n // shall be treated as being handled or not.\n const shouldTreatEventAsHandled = handler({\n editor,\n node,\n operation,\n plugin,\n prevNode,\n } as any);\n\n if (shouldTreatEventAsHandled != null) {\n return shouldTreatEventAsHandled;\n }\n\n return false;\n });\n};\n","import type { Descendant, TextOperation } from '@platejs/slate';\n\nimport type { SlateEditor } from '../editor/SlateEditor';\n\n// biome-ignore lint/nursery/useMaxParams: All 5 parameters are necessary for text change handling\nexport const pipeOnTextChange = (\n editor: SlateEditor,\n node: Descendant,\n text: string,\n prevText: string,\n operation: TextOperation\n) => {\n return editor.meta.pluginCache.handlers.onTextChange.some((key) => {\n const plugin = editor.getPlugin({ key });\n\n // Skip if plugin not found or readOnly\n if (!plugin || editor.dom?.readOnly) {\n return false;\n }\n\n const handler = plugin.handlers?.onTextChange;\n if (!handler) {\n return false;\n }\n\n // The custom event handler may return a boolean to specify whether the event\n // shall be treated as being handled or not.\n const shouldTreatEventAsHandled = handler({\n editor,\n node,\n operation,\n plugin,\n prevText,\n text,\n } as any);\n\n if (shouldTreatEventAsHandled != null) {\n return shouldTreatEventAsHandled;\n }\n\n return false;\n });\n};\n","const DEFAULT = {\n handlers: true,\n inject: true,\n normalizeInitialValue: false,\n render: true,\n};\n\n/**\n * Check if a plugin feature is disabled in read-only mode based on editOnly\n * configuration.\n *\n * @param plugin The plugin to check\n * @param isReadOnly Whether the editor is in read-only mode\n * @param feature The feature to check ('render' | 'handlers' | 'inject' |\n * 'normalizeInitialValue')\n * @returns True if the feature should be disabled\n */\nexport const isEditOnly = (\n readOnly: boolean,\n plugin: any,\n feature: keyof typeof DEFAULT\n): boolean => {\n if (!readOnly) return false;\n\n // If editOnly is true, use the default value for the feature\n if (plugin.editOnly === true) {\n return DEFAULT[feature];\n }\n\n // If editOnly is an object, use its value if specified, otherwise use default\n if (typeof plugin.editOnly === 'object') {\n return plugin.editOnly[feature] ?? DEFAULT[feature];\n }\n\n return false;\n};\n","import type { SlateEditor } from '../../lib/editor';\n\nimport { getEditorPlugin } from '../../lib/plugin';\nimport { isEditOnly } from './isEditOnlyDisabled';\n\n/** Normalize initial value from editor plugins. Set into plate store if diff. */\nexport const pipeNormalizeInitialValue = (editor: SlateEditor) => {\n const value = editor.meta.isNormalizing;\n\n editor.meta.isNormalizing = true;\n\n editor.meta.pluginCache.normalizeInitialValue.forEach((key) => {\n const p = editor.getPlugin({ key });\n\n if (isEditOnly(editor.dom.readOnly, p, 'normalizeInitialValue')) {\n return;\n }\n\n p.normalizeInitialValue?.({\n ...getEditorPlugin(editor, p),\n value: editor.children,\n } as any);\n });\n\n editor.meta.isNormalizing = value;\n};\n","import type { EditorTransforms, TSelection, Value } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { pipeNormalizeInitialValue } from '../../../../internal/plugin/pipeNormalizeInitialValue';\n\nexport type InitOptions = {\n autoSelect?: boolean | 'end' | 'start';\n selection?: TSelection;\n shouldNormalizeEditor?: boolean;\n value?: any;\n onReady?: (ctx: {\n editor: SlateEditor;\n isAsync: boolean;\n value: Value;\n }) => void;\n};\n\nexport const init = (\n editor: SlateEditor,\n { autoSelect, selection, shouldNormalizeEditor, value, onReady }: InitOptions\n) => {\n const onValueLoaded = (isAsync = false) => {\n if (!editor.children || editor.children?.length === 0) {\n editor.children = editor.api.create.value();\n }\n\n if (selection) {\n editor.selection = selection;\n } else if (autoSelect) {\n const edge = autoSelect === 'start' ? 'start' : 'end';\n const target =\n edge === 'start' ? editor.api.start([]) : editor.api.end([]);\n\n editor.tf.select(target!);\n }\n if (editor.children.length > 0) {\n pipeNormalizeInitialValue(editor);\n }\n if (shouldNormalizeEditor) {\n (editor.tf as EditorTransforms).normalize({ force: true });\n }\n\n // Only trigger React re-render for async initialization\n if (onReady) {\n onReady({ editor, isAsync, value: editor.children });\n }\n };\n\n if (value === null) {\n onValueLoaded();\n } else if (typeof value === 'string') {\n editor.children = editor.api.html.deserialize({\n element: value,\n }) as Value;\n onValueLoaded();\n } else if (typeof value === 'function') {\n const result = value(editor);\n\n // Check if result is a promise (async function)\n if (result && typeof result.then === 'function') {\n result.then((resolvedValue: any) => {\n editor.children = resolvedValue;\n onValueLoaded(true);\n });\n } else {\n // Synchronous function\n editor.children = result;\n onValueLoaded();\n }\n } else if (value) {\n editor.children = value;\n onValueLoaded();\n } else {\n onValueLoaded();\n }\n};\n","import {\n type EditorAboveOptions,\n combineMatchOptions,\n PathApi,\n} from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { getPluginByType } from '../../../plugin/getSlatePlugin';\n\nexport type InsertExitBreakOptions = {\n match?: EditorAboveOptions['match'];\n reverse?: boolean;\n};\n\n/**\n * Exits the current block structure by creating a new block next to the\n * appropriate ancestor.\n *\n * This function automatically determines the exit point by finding the first\n * ancestor that doesn't have strict sibling constraints (`isStrictSiblings:\n * false`), allowing standard text blocks to be inserted as siblings.\n *\n * For example:\n *\n * - In `column_group > column > codeblock > codeline`, exits after `codeblock`,\n * then after `column_group`\n * - In `table > tr > td > p`, exits after `table`\n */\nexport const insertExitBreak = (\n editor: SlateEditor,\n { match, reverse }: InsertExitBreakOptions = {}\n) => {\n if (!editor.selection || !editor.api.isCollapsed()) return;\n\n const block = editor.api.block();\n\n if (!block) return;\n\n // Find the nearest ancestor that allows arbitrary block siblings (isStrictSiblings: false)\n // We traverse up the tree until we find an element that can have paragraph siblings\n const target = editor.api.above({\n at: block[1],\n match: combineMatchOptions(\n editor,\n (n, p) =>\n p.length === 1 ||\n (p.length > 1 &&\n !!n.type &&\n !getPluginByType(editor, n.type as string)?.node.isStrictSiblings),\n { match }\n ),\n });\n\n const ancestorPath = target?.[1] ?? block[1];\n\n const targetPath = reverse ? ancestorPath : PathApi.next(ancestorPath);\n\n if (!targetPath) return;\n\n editor.tf.insertNodes(editor.api.create.block(), {\n at: targetPath,\n select: true,\n });\n\n return true;\n};\n","import { type Path, NodeApi } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { BaseParagraphPlugin } from '../../paragraph';\n\n/**\n * Reset the current block to a paragraph, removing all properties except id and\n * type.\n */\nexport const resetBlock = (editor: SlateEditor, { at }: { at?: Path } = {}) => {\n const entry = editor.api.block({ at });\n if (!entry?.[0]) return;\n\n const [block, path] = entry;\n\n editor.tf.withoutNormalizing(() => {\n // Extract only id and type, unset all other properties\n const { id, type, ...otherProps } = NodeApi.extractProps(block);\n\n // Unset all properties except id and type\n Object.keys(otherProps).forEach((key) => {\n editor.tf.unsetNodes(key, { at: path });\n });\n\n const paragraphType = editor.getType(BaseParagraphPlugin.key);\n\n if (block.type !== paragraphType) {\n // Set the new type to paragraph\n editor.tf.setNodes({ type: paragraphType }, { at: path });\n }\n });\n\n return true;\n};\n","import type { Descendant, EditorTransforms, Value } from '@platejs/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nexport const setValue = <V extends Value>(\n editor: SlateEditor,\n value?: V | string\n) => {\n let children: Descendant[] = value as any;\n\n if (typeof value === 'string') {\n children = editor.api.html.deserialize({\n element: value,\n });\n } else if (!value || value.length === 0) {\n children = editor.api.create.value();\n }\n\n (editor.tf as EditorTransforms).replaceNodes(children, {\n at: [],\n children: true,\n });\n};\n","import {\n type Descendant,\n type NodeOperation,\n type TextOperation,\n type TText,\n NodeApi,\n OperationApi,\n PathApi,\n} from '@platejs/slate';\nimport { type OmitFirst, bindFirst } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../editor';\nimport type { PluginConfig } from '../../plugin';\n\nimport { createTSlatePlugin } from '../../plugin';\nimport { pipeOnNodeChange } from '../../utils/pipeOnNodeChange';\nimport { pipeOnTextChange } from '../../utils/pipeOnTextChange';\nimport { init } from './transforms/init';\nimport { insertExitBreak } from './transforms/insertExitBreak';\nimport { resetBlock } from './transforms/resetBlock';\nimport { setValue } from './transforms/setValue';\n\nexport type SlateExtensionConfig = PluginConfig<\n 'slateExtension',\n {\n onNodeChange: (options: {\n editor: SlateEditor;\n node: Descendant;\n operation: NodeOperation;\n prevNode: Descendant;\n }) => void;\n onTextChange: (options: {\n editor: SlateEditor;\n node: Descendant;\n operation: TextOperation;\n prevText: string;\n text: string;\n }) => void;\n },\n {},\n {\n init: OmitFirst<typeof init>;\n insertExitBreak: OmitFirst<typeof insertExitBreak>;\n resetBlock: OmitFirst<typeof resetBlock>;\n setValue: OmitFirst<typeof setValue>;\n }\n>;\n\n/** Opinionated extension of slate default behavior. */\nexport const SlateExtensionPlugin = createTSlatePlugin<SlateExtensionConfig>({\n key: 'slateExtension',\n options: {\n onNodeChange: () => {},\n onTextChange: () => {},\n },\n}).extendEditorTransforms(({ editor, getOption, tf: { apply } }) => ({\n /**\n * Initialize the editor value, selection and normalization. Set `value` to\n * `null` to skip children initialization.\n */\n init: bindFirst(init, editor),\n insertExitBreak: bindFirst(insertExitBreak, editor),\n resetBlock: bindFirst(resetBlock, editor),\n setValue: bindFirst(setValue, editor),\n apply(operation) {\n // Performance optimization: skip state capture if no handlers are registered\n const noop = () => {};\n const hasNodeHandlers =\n editor.meta.pluginCache.handlers.onNodeChange.length > 0 ||\n getOption('onNodeChange') !== noop;\n const hasTextHandlers =\n editor.meta.pluginCache.handlers.onTextChange.length > 0 ||\n getOption('onTextChange') !== noop;\n\n if (!hasNodeHandlers && !hasTextHandlers) {\n apply(operation);\n return;\n }\n\n let prevNode: Descendant | undefined;\n let node: Descendant | undefined;\n let prevText: string | undefined;\n let text: string | undefined;\n let parentNode: Descendant | undefined;\n\n if (OperationApi.isNodeOperation(operation) && hasNodeHandlers) {\n // Get node states BEFORE applying the operation\n switch (operation.type) {\n case 'insert_node': {\n // Both are the new node being inserted\n prevNode = operation.node;\n node = operation.node;\n break;\n }\n\n case 'merge_node':\n case 'move_node':\n case 'set_node':\n case 'split_node': {\n // Get the node before the operation\n prevNode = NodeApi.get(editor, operation.path);\n break;\n }\n case 'remove_node': {\n // Both are the node being removed\n prevNode = operation.node;\n node = operation.node;\n break;\n }\n }\n } else if (OperationApi.isTextOperation(operation) && hasTextHandlers) {\n // Get parent node that contains the text\n const parentPath = PathApi.parent(operation.path);\n parentNode = NodeApi.get<Descendant>(editor, parentPath);\n\n // Get text node before operation\n const textNode = NodeApi.get<TText>(editor, operation.path)!;\n prevText = textNode.text;\n }\n\n // Apply the operation\n apply(operation);\n\n // Get AFTER state for operations where node changes\n if (OperationApi.isNodeOperation(operation) && hasNodeHandlers) {\n switch (operation.type) {\n case 'insert_node':\n case 'remove_node': {\n // Already set above, keep the same\n break;\n }\n\n case 'merge_node': {\n // Get the merged result (at previous path)\n const prevPath = PathApi.previous(operation.path);\n\n if (prevPath) {\n node = NodeApi.get(editor, prevPath);\n }\n\n break;\n }\n\n case 'move_node': {\n // Get node at new location\n node = NodeApi.get(editor, operation.newPath);\n break;\n }\n\n case 'set_node': {\n // Get the updated node\n node = NodeApi.get(editor, operation.path);\n break;\n }\n\n case 'split_node': {\n // Get the first part of the split\n node = NodeApi.get(editor, operation.path);\n break;\n }\n }\n\n // Ensure node is set (fallback to prevNode if needed)\n if (!node) {\n node = prevNode;\n }\n\n // Call handlers - both node and prevNode are guaranteed to be defined\n const eventIsHandled = pipeOnNodeChange(\n editor,\n node!,\n prevNode!,\n operation\n );\n\n if (!eventIsHandled) {\n const onNodeChange = getOption('onNodeChange');\n onNodeChange({ editor, node: node!, operation, prevNode: prevNode! });\n }\n }\n\n // Handle text operations\n if (OperationApi.isTextOperation(operation) && hasTextHandlers) {\n const textNodeAfter = NodeApi.get<TText>(editor, operation.path);\n if (textNodeAfter) {\n text = textNodeAfter.text;\n }\n\n const eventIsHandled = pipeOnTextChange(\n editor,\n parentNode!,\n text!,\n prevText!,\n operation\n );\n\n if (!eventIsHandled) {\n const onTextChange = getOption('onTextChange');\n onTextChange({\n editor,\n node: parentNode!,\n operation,\n prevText: prevText!,\n text: text!,\n });\n }\n }\n },\n}));\n","import {\n type Descendant,\n type Editor,\n ElementApi,\n TextApi,\n} from '@platejs/slate';\n\nimport type { SlateEditor } from '../editor';\nimport type { WithRequiredKey } from '../plugin';\n\nimport { BaseParagraphPlugin } from '../plugins';\n\nconst isInlineNode = (editor: Editor) => (node: Descendant) =>\n TextApi.isText(node) ||\n (ElementApi.isElement(node) && editor.api.isInline(node));\n\nconst makeBlockLazy = (type: string) => (): Descendant => ({\n children: [],\n type,\n});\n\nconst hasDifferentChildNodes = (\n descendants: Descendant[],\n isInline: (node: Descendant) => boolean\n): boolean =>\n descendants.some((descendant, index, arr) => {\n const prevDescendant = arr[index - 1];\n\n if (index !== 0) {\n return isInline(descendant) !== isInline(prevDescendant);\n }\n\n return false;\n });\n\n/**\n * Handles 3rd constraint: \"Block nodes can only contain other blocks, or inline\n * and text nodes.\"\n */\nconst normalizeDifferentNodeTypes = (\n descendants: Descendant[],\n isInline: (node: Descendant) => boolean,\n makeDefaultBlock: () => Descendant\n): Descendant[] => {\n const hasDifferentNodes = hasDifferentChildNodes(descendants, isInline);\n\n const { fragment } = descendants.reduce(\n (memo, node) => {\n if (hasDifferentNodes && isInline(node)) {\n let block = memo.precedingBlock;\n\n if (!block) {\n block = makeDefaultBlock();\n memo.precedingBlock = block;\n memo.fragment.push(block);\n }\n\n (block.children as Descendant[]).push(node);\n } else {\n memo.fragment.push(node);\n memo.precedingBlock = null;\n }\n\n return memo;\n },\n {\n fragment: [] as Descendant[],\n precedingBlock: null as Descendant | null,\n }\n );\n\n return fragment;\n};\n\n/**\n * Handles 1st constraint: \"All Element nodes must contain at least one Text\n * descendant.\"\n */\nconst normalizeEmptyChildren = (descendants: Descendant[]): Descendant[] => {\n if (descendants.length === 0) {\n return [{ text: '' } as Descendant];\n }\n\n return descendants;\n};\n\nconst normalize = (\n descendants: Descendant[],\n isInline: (node: Descendant) => boolean,\n makeDefaultBlock: () => Descendant\n): Descendant[] => {\n // biome-ignore lint/style/noParameterAssign: Sequential transformation pipeline pattern\n descendants = normalizeEmptyChildren(descendants);\n // biome-ignore lint/style/noParameterAssign: Sequential transformation pipeline pattern\n descendants = normalizeDifferentNodeTypes(\n descendants,\n isInline,\n makeDefaultBlock\n );\n\n // biome-ignore lint/style/noParameterAssign: Sequential transformation pipeline pattern\n descendants = descendants.map((node) => {\n if (ElementApi.isElement(node)) {\n return {\n ...node,\n children: normalize(\n node.children as Descendant[],\n isInline,\n makeDefaultBlock\n ),\n };\n }\n\n return node;\n });\n\n return descendants;\n};\n\n/** Normalize the descendants to a valid document fragment. */\nexport const normalizeDescendantsToDocumentFragment = (\n editor: SlateEditor,\n {\n defaultElementPlugin = BaseParagraphPlugin,\n descendants,\n }: { descendants: Descendant[]; defaultElementPlugin?: WithRequiredKey }\n): Descendant[] => {\n const isInline = isInlineNode(editor);\n const defaultType = editor.getType(defaultElementPlugin.key);\n const makeDefaultBlock = makeBlockLazy(defaultType);\n\n return normalize(descendants, isInline, makeDefaultBlock as any);\n};\n","import type { SlateEditor } from '../editor';\nimport type { ParserOptions } from '../plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../plugin';\n\n/** Is the plugin disabled by another plugin. */\nexport const pipeInsertDataQuery = (\n editor: SlateEditor,\n plugins: Partial<AnyEditorPlugin>[],\n options: ParserOptions\n) =>\n plugins.every((p) => {\n const query = p.parser?.query;\n\n return (\n !query ||\n query({\n ...getEditorPlugin(editor, p as any),\n ...options,\n })\n );\n });\n","import { pipeInsertFragment } from '../../internal/plugin/pipeInsertFragment';\nimport { pipeTransformData } from '../../internal/plugin/pipeTransformData';\nimport { pipeTransformFragment } from '../../internal/plugin/pipeTransformFragment';\nimport { type Parser, createSlatePlugin, getEditorPlugin } from '../plugin';\nimport { getInjectedPlugins } from '../utils';\nimport { pipeInsertDataQuery } from '../utils/pipeInsertDataQuery';\n\nexport const ParserPlugin = createSlatePlugin({\n key: 'parser',\n}).overrideEditor(({ editor, tf: { insertData } }) => ({\n transforms: {\n insertData(dataTransfer: DataTransfer) {\n const inserted = [...editor.meta.pluginList].reverse().some((plugin) => {\n const parser = plugin.parser as Parser | undefined;\n\n if (!parser) return false;\n\n const injectedPlugins = getInjectedPlugins(editor, plugin);\n const { deserialize, format, mimeTypes } = parser;\n\n if (!format && !mimeTypes) return false;\n\n // Handle both string and string[] formats\n const formats = Array.isArray(format) ? format : format ? [format] : [];\n const mimeTypeList =\n mimeTypes ||\n formats.map((fmt) => (fmt.includes('/') ? fmt : `text/${fmt}`));\n\n for (const mimeType of mimeTypeList) {\n let data = dataTransfer.getData(mimeType);\n\n if (\n (mimeType !== 'Files' && !data) ||\n (mimeType === 'Files' && dataTransfer.files.length === 0)\n )\n continue;\n if (\n !pipeInsertDataQuery(editor, injectedPlugins, {\n data,\n dataTransfer,\n mimeType,\n })\n ) {\n continue;\n }\n\n data = pipeTransformData(editor, injectedPlugins, {\n data,\n dataTransfer,\n mimeType,\n });\n\n let fragment = deserialize?.({\n ...getEditorPlugin(editor, plugin),\n data,\n dataTransfer,\n mimeType,\n });\n\n if (!fragment?.length) continue;\n\n fragment = pipeTransformFragment(editor, injectedPlugins, {\n data,\n dataTransfer,\n fragment,\n mimeType,\n });\n\n if (fragment.length === 0) continue;\n\n pipeInsertFragment(editor, injectedPlugins, {\n data,\n dataTransfer,\n fragment,\n mimeType,\n });\n\n return true;\n }\n\n return false;\n });\n\n if (inserted) return;\n\n insertData(dataTransfer);\n },\n },\n}));\n","import type { AnyPluginConfig, PluginConfig } from '../plugin/BasePlugin';\nimport type { SlatePlugin } from '../plugin/SlatePlugin';\n\nimport { AstPlugin } from './AstPlugin';\nimport { HistoryPlugin } from './HistoryPlugin';\nimport { OverridePlugin } from './override/OverridePlugin';\nimport { ParserPlugin } from './ParserPlugin';\nimport { type DebugErrorType, type LogLevel, DebugPlugin } from './debug';\nimport { DOMPlugin } from './dom';\nimport { HtmlPlugin } from './html';\nimport { LengthPlugin } from './length';\nimport { AffinityPlugin } from './affinity';\nimport { type NodeIdConfig, NodeIdPlugin } from './node-id/NodeIdPlugin';\nimport { BaseParagraphPlugin } from './paragraph';\nimport {\n type SlateExtensionConfig,\n SlateExtensionPlugin,\n} from './slate-extension';\nimport { type ChunkingConfig, ChunkingPlugin } from './chunking/ChunkingPlugin';\n\nexport type CorePlugin = ReturnType<typeof getCorePlugins>[number];\n\nexport type GetCorePluginsOptions = {\n /** Enable mark/element affinity. */\n affinity?: boolean;\n /** Configure Slate's chunking optimization. */\n chunking?: ChunkingConfig['options'] | boolean;\n /** Specifies the maximum number of characters allowed in the editor. */\n maxLength?: number;\n /** Configure the node id plugin. */\n nodeId?: NodeIdConfig['options'] | boolean;\n /** Override the core plugins using the same key. */\n plugins?: AnyPluginConfig[];\n};\n\nexport const getCorePlugins = ({\n affinity,\n chunking,\n maxLength,\n nodeId,\n plugins = [],\n}: GetCorePluginsOptions) => {\n // Disable nodeId by default in test environment for deterministic tests\n let resolvedNodeId: any = nodeId;\n if (process.env.NODE_ENV === 'test' && nodeId === undefined) {\n resolvedNodeId = false;\n }\n\n let corePlugins = [\n DebugPlugin as SlatePlugin<DebugConfig>,\n SlateExtensionPlugin,\n DOMPlugin,\n HistoryPlugin,\n OverridePlugin,\n ParserPlugin,\n maxLength\n ? LengthPlugin.configure({ options: { maxLength } })\n : LengthPlugin,\n HtmlPlugin,\n AstPlugin,\n NodeIdPlugin.configure({\n enabled: resolvedNodeId !== false,\n options: resolvedNodeId === false ? undefined : resolvedNodeId,\n }),\n AffinityPlugin.configure({ enabled: affinity }),\n BaseParagraphPlugin,\n ChunkingPlugin.configure({\n enabled: chunking !== false,\n options: typeof chunking === 'boolean' ? undefined : chunking,\n }),\n ];\n\n // Create a map for quick lookup of custom plugins\n const customPluginsMap = new Map(\n plugins.map((plugin) => [plugin.key, plugin])\n );\n\n // Replace core plugins with custom plugins if they exist and remove them from plugins\n corePlugins = corePlugins.map((corePlugin) => {\n const customPlugin = customPluginsMap.get(corePlugin.key);\n\n if (customPlugin) {\n // Remove the custom plugin from the plugins array\n const index = plugins.findIndex((p) => p.key === corePlugin.key);\n\n if (index !== -1) {\n plugins.splice(index, 1);\n }\n\n return customPlugin;\n }\n\n return corePlugin as any;\n });\n\n return corePlugins;\n};\n\nexport type CorePluginTransforms = SlateExtensionConfig['transforms'];\nexport type CorePluginApi = SlateExtensionConfig['api'];\n\nexport type DebugConfig = PluginConfig<\n 'debug',\n {\n isProduction: boolean;\n logger: Partial<Record<LogLevel, LogFunction>>;\n logLevel: LogLevel;\n throwErrors: boolean;\n },\n {\n debug: {\n error: (\n message: string | unknown,\n type?: DebugErrorType,\n details?: any\n ) => void;\n info: (message: string, type?: DebugErrorType, details?: any) => void;\n log: (message: string, type?: DebugErrorType, details?: any) => void;\n warn: (message: string, type?: DebugErrorType, details?: any) => void;\n };\n }\n>;\n\nexport type LengthConfig = PluginConfig<\n 'length',\n {\n maxLength: number;\n }\n>;\n\ntype LogFunction = (\n message: string,\n type?: DebugErrorType,\n details?: any\n) => void;\n","import {\n type Editor,\n type TSelection,\n type Value,\n createEditor,\n} from '@platejs/slate';\nimport { nanoid } from 'nanoid';\n\nimport type { PluginStoreFactory } from '../../internal/plugin/resolvePlugins';\nimport type { AnyPluginConfig, NodeComponents } from '../plugin/BasePlugin';\nimport type { AnySlatePlugin } from '../plugin/SlatePlugin';\nimport type { ChunkingConfig } from '../plugins/chunking';\nimport type { NodeIdConfig } from '../plugins/node-id/NodeIdPlugin';\nimport type { InferPlugins, SlateEditor, TSlateEditor } from './SlateEditor';\n\nimport { resolvePlugins } from '../../internal/plugin/resolvePlugins';\nimport { createSlatePlugin } from '../plugin/createSlatePlugin';\nimport { getPluginType, getSlatePlugin } from '../plugin/getSlatePlugin';\nimport { type CorePlugin, getCorePlugins } from '../plugins/getCorePlugins';\n\nexport type BaseWithSlateOptions<P extends AnyPluginConfig = CorePlugin> = {\n /**\n * Unique identifier for the editor instance.\n *\n * @default nanoid()\n */\n id?: string;\n /**\n * Current user ID for collaborative features (e.g., Yjs). Used to identify\n * the creator of elements like combobox inputs.\n */\n userId?: string | null;\n /**\n * Determines which mark/element to apply at boundaries between different\n * marks, based on cursor movement using the left/right arrow keys.\n *\n * Example: <text bold>Bold</text><cursor><text italic>Italic</text>\n *\n * If the cursor moved here from the left (via → key), typing applies\n * **bold**.\n *\n * If the cursor moved here from the right (via ← key), typing applies\n * _italic_.\n *\n * Without mark affinity, the preceding mark (**bold**) is always applied\n * regardless of direction.\n *\n * @default true\n */\n affinity?: boolean;\n /**\n * Select the editor after initialization.\n *\n * @default false\n *\n * - `true` | 'end': Select the end of the editor\n * - `false`: Do not select anything\n * - `'start'`: Select the start of the editor\n */\n autoSelect?: boolean | 'end' | 'start';\n /**\n * Configure Slate's chunking optimization, which reduces latency while\n * typing. Set to `false` to disable.\n *\n * @default true\n * @see https://docs.slatejs.org/walkthroughs/09-performance\n */\n chunking?: ChunkingConfig['options'] | boolean;\n /** Specifies the component for each plugin key. */\n components?: NodeComponents;\n /** Specifies the component for each plugin key. */\n // components?: Partial<\n // Record<KeyofNodePlugins<InferPlugins<P[]>>, NodeComponent | null>\n // >;\n /**\n * Specifies the maximum number of characters allowed in the editor. When the\n * limit is reached, further input will be prevented.\n */\n maxLength?: number;\n /**\n * Configuration for automatic node ID generation and management.\n *\n * Unless set to `false`, the editor automatically adds unique IDs to nodes\n * through the core NodeIdPlugin:\n *\n * - Normalizes the initial value for missing IDs\n * - Adds IDs to new nodes during insertion\n * - Preserves or reuses IDs on undo/redo and copy/paste operations\n * - Handles ID conflicts and duplicates\n *\n * @default { idKey: 'id', filterInline: true, filterText: true, idCreator: () => nanoid(10) }\n */\n nodeId?: NodeIdConfig['options'] | boolean;\n /**\n * Factory used to create the per-plugin options store\n *\n * @default createVanillaStore from zustand-x/vanilla\n */\n optionsStoreFactory?: PluginStoreFactory;\n // override?: {\n // components?: Partial<\n // Record<KeyofNodePlugins<InferPlugins<P[]>>, NodeComponent | null>\n // >;\n // };\n /**\n * Array of plugins to be loaded into the editor. Plugins extend the editor's\n * functionality and define custom behavior.\n */\n plugins?: P[];\n /**\n * Editor read-only initial state. For dynamic read-only control, use the\n * `Plate.readOnly` prop instead.\n *\n * @default false\n */\n readOnly?: boolean;\n /**\n * Initial selection state for the editor. Defines where the cursor should be\n * positioned when the editor loads.\n */\n selection?: TSelection;\n /**\n * When `true`, normalizes the initial `value` passed to the editor. This is\n * useful when adding normalization rules to already existing content or when\n * the initial value might not conform to the current schema.\n *\n * Note: Normalization may take time for large documents.\n *\n * @default false\n */\n shouldNormalizeEditor?: boolean;\n /**\n * When `true`, skips the initial value, selection, and normalization logic.\n * Useful when the editor state is managed externally (e.g., with Yjs\n * collaboration) or when you want to manually control the initialization\n * process.\n *\n * @default false\n */\n skipInitialization?: boolean;\n};\n\nexport type WithSlateOptions<\n V extends Value = Value,\n P extends AnyPluginConfig = CorePlugin,\n> = BaseWithSlateOptions<P> &\n Pick<\n Partial<AnySlatePlugin>,\n | 'api'\n | 'decorate'\n | 'extendEditor'\n | 'inject'\n | 'normalizeInitialValue'\n | 'options'\n | 'override'\n | 'transforms'\n > & {\n // override?: {\n // /** Enable or disable plugins */\n // enabled?: Partial<Record<KeyofPlugins<InferPlugins<P[]>>, boolean>>;\n // plugins?: Partial<\n // Record<\n // KeyofPlugins<InferPlugins<P[]>>,\n // PartialEditorPlugin<AnyPluginConfig>\n // >\n // >;\n // };\n /**\n * Initial content for the editor.\n *\n * Can be:\n *\n * - A static value (array of nodes)\n * - An HTML string that will be deserialized\n * - A function that returns a value or Promise<value>\n * - `null` for an empty editor\n *\n * @default [{ type: 'p'; children: [{ text: '' }] }]\n */\n value?: ((editor: SlateEditor) => Promise<V> | V) | V | string | null;\n /** Function to configure the root plugin */\n rootPlugin?: (plugin: AnySlatePlugin) => AnySlatePlugin;\n /**\n * Callback called when the editor is ready (after initialization\n * completes).\n */\n onReady?: (ctx: {\n editor: SlateEditor;\n isAsync: boolean;\n value: V;\n }) => void;\n };\n\n/**\n * Applies Plate enhancements to an editor instance (non-React version).\n *\n * @remarks\n * This function supports server-side usage as it doesn't include React-specific\n * features like component rendering or hooks integration.\n * @see {@link createSlateEditor} for a higher-level non-React editor creation function.\n * @see {@link createPlateEditor} for a React-specific version of editor creation.\n * @see {@link usePlateEditor} for a memoized React version.\n * @see {@link withPlate} for the React-specific enhancement function.\n */\nexport const withSlate = <\n V extends Value = Value,\n P extends AnyPluginConfig = CorePlugin,\n>(\n e: Editor,\n {\n id,\n affinity = true,\n autoSelect,\n chunking = true,\n maxLength,\n nodeId,\n optionsStoreFactory,\n plugins = [],\n readOnly = false,\n rootPlugin,\n selection,\n shouldNormalizeEditor,\n skipInitialization,\n userId,\n value,\n onReady,\n ...pluginConfig\n }: WithSlateOptions<V, P> = {}\n): TSlateEditor<V, InferPlugins<P[]>> => {\n const editor = e as SlateEditor;\n\n editor.id = id ?? editor.id ?? nanoid();\n editor.meta.key = editor.meta.key ?? nanoid();\n editor.meta.isFallback = false;\n editor.meta.userId = userId;\n editor.dom = {\n composing: false,\n currentKeyboardEvent: null,\n focused: false,\n prevSelection: null,\n readOnly,\n };\n\n editor.getApi = () => editor.api as any;\n editor.getTransforms = () => editor.transforms as any;\n editor.getPlugin = (plugin) => getSlatePlugin(editor, plugin) as any;\n editor.getType = (pluginKey) => getPluginType(editor, pluginKey);\n editor.getInjectProps = (plugin) => {\n const nodeProps =\n editor.getPlugin<AnySlatePlugin>(plugin).inject?.nodeProps ?? ({} as any);\n\n nodeProps.nodeKey = nodeProps.nodeKey ?? editor.getType(plugin.key);\n nodeProps.styleKey = nodeProps.styleKey ?? nodeProps.nodeKey;\n\n return nodeProps;\n };\n editor.getOptionsStore = (plugin) => editor.getPlugin(plugin).optionsStore;\n editor.getOptions = (plugin) => {\n const store = editor.getOptionsStore(plugin);\n\n if (!store) return editor.getPlugin(plugin).options;\n\n return editor.getOptionsStore(plugin).get('state');\n };\n editor.getOption = (plugin, key, ...args) => {\n const store = editor.getOptionsStore(plugin);\n\n if (!store) return editor.getPlugin(plugin).options[key];\n\n if (!(key in store.get('state')) && !(key in store.selectors)) {\n editor.api.debug.error(\n `editor.getOption: ${key as string} option is not defined in plugin ${plugin.key}.`,\n 'OPTION_UNDEFINED'\n );\n return;\n }\n\n return (store.get as any)(key, ...args);\n };\n editor.setOption = (plugin: any, key: any, ...args: any) => {\n const store = editor.getOptionsStore(plugin);\n\n if (!store) return;\n\n if (!(key in store.get('state'))) {\n editor.api.debug.error(\n `editor.setOption: ${key} option is not defined in plugin ${plugin.key}.`,\n 'OPTION_UNDEFINED'\n );\n return;\n }\n\n (store.set as any)(key, ...args);\n };\n editor.setOptions = (plugin: any, options: any) => {\n const store = editor.getOptionsStore(plugin);\n\n if (!store) return;\n if (typeof options === 'object') {\n store.set('state', (draft: any) => {\n Object.assign(draft, options);\n });\n } else if (typeof options === 'function') {\n store.set('state', options);\n }\n };\n\n // Plugin initialization code\n const corePlugins = getCorePlugins({\n affinity,\n chunking,\n maxLength,\n nodeId,\n plugins,\n });\n\n let rootPluginInstance = createSlatePlugin({\n key: 'root',\n priority: 10_000,\n ...pluginConfig,\n override: {\n ...pluginConfig.override,\n components: {\n ...pluginConfig.components,\n ...pluginConfig.override?.components,\n },\n },\n plugins: [...corePlugins, ...plugins],\n });\n\n // Apply rootPlugin configuration if provided\n if (rootPlugin) {\n rootPluginInstance = rootPlugin(rootPluginInstance) as any;\n }\n\n resolvePlugins(editor, [rootPluginInstance], optionsStoreFactory);\n\n /** Ignore normalizeNode overrides if shouldNormalizeNode returns false */\n const normalizeNode = editor.tf.normalizeNode;\n editor.tf.normalizeNode = (...args) => {\n if (!editor.api.shouldNormalizeNode(args[0])) {\n return;\n }\n\n return normalizeNode(...args);\n };\n editor.normalizeNode = editor.tf.normalizeNode;\n\n if (!skipInitialization) {\n editor.tf.init({\n autoSelect,\n selection,\n shouldNormalizeEditor,\n value,\n onReady: onReady as any,\n });\n }\n\n return editor as any;\n};\n\nexport type CreateSlateEditorOptions<\n V extends Value = Value,\n P extends AnyPluginConfig = CorePlugin,\n> = WithSlateOptions<V, P> & {\n /**\n * Initial editor to be extended with `withSlate`.\n *\n * @default createEditor()\n */\n editor?: Editor;\n};\n\n/**\n * Creates a Slate editor (non-React version).\n *\n * This function creates a fully configured Plate editor instance that can be\n * used in non-React environments or server-side contexts. It applies all the\n * specified plugins and configurations to create a functional editor.\n *\n * Examples:\n *\n * ```ts\n * const editor = createSlateEditor({\n * plugins: [ParagraphPlugin, HeadingPlugin],\n * value: [{ type: 'p', children: [{ text: 'Hello world!' }] }],\n * });\n *\n * // Editor with custom configuration\n * const editor = createSlateEditor({\n * plugins: [ParagraphPlugin],\n * maxLength: 1000,\n * nodeId: { idCreator: () => uuidv4() },\n * autoSelect: 'end',\n * });\n *\n * // Server-side editor\n * const editor = createSlateEditor({\n * plugins: [ParagraphPlugin],\n * value: '<p>HTML content</p>',\n * skipInitialization: true,\n * });\n * ```\n *\n * @see {@link createPlateEditor} for a React-specific version of editor creation.\n * @see {@link usePlateEditor} for a memoized React version.\n * @see {@link withSlate} for the underlying function that applies Slate enhancements to an editor.\n */\nexport const createSlateEditor = <\n V extends Value = Value,\n P extends AnyPluginConfig = CorePlugin,\n>({\n editor = createEditor(),\n ...options\n}: CreateSlateEditorOptions<V, P> = {}) => withSlate<V, P>(editor, options);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAgBA,WAAWC,OAA+B;AACxD,QAAO,OAAOA,UAAU;;;;;ACG1B,SAAgBI,aAAgBC,YAAe,GAAGE,eAAyB;AACzE,QAAOL,UACL,EAAE,EACFG,YACA,GAAGE,gBACFC,UAAmBC,UAAmBC,QAA2B;AAEhE,MAAIC,MAAMC,QAAQH,SAAS,CACzB,QAAOA;AAGT,MAAIC,QAAQ,UACV,QAAO;GAAE,GAAIF;GAAkB,GAAIC;GAAkB;GAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuEH,SAAgByB,kBAOdC,SAEuC,EAAE,EACC;CAC1C,IAAIE;CACJ,IAAIC;AAEJ,KAAIjB,WAAWc,OAAO,EAAE;AACtBE,eAAa,EAAEE,KAAK,IAAS;AAC7BD,sBAAoBF,WAAgBD,OAAOC,OAAO;OAElDC,cAAaF;CAGf,MAAMI,MAAMF,WAAWE,OAAO;CAE9B,MAAMC,SAASlB,aACb;EACEiB;EACAE,iBAAiB,EAAE;EACnBC,iBAAiB;EACjBC,cAAcL,mBAAmB,CAACA,iBAAiB,GAAG,EA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