@contember/react-slate-editor-base 2.0.0-alpha.32 → 2.0.0-alpha.36
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/dist/development/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/development/src/components/RichTextEditor.js.map +1 -1
- package/dist/development/src/components/triggers/EditorElementTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorElementTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorGenericTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorGenericTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorMarkTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorMarkTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorWrapNodeTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorWrapNodeTrigger.js.map +1 -1
- package/dist/development/src/editor/createEditor.cjs.map +1 -1
- package/dist/development/src/editor/createEditor.js.map +1 -1
- package/dist/development/src/editor/createEditorWithEssentials.cjs.map +1 -1
- package/dist/development/src/editor/createEditorWithEssentials.js.map +1 -1
- package/dist/development/src/editor/index.cjs.map +1 -1
- package/dist/development/src/editor/methods/addMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/addMarks.js.map +1 -1
- package/dist/development/src/editor/methods/canToggleMark.cjs.map +1 -1
- package/dist/development/src/editor/methods/canToggleMark.js.map +1 -1
- package/dist/development/src/editor/methods/closest.cjs.map +1 -1
- package/dist/development/src/editor/methods/closest.js.map +1 -1
- package/dist/development/src/editor/methods/closestBlockEntry.cjs.map +1 -1
- package/dist/development/src/editor/methods/ejectElement.cjs.map +1 -1
- package/dist/development/src/editor/methods/ejectElement.js.map +1 -1
- package/dist/development/src/editor/methods/getElementDataAttributes.cjs.map +1 -1
- package/dist/development/src/editor/methods/getElementDataAttributes.js.map +1 -1
- package/dist/development/src/editor/methods/getPreviousSibling.cjs.map +1 -1
- package/dist/development/src/editor/methods/getPreviousSibling.js.map +1 -1
- package/dist/development/src/editor/methods/hasMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/hasMarks.js.map +1 -1
- package/dist/development/src/editor/methods/hasParentOfType.cjs.map +1 -1
- package/dist/development/src/editor/methods/hasParentOfType.js.map +1 -1
- package/dist/development/src/editor/methods/isElementType.cjs.map +1 -1
- package/dist/development/src/editor/methods/isElementType.js.map +1 -1
- package/dist/development/src/editor/methods/permissivelyDeserializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/permissivelyDeserializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/removeMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/removeMarks.js.map +1 -1
- package/dist/development/src/editor/methods/serializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/serializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/strictlyDeserializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/strictlyDeserializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/toLatestFormat.cjs.map +1 -1
- package/dist/development/src/editor/methods/toLatestFormat.js.map +1 -1
- package/dist/development/src/internal/components/DefaultElement.cjs.map +1 -1
- package/dist/development/src/internal/components/DefaultElement.js.map +1 -1
- package/dist/development/src/internal/hooks/useRichTextFieldNodes.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useRichTextFieldNodes.js.map +1 -1
- package/dist/development/src/internal/utils/EditorPasteUtils.cjs.map +1 -1
- package/dist/development/src/internal/utils/EditorPasteUtils.js.map +1 -1
- package/dist/development/src/internal/utils/parseUrl.cjs.map +1 -1
- package/dist/development/src/internal/utils/parseUrl.js.map +1 -1
- package/dist/development/src/plugins/attributes/alignment/alignButton.cjs.map +1 -1
- package/dist/development/src/plugins/attributes/alignment/alignButton.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/HtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/HtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/createMarkHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/createMarkHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/withPaste.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/withPaste.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorElement.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorModifications.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorModifications.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/withAnchors.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/withAnchors.js.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingElement.js.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/headings/withHeadings.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/withHeadings.js.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/HorizontalRuleElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/HorizontalRuleElement.js.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/withHorizontalRules.cjs.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/withHorizontalRules.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListItemElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListItemElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/OrderedListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/UnorderedListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/dedentListItem.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/dedentListItem.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/indentListItem.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/indentListItem.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/normalizeListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/normalizeListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/toggleListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/toggleListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/withLists.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/withLists.js.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/ParagraphElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/ParagraphElement.js.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/withParagraphs.cjs.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/withParagraphs.js.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/ScrollTargetElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/ScrollTargetElement.js.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/withScrollTargets.cjs.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/withScrollTargets.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableCellElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableCellElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElementSelection.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElementSelection.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.js +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableRowElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableRowElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/gaugeTableColumnCount.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/gaugeTableColumnCount.js.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/development/src/plugins/text/bold/withBold.cjs.map +1 -1
- package/dist/development/src/plugins/text/bold/withBold.js.map +1 -1
- package/dist/development/src/plugins/text/code/withCode.cjs.map +1 -1
- package/dist/development/src/plugins/text/highlight/withHighlight.cjs.map +1 -1
- package/dist/development/src/plugins/text/italic/withItalic.cjs.map +1 -1
- package/dist/development/src/plugins/text/italic/withItalic.js.map +1 -1
- package/dist/development/src/plugins/text/newline/withNewline.cjs.map +1 -1
- package/dist/development/src/plugins/text/newline/withNewline.js.map +1 -1
- package/dist/development/src/plugins/text/strikeThrough/withStrikeThrough.cjs.map +1 -1
- package/dist/development/src/plugins/text/strikeThrough/withStrikeThrough.js.map +1 -1
- package/dist/development/src/plugins/text/underline/withUnderline.cjs.map +1 -1
- package/dist/development/src/plugins/text/underline/withUnderline.js.map +1 -1
- package/dist/production/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/production/src/components/RichTextEditor.js.map +1 -1
- package/dist/production/src/components/triggers/EditorElementTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorElementTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorGenericTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorGenericTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorMarkTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorMarkTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorWrapNodeTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorWrapNodeTrigger.js.map +1 -1
- package/dist/production/src/editor/createEditor.cjs.map +1 -1
- package/dist/production/src/editor/createEditor.js.map +1 -1
- package/dist/production/src/editor/createEditorWithEssentials.cjs.map +1 -1
- package/dist/production/src/editor/createEditorWithEssentials.js.map +1 -1
- package/dist/production/src/editor/index.cjs.map +1 -1
- package/dist/production/src/editor/methods/addMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/addMarks.js.map +1 -1
- package/dist/production/src/editor/methods/canToggleMark.cjs.map +1 -1
- package/dist/production/src/editor/methods/canToggleMark.js.map +1 -1
- package/dist/production/src/editor/methods/closest.cjs.map +1 -1
- package/dist/production/src/editor/methods/closest.js.map +1 -1
- package/dist/production/src/editor/methods/closestBlockEntry.cjs.map +1 -1
- package/dist/production/src/editor/methods/ejectElement.cjs.map +1 -1
- package/dist/production/src/editor/methods/ejectElement.js.map +1 -1
- package/dist/production/src/editor/methods/getElementDataAttributes.cjs.map +1 -1
- package/dist/production/src/editor/methods/getElementDataAttributes.js.map +1 -1
- package/dist/production/src/editor/methods/getPreviousSibling.cjs.map +1 -1
- package/dist/production/src/editor/methods/getPreviousSibling.js.map +1 -1
- package/dist/production/src/editor/methods/hasMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/hasMarks.js.map +1 -1
- package/dist/production/src/editor/methods/hasParentOfType.cjs.map +1 -1
- package/dist/production/src/editor/methods/hasParentOfType.js.map +1 -1
- package/dist/production/src/editor/methods/isElementType.cjs.map +1 -1
- package/dist/production/src/editor/methods/isElementType.js.map +1 -1
- package/dist/production/src/editor/methods/permissivelyDeserializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/permissivelyDeserializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/removeMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/removeMarks.js.map +1 -1
- package/dist/production/src/editor/methods/serializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/serializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/strictlyDeserializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/strictlyDeserializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/toLatestFormat.cjs.map +1 -1
- package/dist/production/src/editor/methods/toLatestFormat.js.map +1 -1
- package/dist/production/src/internal/components/DefaultElement.cjs.map +1 -1
- package/dist/production/src/internal/components/DefaultElement.js.map +1 -1
- package/dist/production/src/internal/hooks/useRichTextFieldNodes.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useRichTextFieldNodes.js.map +1 -1
- package/dist/production/src/internal/utils/EditorPasteUtils.cjs.map +1 -1
- package/dist/production/src/internal/utils/EditorPasteUtils.js.map +1 -1
- package/dist/production/src/internal/utils/parseUrl.cjs.map +1 -1
- package/dist/production/src/internal/utils/parseUrl.js.map +1 -1
- package/dist/production/src/plugins/attributes/alignment/alignButton.cjs.map +1 -1
- package/dist/production/src/plugins/attributes/alignment/alignButton.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/HtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/HtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/createMarkHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/createMarkHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/withPaste.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/withPaste.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorElement.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorModifications.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorModifications.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/withAnchors.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/withAnchors.js.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingElement.js.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/headings/withHeadings.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/withHeadings.js.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/HorizontalRuleElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/HorizontalRuleElement.js.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/withHorizontalRules.cjs.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/withHorizontalRules.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListItemElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListItemElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/OrderedListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/UnorderedListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/dedentListItem.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/dedentListItem.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/indentListItem.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/indentListItem.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/normalizeListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/normalizeListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/toggleListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/toggleListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/withLists.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/withLists.js.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/ParagraphElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/ParagraphElement.js.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/withParagraphs.cjs.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/withParagraphs.js.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/ScrollTargetElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/ScrollTargetElement.js.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/withScrollTargets.cjs.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/withScrollTargets.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableCellElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableCellElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElementSelection.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElementSelection.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.js +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableRowElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableRowElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/gaugeTableColumnCount.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/gaugeTableColumnCount.js.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/production/src/plugins/text/bold/withBold.cjs.map +1 -1
- package/dist/production/src/plugins/text/bold/withBold.js.map +1 -1
- package/dist/production/src/plugins/text/code/withCode.cjs.map +1 -1
- package/dist/production/src/plugins/text/highlight/withHighlight.cjs.map +1 -1
- package/dist/production/src/plugins/text/italic/withItalic.cjs.map +1 -1
- package/dist/production/src/plugins/text/italic/withItalic.js.map +1 -1
- package/dist/production/src/plugins/text/newline/withNewline.cjs.map +1 -1
- package/dist/production/src/plugins/text/newline/withNewline.js.map +1 -1
- package/dist/production/src/plugins/text/strikeThrough/withStrikeThrough.cjs.map +1 -1
- package/dist/production/src/plugins/text/strikeThrough/withStrikeThrough.js.map +1 -1
- package/dist/production/src/plugins/text/underline/withUnderline.cjs.map +1 -1
- package/dist/production/src/plugins/text/underline/withUnderline.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorPasteUtils.js","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/EditorPasteUtils.ts"],"sourcesContent":["import { Element } from 'slate'\nimport { NodesWithType } from '../../plugins/behaviour/paste/HtmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../types/editor'\n\nexport class EditorPasteUtils {\n\tpublic static wordPasteListItemContent(allNodes: Iterable<Node> | ArrayLike<Node>): Node[] {\n\t\tconst nodes: Node[] = []\n\t\tlet ignoring = false\n\t\tlet forProcessing = Array.from(allNodes)\n\t\tif (\n\t\t\t(forProcessing.length === 1 && forProcessing[0].nodeName === 'SPAN') ||\n\t\t\t\t(forProcessing.length === 2 && forProcessing[0].nodeName === 'SPAN' && forProcessing[1].nodeName === 'O:P')\n\t\t) {\n\t\t\tforProcessing = Array.from(forProcessing[0].childNodes)\n\t\t}\n\n\t\tfor (const node of forProcessing) {\n\t\t\tconst isStartIgnore = node.nodeType === Node.COMMENT_NODE && node.nodeValue === '[if !supportLists]'\n\t\t\tif (isStartIgnore) {\n\t\t\t\tignoring = true\n\t\t\t} else {\n\t\t\t\tconst isEndIgnore = node.nodeType === Node.COMMENT_NODE && node.nodeValue === '[endif]'\n\t\t\t\tif (isEndIgnore) {\n\t\t\t\t\tignoring = false\n\t\t\t\t} else {\n\t\t\t\t\tif (!ignoring) {\n\t\t\t\t\t\tnodes.push(node)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nodes\n\t}\n\n\tpublic static flattenNodesWithType(withType: NodesWithType[], defaultElementFactory: EditorDefaultElementFactory): NodesWithType {\n\t\tconst withTypeFiltered = withType.filter((item): item is Exclude<NodesWithType, null> => item !== null)\n\t\tconst containsBlock = withTypeFiltered.find(({ elements }) => elements !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: withTypeFiltered.flatMap<Element>(item => {\n\t\t\t\t\tif (item.elements === undefined) {\n\t\t\t\t\t\treturn [defaultElementFactory(item.texts)]\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn item.elements\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: withTypeFiltered.flatMap(item => item.texts!) }\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAIO,MAAM,iBAAiB;AAAA,EAC7B,OAAc,yBAAyB,UAAoD;AAC1F,UAAM,QAAgB,
|
|
1
|
+
{"version":3,"file":"EditorPasteUtils.js","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/EditorPasteUtils.ts"],"sourcesContent":["import { Element } from 'slate'\nimport { NodesWithType } from '../../plugins/behaviour/paste/HtmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../types/editor'\n\nexport class EditorPasteUtils {\n\tpublic static wordPasteListItemContent(allNodes: Iterable<Node> | ArrayLike<Node>): Node[] {\n\t\tconst nodes: Node[] = []\n\t\tlet ignoring = false\n\t\tlet forProcessing = Array.from(allNodes)\n\t\tif (\n\t\t\t(forProcessing.length === 1 && forProcessing[0].nodeName === 'SPAN') ||\n\t\t\t\t(forProcessing.length === 2 && forProcessing[0].nodeName === 'SPAN' && forProcessing[1].nodeName === 'O:P')\n\t\t) {\n\t\t\tforProcessing = Array.from(forProcessing[0].childNodes)\n\t\t}\n\n\t\tfor (const node of forProcessing) {\n\t\t\tconst isStartIgnore = node.nodeType === Node.COMMENT_NODE && node.nodeValue === '[if !supportLists]'\n\t\t\tif (isStartIgnore) {\n\t\t\t\tignoring = true\n\t\t\t} else {\n\t\t\t\tconst isEndIgnore = node.nodeType === Node.COMMENT_NODE && node.nodeValue === '[endif]'\n\t\t\t\tif (isEndIgnore) {\n\t\t\t\t\tignoring = false\n\t\t\t\t} else {\n\t\t\t\t\tif (!ignoring) {\n\t\t\t\t\t\tnodes.push(node)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nodes\n\t}\n\n\tpublic static flattenNodesWithType(withType: NodesWithType[], defaultElementFactory: EditorDefaultElementFactory): NodesWithType {\n\t\tconst withTypeFiltered = withType.filter((item): item is Exclude<NodesWithType, null> => item !== null)\n\t\tconst containsBlock = withTypeFiltered.find(({ elements }) => elements !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: withTypeFiltered.flatMap<Element>(item => {\n\t\t\t\t\tif (item.elements === undefined) {\n\t\t\t\t\t\treturn [defaultElementFactory(item.texts)]\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn item.elements\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: withTypeFiltered.flatMap(item => item.texts!) }\n\t\t}\n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/D;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseUrl.cjs","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/parseUrl.ts"],"sourcesContent":["export const parseUrl = (url: string): URL | undefined => {\n\tif (url.length < 4 || url.includes(' ')) {\n\t\t// This is almost definitely not an url anyway.\n\t\t// By returning early, we avoid the relatively costly URL constructor and can speed up the most common case of\n\t\t// just inserting a single character which better be as fast as possible.\n\t\treturn undefined\n\t}\n\ttry {\n\t\treturn new URL(url)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":";;AAAa,MAAA,WAAW,CAAC,QAAiC;AACzD,MAAI,IAAI,SAAS,KAAK,IAAI,SAAS,GAAG,GAAG;AAIjC,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"parseUrl.cjs","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/parseUrl.ts"],"sourcesContent":["export const parseUrl = (url: string): URL | undefined => {\n\tif (url.length < 4 || url.includes(' ')) {\n\t\t// This is almost definitely not an url anyway.\n\t\t// By returning early, we avoid the relatively costly URL constructor and can speed up the most common case of\n\t\t// just inserting a single character which better be as fast as possible.\n\t\treturn undefined\n\t}\n\ttry {\n\t\treturn new URL(url)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":";;AAAa,MAAA,WAAW,CAAC,QAAiC;AACzD,MAAI,IAAI,SAAS,KAAK,IAAI,SAAS,GAAG,GAAG;AAIjC,WAAA;AAAA,EAAA;AAEJ,MAAA;AACI,WAAA,IAAI,IAAI,GAAG;AAAA,EAAA,QACX;AACA,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseUrl.js","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/parseUrl.ts"],"sourcesContent":["export const parseUrl = (url: string): URL | undefined => {\n\tif (url.length < 4 || url.includes(' ')) {\n\t\t// This is almost definitely not an url anyway.\n\t\t// By returning early, we avoid the relatively costly URL constructor and can speed up the most common case of\n\t\t// just inserting a single character which better be as fast as possible.\n\t\treturn undefined\n\t}\n\ttry {\n\t\treturn new URL(url)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":"AAAa,MAAA,WAAW,CAAC,QAAiC;AACzD,MAAI,IAAI,SAAS,KAAK,IAAI,SAAS,GAAG,GAAG;AAIjC,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"parseUrl.js","sources":["../../../../../../packages/react-slate-editor-base/src/internal/utils/parseUrl.ts"],"sourcesContent":["export const parseUrl = (url: string): URL | undefined => {\n\tif (url.length < 4 || url.includes(' ')) {\n\t\t// This is almost definitely not an url anyway.\n\t\t// By returning early, we avoid the relatively costly URL constructor and can speed up the most common case of\n\t\t// just inserting a single character which better be as fast as possible.\n\t\treturn undefined\n\t}\n\ttry {\n\t\treturn new URL(url)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":"AAAa,MAAA,WAAW,CAAC,QAAiC;AACzD,MAAI,IAAI,SAAS,KAAK,IAAI,SAAS,GAAG,GAAG;AAIjC,WAAA;AAAA,EAAA;AAEJ,MAAA;AACI,WAAA,IAAI,IAAI,GAAG;AAAA,EAAA,QACX;AACA,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignButton.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/attributes/alignment/alignButton.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node, Transforms } from 'slate'\n\nexport type AlignDirection = 'start' | 'center' | 'end' | 'justify' | undefined\n\nconst isAlignTarget = (editor: Editor, it: Node, direction: AlignDirection) =>\n\tSlateElement.isElement(it)\n\t&& editor.acceptsAttributes(it.type, { align: direction })\n\nexport const createAlignHandler = (direction: AlignDirection): {\n\tisActive?: (args: { editor: Editor }) => boolean\n\tshouldDisplay?: (args: { editor: Editor }) => boolean\n\ttoggle: (args: { editor: Editor }) => void\n}\t=> ({\n\tshouldDisplay: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) })).length > 0\n\t},\n\tisActive: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) && (it as any).align === direction })).length > 0\n\t},\n\ttoggle: ({ editor }) => {\n\t\tTransforms.setNodes(editor, {\n\t\t\talign: direction,\n\t\t}, {\n\t\t\tmatch: it => isAlignTarget(editor, it, direction),\n\t\t})\n\t},\n})\n\n\n\n"],"names":["SlateElement","Editor","Transforms"],"mappings":";;;AAIA,MAAM,gBAAgB,CAAC,QAAgB,IAAU,cAChDA,MAAAA,QAAa,UAAU,EAAE,KACtB,OAAO,kBAAkB,GAAG,MAAM,EAAE,OAAO,WAAW;AAE7C,MAAA,qBAAqB,CAAC,eAI7B;AAAA,EACL,eAAe,CAAC,EAAE,aAAa;AAC9B,WAAO,MAAM,KAAKC,
|
|
1
|
+
{"version":3,"file":"alignButton.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/attributes/alignment/alignButton.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node, Transforms } from 'slate'\n\nexport type AlignDirection = 'start' | 'center' | 'end' | 'justify' | undefined\n\nconst isAlignTarget = (editor: Editor, it: Node, direction: AlignDirection) =>\n\tSlateElement.isElement(it)\n\t&& editor.acceptsAttributes(it.type, { align: direction })\n\nexport const createAlignHandler = (direction: AlignDirection): {\n\tisActive?: (args: { editor: Editor }) => boolean\n\tshouldDisplay?: (args: { editor: Editor }) => boolean\n\ttoggle: (args: { editor: Editor }) => void\n}\t=> ({\n\tshouldDisplay: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) })).length > 0\n\t},\n\tisActive: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) && (it as any).align === direction })).length > 0\n\t},\n\ttoggle: ({ editor }) => {\n\t\tTransforms.setNodes(editor, {\n\t\t\talign: direction,\n\t\t}, {\n\t\t\tmatch: it => isAlignTarget(editor, it, direction),\n\t\t})\n\t},\n})\n\n\n\n"],"names":["SlateElement","Editor","Transforms"],"mappings":";;;AAIA,MAAM,gBAAgB,CAAC,QAAgB,IAAU,cAChDA,MAAAA,QAAa,UAAU,EAAE,KACtB,OAAO,kBAAkB,GAAG,MAAM,EAAE,OAAO,WAAW;AAE7C,MAAA,qBAAqB,CAAC,eAI7B;AAAA,EACL,eAAe,CAAC,EAAE,aAAa;AAC9B,WAAO,MAAM,KAAKC,MAAAA,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAA,OAAM,cAAc,QAAQ,IAAI,SAAS,EAAA,CAAG,CAAC,EAAE,SAAS;AAAA,EACzG;AAAA,EACA,UAAU,CAAC,EAAE,aAAa;AACzB,WAAO,MAAM,KAAKA,aAAO,MAAM,QAAQ,EAAE,OAAO,CAAM,OAAA,cAAc,QAAQ,IAAI,SAAS,KAAM,GAAW,UAAU,UAAW,CAAA,CAAC,EAAE,SAAS;AAAA,EAC5I;AAAA,EACA,QAAQ,CAAC,EAAE,aAAa;AACvBC,UAAA,WAAW,SAAS,QAAQ;AAAA,MAC3B,OAAO;AAAA,IAAA,GACL;AAAA,MACF,OAAO,CAAA,OAAM,cAAc,QAAQ,IAAI,SAAS;AAAA,IAAA,CAChD;AAAA,EAAA;AAEH;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignButton.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/attributes/alignment/alignButton.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node, Transforms } from 'slate'\n\nexport type AlignDirection = 'start' | 'center' | 'end' | 'justify' | undefined\n\nconst isAlignTarget = (editor: Editor, it: Node, direction: AlignDirection) =>\n\tSlateElement.isElement(it)\n\t&& editor.acceptsAttributes(it.type, { align: direction })\n\nexport const createAlignHandler = (direction: AlignDirection): {\n\tisActive?: (args: { editor: Editor }) => boolean\n\tshouldDisplay?: (args: { editor: Editor }) => boolean\n\ttoggle: (args: { editor: Editor }) => void\n}\t=> ({\n\tshouldDisplay: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) })).length > 0\n\t},\n\tisActive: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) && (it as any).align === direction })).length > 0\n\t},\n\ttoggle: ({ editor }) => {\n\t\tTransforms.setNodes(editor, {\n\t\t\talign: direction,\n\t\t}, {\n\t\t\tmatch: it => isAlignTarget(editor, it, direction),\n\t\t})\n\t},\n})\n\n\n\n"],"names":["SlateElement"],"mappings":";AAIA,MAAM,gBAAgB,CAAC,QAAgB,IAAU,cAChDA,QAAa,UAAU,EAAE,KACtB,OAAO,kBAAkB,GAAG,MAAM,EAAE,OAAO,WAAW;AAE7C,MAAA,qBAAqB,CAAC,eAI7B;AAAA,EACL,eAAe,CAAC,EAAE,aAAa;AAC9B,WAAO,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAA,OAAM,cAAc,QAAQ,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"alignButton.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/attributes/alignment/alignButton.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node, Transforms } from 'slate'\n\nexport type AlignDirection = 'start' | 'center' | 'end' | 'justify' | undefined\n\nconst isAlignTarget = (editor: Editor, it: Node, direction: AlignDirection) =>\n\tSlateElement.isElement(it)\n\t&& editor.acceptsAttributes(it.type, { align: direction })\n\nexport const createAlignHandler = (direction: AlignDirection): {\n\tisActive?: (args: { editor: Editor }) => boolean\n\tshouldDisplay?: (args: { editor: Editor }) => boolean\n\ttoggle: (args: { editor: Editor }) => void\n}\t=> ({\n\tshouldDisplay: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) })).length > 0\n\t},\n\tisActive: ({ editor }) => {\n\t\treturn Array.from(Editor.nodes(editor, { match: it => isAlignTarget(editor, it, direction) && (it as any).align === direction })).length > 0\n\t},\n\ttoggle: ({ editor }) => {\n\t\tTransforms.setNodes(editor, {\n\t\t\talign: direction,\n\t\t}, {\n\t\t\tmatch: it => isAlignTarget(editor, it, direction),\n\t\t})\n\t},\n})\n\n\n\n"],"names":["SlateElement"],"mappings":";AAIA,MAAM,gBAAgB,CAAC,QAAgB,IAAU,cAChDA,QAAa,UAAU,EAAE,KACtB,OAAO,kBAAkB,GAAG,MAAM,EAAE,OAAO,WAAW;AAE7C,MAAA,qBAAqB,CAAC,eAI7B;AAAA,EACL,eAAe,CAAC,EAAE,aAAa;AAC9B,WAAO,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAA,OAAM,cAAc,QAAQ,IAAI,SAAS,EAAA,CAAG,CAAC,EAAE,SAAS;AAAA,EACzG;AAAA,EACA,UAAU,CAAC,EAAE,aAAa;AACzB,WAAO,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAM,OAAA,cAAc,QAAQ,IAAI,SAAS,KAAM,GAAW,UAAU,UAAW,CAAA,CAAC,EAAE,SAAS;AAAA,EAC5I;AAAA,EACA,QAAQ,CAAC,EAAE,aAAa;AACvB,eAAW,SAAS,QAAQ;AAAA,MAC3B,OAAO;AAAA,IAAA,GACL;AAAA,MACF,OAAO,CAAA,OAAM,cAAc,QAAQ,IAAI,SAAS;AAAA,IAAA,CAChD;AAAA,EAAA;AAEH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/HtmlDeserializer.ts"],"sourcesContent":["import { Descendant, Element as SlateElement, Text as SlateText } from 'slate'\nimport { HtmlDeserializerNextCallback, HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../../types/editor'\n\nconst ignoredElements = ['SCRIPT', 'STYLE', 'TEMPLATE']\n\nexport interface TextAttrs {\n\t[key: string]: any\n}\n\nexport type NodesWithTypeFiltered =\n\t| { texts: Descendant[]; elements?: undefined }\n\t| { elements: SlateElement[]; texts?: undefined }\n\nexport type NodesWithType = NodesWithTypeFiltered | null\n\nexport class HtmlDeserializer {\n\tconstructor(\n\t\tpublic createDefaultElement: EditorDefaultElementFactory,\n\t\tprivate plugins: HtmlDeserializerPlugin[],\n\t) {\n\t}\n\n\tregisterPlugin(plugin: HtmlDeserializerPlugin, prepend: boolean = true) {\n\t\tprepend ? this.plugins.unshift(plugin) : this.plugins.push(plugin)\n\t}\n\n\tpublic processNodeListPaste(nodeList: Node[], cumulativeTextAttrs: TextAttrs) {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processNodeListPaste?.({ nodeList, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\tconst processed: (\n\t\t\t| { text: SlateText | SlateElement; element?: undefined; isWhiteSpace: boolean }\n\t\t\t| { element: SlateElement; text?: undefined }\n\t\t)[] = []\n\n\t\tfor (const childNode of nodeList) {\n\t\t\tconst isWhiteSpace = childNode.nodeType === Node.TEXT_NODE && childNode.textContent?.match(/^\\s*$/) !== null\n\n\t\t\t// Block\n\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\tconst result =\n\t\t\t\tchildNode instanceof HTMLElement\n\t\t\t\t\t? this.processBlockPaste(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t)\n\t\t\t\t\t: null\n\t\t\tif (result !== null) {\n\t\t\t\tprocessed.push(...(Array.isArray(result) ? result : [result]).map(element => ({ element })))\n\t\t\t} else {\n\t\t\t\t// Inline\n\t\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\t\tif (result !== null) {\n\t\t\t\t\tprocessed.push(...result.map(text => ({ text, isWhiteSpace })))\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown element\n\t\t\t\t\tconst deserializedChildren = this.processNodeListPaste(\n\t\t\t\t\t\tArray.from(childNode.childNodes),\n\t\t\t\t\t\tattrs,\n\t\t\t\t\t)\n\t\t\t\t\tprocessed.push(\n\t\t\t\t\t\t...(deserializedChildren === null\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: deserializedChildren.texts !== undefined\n\t\t\t\t\t\t\t\t? deserializedChildren.texts.map(text => ({ text, isWhiteSpace }))\n\t\t\t\t\t\t\t\t: deserializedChildren.elements.map(element => ({ element }))),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (processed.length === 0) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst containsBlock = processed.find(({ element }) => element !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: processed.flatMap(item => {\n\t\t\t\t\tif (item.text !== undefined) {\n\t\t\t\t\t\treturn item.isWhiteSpace ? [] : [this.createDefaultElement([item.text])]\n\t\t\t\t\t} else if (item.element !== undefined) {\n\t\t\t\t\t\treturn [item.element]\n\t\t\t\t\t}\n\t\t\t\t\t{\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: processed.map(item => item.text as SlateText) }\n\t\t}\n\t}\n\n\tdeserializeInline(list: NodeList | Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\treturn Array.from(list).flatMap(childNode => {\n\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t} else {\n\t\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\t\treturn this.deserializeInline(childNode.childNodes, attrs)\n\t\t\t}\n\t\t})\n\t}\n\n\tdeserializeBlocks(list: Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\tconst result = this.processNodeListPaste(list, cumulativeTextAttrs)\n\t\treturn result?.texts ?? result?.elements ?? []\n\t}\n\n\n\tprivate deserializeTextNode(node: Node, cumulativeTextAttrs: TextAttrs): Descendant[] | null {\n\t\tif (node.nodeType === Node.TEXT_NODE) {\n\t\t\tconst text = node.textContent ?? ''\n\t\t\treturn [{ ...cumulativeTextAttrs, text: text.replace(/[ \\t]*(?:\\r?\\n[ \\t]*)+/g, ' ') }]\n\t\t} else if (node instanceof HTMLElement) {\n\t\t\tconst result = this.processInlinePaste(\n\t\t\t\tnode,\n\t\t\t\tcumulativeTextAttrs,\n\t\t\t)\n\t\t\tif (result !== null) {\n\t\t\t\treturn Array.isArray(result) ? result : [result]\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tprivate processInlinePaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): (SlateElement | SlateText)[] | SlateElement | SlateText | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tif (element.tagName === 'BR') {\n\t\t\treturn { ...cumulativeTextAttrs, text: ' ' }\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) => {\n\t\t\tconst attrs = this.processWithAttributeProcessor(element, cta)\n\t\t\treturn this.deserializeInline(list, attrs)\n\t\t}\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processInlinePaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\tprivate processWithAttributeProcessor(element: Node, cumulativeTextAttrs: TextAttrs): TextAttrs {\n\t\tif (!(element instanceof HTMLElement)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.plugins.reduce(\n\t\t\t(cta, plugin) => plugin.processAttributesPaste?.({ element, cumulativeTextAttrs, deserializer: this }) ?? cta,\n\t\t\tcumulativeTextAttrs,\n\t\t)\n\t}\n\n\tprivate processBlockPaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): SlateElement[] | SlateElement | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) =>\n\t\t\tthis.deserializeBlocks(Array.from(list), { ...cumulativeTextAttrs, ...cta })\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processBlockPaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n"],"names":["result"],"mappings":";;AAIA,MAAM,kBAAkB,CAAC,UAAU,SAAS,UAAU;AAY/C,MAAM,iBAAiB;AAAA,EAC7B,YACQ,sBACC,SACP;AAFM,SAAA,uBAAA;AACC,SAAA,UAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"HtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/HtmlDeserializer.ts"],"sourcesContent":["import { Descendant, Element as SlateElement, Text as SlateText } from 'slate'\nimport { HtmlDeserializerNextCallback, HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../../types/editor'\n\nconst ignoredElements = ['SCRIPT', 'STYLE', 'TEMPLATE']\n\nexport interface TextAttrs {\n\t[key: string]: any\n}\n\nexport type NodesWithTypeFiltered =\n\t| { texts: Descendant[]; elements?: undefined }\n\t| { elements: SlateElement[]; texts?: undefined }\n\nexport type NodesWithType = NodesWithTypeFiltered | null\n\nexport class HtmlDeserializer {\n\tconstructor(\n\t\tpublic createDefaultElement: EditorDefaultElementFactory,\n\t\tprivate plugins: HtmlDeserializerPlugin[],\n\t) {\n\t}\n\n\tregisterPlugin(plugin: HtmlDeserializerPlugin, prepend: boolean = true) {\n\t\tprepend ? this.plugins.unshift(plugin) : this.plugins.push(plugin)\n\t}\n\n\tpublic processNodeListPaste(nodeList: Node[], cumulativeTextAttrs: TextAttrs) {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processNodeListPaste?.({ nodeList, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\tconst processed: (\n\t\t\t| { text: SlateText | SlateElement; element?: undefined; isWhiteSpace: boolean }\n\t\t\t| { element: SlateElement; text?: undefined }\n\t\t)[] = []\n\n\t\tfor (const childNode of nodeList) {\n\t\t\tconst isWhiteSpace = childNode.nodeType === Node.TEXT_NODE && childNode.textContent?.match(/^\\s*$/) !== null\n\n\t\t\t// Block\n\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\tconst result =\n\t\t\t\tchildNode instanceof HTMLElement\n\t\t\t\t\t? this.processBlockPaste(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t)\n\t\t\t\t\t: null\n\t\t\tif (result !== null) {\n\t\t\t\tprocessed.push(...(Array.isArray(result) ? result : [result]).map(element => ({ element })))\n\t\t\t} else {\n\t\t\t\t// Inline\n\t\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\t\tif (result !== null) {\n\t\t\t\t\tprocessed.push(...result.map(text => ({ text, isWhiteSpace })))\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown element\n\t\t\t\t\tconst deserializedChildren = this.processNodeListPaste(\n\t\t\t\t\t\tArray.from(childNode.childNodes),\n\t\t\t\t\t\tattrs,\n\t\t\t\t\t)\n\t\t\t\t\tprocessed.push(\n\t\t\t\t\t\t...(deserializedChildren === null\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: deserializedChildren.texts !== undefined\n\t\t\t\t\t\t\t\t? deserializedChildren.texts.map(text => ({ text, isWhiteSpace }))\n\t\t\t\t\t\t\t\t: deserializedChildren.elements.map(element => ({ element }))),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (processed.length === 0) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst containsBlock = processed.find(({ element }) => element !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: processed.flatMap(item => {\n\t\t\t\t\tif (item.text !== undefined) {\n\t\t\t\t\t\treturn item.isWhiteSpace ? [] : [this.createDefaultElement([item.text])]\n\t\t\t\t\t} else if (item.element !== undefined) {\n\t\t\t\t\t\treturn [item.element]\n\t\t\t\t\t}\n\t\t\t\t\t{\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: processed.map(item => item.text as SlateText) }\n\t\t}\n\t}\n\n\tdeserializeInline(list: NodeList | Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\treturn Array.from(list).flatMap(childNode => {\n\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t} else {\n\t\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\t\treturn this.deserializeInline(childNode.childNodes, attrs)\n\t\t\t}\n\t\t})\n\t}\n\n\tdeserializeBlocks(list: Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\tconst result = this.processNodeListPaste(list, cumulativeTextAttrs)\n\t\treturn result?.texts ?? result?.elements ?? []\n\t}\n\n\n\tprivate deserializeTextNode(node: Node, cumulativeTextAttrs: TextAttrs): Descendant[] | null {\n\t\tif (node.nodeType === Node.TEXT_NODE) {\n\t\t\tconst text = node.textContent ?? ''\n\t\t\treturn [{ ...cumulativeTextAttrs, text: text.replace(/[ \\t]*(?:\\r?\\n[ \\t]*)+/g, ' ') }]\n\t\t} else if (node instanceof HTMLElement) {\n\t\t\tconst result = this.processInlinePaste(\n\t\t\t\tnode,\n\t\t\t\tcumulativeTextAttrs,\n\t\t\t)\n\t\t\tif (result !== null) {\n\t\t\t\treturn Array.isArray(result) ? result : [result]\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tprivate processInlinePaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): (SlateElement | SlateText)[] | SlateElement | SlateText | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tif (element.tagName === 'BR') {\n\t\t\treturn { ...cumulativeTextAttrs, text: ' ' }\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) => {\n\t\t\tconst attrs = this.processWithAttributeProcessor(element, cta)\n\t\t\treturn this.deserializeInline(list, attrs)\n\t\t}\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processInlinePaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\tprivate processWithAttributeProcessor(element: Node, cumulativeTextAttrs: TextAttrs): TextAttrs {\n\t\tif (!(element instanceof HTMLElement)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.plugins.reduce(\n\t\t\t(cta, plugin) => plugin.processAttributesPaste?.({ element, cumulativeTextAttrs, deserializer: this }) ?? cta,\n\t\t\tcumulativeTextAttrs,\n\t\t)\n\t}\n\n\tprivate processBlockPaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): SlateElement[] | SlateElement | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) =>\n\t\t\tthis.deserializeBlocks(Array.from(list), { ...cumulativeTextAttrs, ...cta })\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processBlockPaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result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,OAAO,GAAG;AAC9C,aAAO,CAAC;AAAA,IAAA;AAET,UAAM,OAAqC,CAAC,MAAM,QACjD,KAAK,kBAAkB,MAAM,KAAK,IAAI,GAAG,EAAE,GAAG,qBAAqB,GAAG,KAAK;AAEjE,eAAA,UAAU,KAAK,SAAS;AAC5B,YAAA,SAAS,OAAO,oBAAoB,EAAE,SAAS,MAAM,qBAAqB,cAAc,KAAM,CAAA,KAAK;AACzG,UAAI,WAAW,MAAM;AACb,eAAA;AAAA,MAAA;AAAA,IACR;AAEM,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/HtmlDeserializer.ts"],"sourcesContent":["import { Descendant, Element as SlateElement, Text as SlateText } from 'slate'\nimport { HtmlDeserializerNextCallback, HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../../types/editor'\n\nconst ignoredElements = ['SCRIPT', 'STYLE', 'TEMPLATE']\n\nexport interface TextAttrs {\n\t[key: string]: any\n}\n\nexport type NodesWithTypeFiltered =\n\t| { texts: Descendant[]; elements?: undefined }\n\t| { elements: SlateElement[]; texts?: undefined }\n\nexport type NodesWithType = NodesWithTypeFiltered | null\n\nexport class HtmlDeserializer {\n\tconstructor(\n\t\tpublic createDefaultElement: EditorDefaultElementFactory,\n\t\tprivate plugins: HtmlDeserializerPlugin[],\n\t) {\n\t}\n\n\tregisterPlugin(plugin: HtmlDeserializerPlugin, prepend: boolean = true) {\n\t\tprepend ? this.plugins.unshift(plugin) : this.plugins.push(plugin)\n\t}\n\n\tpublic processNodeListPaste(nodeList: Node[], cumulativeTextAttrs: TextAttrs) {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processNodeListPaste?.({ nodeList, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\tconst processed: (\n\t\t\t| { text: SlateText | SlateElement; element?: undefined; isWhiteSpace: boolean }\n\t\t\t| { element: SlateElement; text?: undefined }\n\t\t)[] = []\n\n\t\tfor (const childNode of nodeList) {\n\t\t\tconst isWhiteSpace = childNode.nodeType === Node.TEXT_NODE && childNode.textContent?.match(/^\\s*$/) !== null\n\n\t\t\t// Block\n\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\tconst result =\n\t\t\t\tchildNode instanceof HTMLElement\n\t\t\t\t\t? this.processBlockPaste(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t)\n\t\t\t\t\t: null\n\t\t\tif (result !== null) {\n\t\t\t\tprocessed.push(...(Array.isArray(result) ? result : [result]).map(element => ({ element })))\n\t\t\t} else {\n\t\t\t\t// Inline\n\t\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\t\tif (result !== null) {\n\t\t\t\t\tprocessed.push(...result.map(text => ({ text, isWhiteSpace })))\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown element\n\t\t\t\t\tconst deserializedChildren = this.processNodeListPaste(\n\t\t\t\t\t\tArray.from(childNode.childNodes),\n\t\t\t\t\t\tattrs,\n\t\t\t\t\t)\n\t\t\t\t\tprocessed.push(\n\t\t\t\t\t\t...(deserializedChildren === null\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: deserializedChildren.texts !== undefined\n\t\t\t\t\t\t\t\t? deserializedChildren.texts.map(text => ({ text, isWhiteSpace }))\n\t\t\t\t\t\t\t\t: deserializedChildren.elements.map(element => ({ element }))),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (processed.length === 0) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst containsBlock = processed.find(({ element }) => element !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: processed.flatMap(item => {\n\t\t\t\t\tif (item.text !== undefined) {\n\t\t\t\t\t\treturn item.isWhiteSpace ? [] : [this.createDefaultElement([item.text])]\n\t\t\t\t\t} else if (item.element !== undefined) {\n\t\t\t\t\t\treturn [item.element]\n\t\t\t\t\t}\n\t\t\t\t\t{\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: processed.map(item => item.text as SlateText) }\n\t\t}\n\t}\n\n\tdeserializeInline(list: NodeList | Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\treturn Array.from(list).flatMap(childNode => {\n\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t} else {\n\t\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\t\treturn this.deserializeInline(childNode.childNodes, attrs)\n\t\t\t}\n\t\t})\n\t}\n\n\tdeserializeBlocks(list: Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\tconst result = this.processNodeListPaste(list, cumulativeTextAttrs)\n\t\treturn result?.texts ?? result?.elements ?? []\n\t}\n\n\n\tprivate deserializeTextNode(node: Node, cumulativeTextAttrs: TextAttrs): Descendant[] | null {\n\t\tif (node.nodeType === Node.TEXT_NODE) {\n\t\t\tconst text = node.textContent ?? ''\n\t\t\treturn [{ ...cumulativeTextAttrs, text: text.replace(/[ \\t]*(?:\\r?\\n[ \\t]*)+/g, ' ') }]\n\t\t} else if (node instanceof HTMLElement) {\n\t\t\tconst result = this.processInlinePaste(\n\t\t\t\tnode,\n\t\t\t\tcumulativeTextAttrs,\n\t\t\t)\n\t\t\tif (result !== null) {\n\t\t\t\treturn Array.isArray(result) ? result : [result]\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tprivate processInlinePaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): (SlateElement | SlateText)[] | SlateElement | SlateText | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tif (element.tagName === 'BR') {\n\t\t\treturn { ...cumulativeTextAttrs, text: ' ' }\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) => {\n\t\t\tconst attrs = this.processWithAttributeProcessor(element, cta)\n\t\t\treturn this.deserializeInline(list, attrs)\n\t\t}\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processInlinePaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\tprivate processWithAttributeProcessor(element: Node, cumulativeTextAttrs: TextAttrs): TextAttrs {\n\t\tif (!(element instanceof HTMLElement)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.plugins.reduce(\n\t\t\t(cta, plugin) => plugin.processAttributesPaste?.({ element, cumulativeTextAttrs, deserializer: this }) ?? cta,\n\t\t\tcumulativeTextAttrs,\n\t\t)\n\t}\n\n\tprivate processBlockPaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): SlateElement[] | SlateElement | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) =>\n\t\t\tthis.deserializeBlocks(Array.from(list), { ...cumulativeTextAttrs, ...cta })\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processBlockPaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n"],"names":["result"],"mappings":"AAIA,MAAM,kBAAkB,CAAC,UAAU,SAAS,UAAU;AAY/C,MAAM,iBAAiB;AAAA,EAC7B,YACQ,sBACC,SACP;AAFM,SAAA,uBAAA;AACC,SAAA,UAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"HtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/HtmlDeserializer.ts"],"sourcesContent":["import { Descendant, Element as SlateElement, Text as SlateText } from 'slate'\nimport { HtmlDeserializerNextCallback, HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\nimport { EditorDefaultElementFactory } from '../../../types/editor'\n\nconst ignoredElements = ['SCRIPT', 'STYLE', 'TEMPLATE']\n\nexport interface TextAttrs {\n\t[key: string]: any\n}\n\nexport type NodesWithTypeFiltered =\n\t| { texts: Descendant[]; elements?: undefined }\n\t| { elements: SlateElement[]; texts?: undefined }\n\nexport type NodesWithType = NodesWithTypeFiltered | null\n\nexport class HtmlDeserializer {\n\tconstructor(\n\t\tpublic createDefaultElement: EditorDefaultElementFactory,\n\t\tprivate plugins: HtmlDeserializerPlugin[],\n\t) {\n\t}\n\n\tregisterPlugin(plugin: HtmlDeserializerPlugin, prepend: boolean = true) {\n\t\tprepend ? this.plugins.unshift(plugin) : this.plugins.push(plugin)\n\t}\n\n\tpublic processNodeListPaste(nodeList: Node[], cumulativeTextAttrs: TextAttrs) {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processNodeListPaste?.({ nodeList, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\tconst processed: (\n\t\t\t| { text: SlateText | SlateElement; element?: undefined; isWhiteSpace: boolean }\n\t\t\t| { element: SlateElement; text?: undefined }\n\t\t)[] = []\n\n\t\tfor (const childNode of nodeList) {\n\t\t\tconst isWhiteSpace = childNode.nodeType === Node.TEXT_NODE && childNode.textContent?.match(/^\\s*$/) !== null\n\n\t\t\t// Block\n\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\tconst result =\n\t\t\t\tchildNode instanceof HTMLElement\n\t\t\t\t\t? this.processBlockPaste(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t)\n\t\t\t\t\t: null\n\t\t\tif (result !== null) {\n\t\t\t\tprocessed.push(...(Array.isArray(result) ? result : [result]).map(element => ({ element })))\n\t\t\t} else {\n\t\t\t\t// Inline\n\t\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\t\tif (result !== null) {\n\t\t\t\t\tprocessed.push(...result.map(text => ({ text, isWhiteSpace })))\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown element\n\t\t\t\t\tconst deserializedChildren = this.processNodeListPaste(\n\t\t\t\t\t\tArray.from(childNode.childNodes),\n\t\t\t\t\t\tattrs,\n\t\t\t\t\t)\n\t\t\t\t\tprocessed.push(\n\t\t\t\t\t\t...(deserializedChildren === null\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: deserializedChildren.texts !== undefined\n\t\t\t\t\t\t\t\t? deserializedChildren.texts.map(text => ({ text, isWhiteSpace }))\n\t\t\t\t\t\t\t\t: deserializedChildren.elements.map(element => ({ element }))),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (processed.length === 0) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst containsBlock = processed.find(({ element }) => element !== undefined) !== undefined\n\n\t\tif (containsBlock) {\n\t\t\treturn {\n\t\t\t\telements: processed.flatMap(item => {\n\t\t\t\t\tif (item.text !== undefined) {\n\t\t\t\t\t\treturn item.isWhiteSpace ? [] : [this.createDefaultElement([item.text])]\n\t\t\t\t\t} else if (item.element !== undefined) {\n\t\t\t\t\t\treturn [item.element]\n\t\t\t\t\t}\n\t\t\t\t\t{\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t}\n\t\t} else {\n\t\t\treturn { texts: processed.map(item => item.text as SlateText) }\n\t\t}\n\t}\n\n\tdeserializeInline(list: NodeList | Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\treturn Array.from(list).flatMap(childNode => {\n\t\t\tconst result = this.deserializeTextNode(childNode, cumulativeTextAttrs)\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t} else {\n\t\t\t\tconst attrs = this.processWithAttributeProcessor(childNode, cumulativeTextAttrs)\n\t\t\t\treturn this.deserializeInline(childNode.childNodes, attrs)\n\t\t\t}\n\t\t})\n\t}\n\n\tdeserializeBlocks(list: Node[], cumulativeTextAttrs: TextAttrs): Descendant[] {\n\t\tconst result = this.processNodeListPaste(list, cumulativeTextAttrs)\n\t\treturn result?.texts ?? result?.elements ?? []\n\t}\n\n\n\tprivate deserializeTextNode(node: Node, cumulativeTextAttrs: TextAttrs): Descendant[] | null {\n\t\tif (node.nodeType === Node.TEXT_NODE) {\n\t\t\tconst text = node.textContent ?? ''\n\t\t\treturn [{ ...cumulativeTextAttrs, text: text.replace(/[ \\t]*(?:\\r?\\n[ \\t]*)+/g, ' ') }]\n\t\t} else if (node instanceof HTMLElement) {\n\t\t\tconst result = this.processInlinePaste(\n\t\t\t\tnode,\n\t\t\t\tcumulativeTextAttrs,\n\t\t\t)\n\t\t\tif (result !== null) {\n\t\t\t\treturn Array.isArray(result) ? result : [result]\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tprivate processInlinePaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): (SlateElement | SlateText)[] | SlateElement | SlateText | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tif (element.tagName === 'BR') {\n\t\t\treturn { ...cumulativeTextAttrs, text: ' ' }\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) => {\n\t\t\tconst attrs = this.processWithAttributeProcessor(element, cta)\n\t\t\treturn this.deserializeInline(list, attrs)\n\t\t}\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processInlinePaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\tprivate processWithAttributeProcessor(element: Node, cumulativeTextAttrs: TextAttrs): TextAttrs {\n\t\tif (!(element instanceof HTMLElement)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.plugins.reduce(\n\t\t\t(cta, plugin) => plugin.processAttributesPaste?.({ element, cumulativeTextAttrs, deserializer: this }) ?? cta,\n\t\t\tcumulativeTextAttrs,\n\t\t)\n\t}\n\n\tprivate processBlockPaste(element: HTMLElement, cumulativeTextAttrs: TextAttrs): SlateElement[] | SlateElement | null {\n\t\tif (ignoredElements.includes(element.tagName)) {\n\t\t\treturn []\n\t\t}\n\t\tconst next: HtmlDeserializerNextCallback = (list, cta) =>\n\t\t\tthis.deserializeBlocks(Array.from(list), { ...cumulativeTextAttrs, ...cta })\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst result = plugin.processBlockPaste?.({ element, next, cumulativeTextAttrs, deserializer: this }) ?? null\n\t\t\tif (result !== null) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n"],"names":["result"],"mappings":"AAIA,MAAM,kBAAkB,CAAC,UAAU,SAAS,UAAU;AAY/C,MAAM,iBAAiB;AAAA,EAC7B,YACQ,sBACC,SACP;AAFM,SAAA,uBAAA;AACC,SAAA,UAAA;AAAA,EAAA;AAAA,EAIT,eAAe,QAAgC,UAAmB,MAAM;AAC7D,cAAA,KAAK,QAAQ,QAAQ,MAAM,IAAI,KAAK,QAAQ,KAAK,MAAM;AAAA,EAAA;AAAA,EAG3D,qBAAqB,UAAkB,qBAAgC;AAClE,eAAA,UAAU,KAAK,SAAS;AAC5B,YAAA,SAAS,OAAO,uBAAuB,EAAE,UAAU,qBAAqB,cAAc,KAAM,CAAA,KAAK;AACvG,UAAI,WAAW,MAAM;AACb,eAAA;AAAA,MAAA;AAAA,IACR;AAED,UAAM,YAGA,CAAC;AAEP,eAAW,aAAa,UAAU;AAC3B,YAAA,eAAe,UAAU,aAA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AC,MAAM,QAAQ;AACzD,YAAM,QAAQ,KAAK,8BAA8B,SAAS,GAAG;AACtD,aAAA,KAAK,kBAAkB,MAAM,KAAK;AAAA,IAC1C;AACW,eAAA,UAAU,KAAK,SAAS;AAC5B,YAAA,SAAS,OAAO,qBAAqB,EAAE,SAAS,MAAM,qBAAqB,cAAc,KAAM,CAAA,KAAK;AAC1G,UAAI,WAAW,MAAM;AACb,eAAA;AAAA,MAAA;AAAA,IACR;AAEM,WAAA;AAAA,EAAA;AAAA,EAGA,8BAA8B,SAAe,qBAA2C;AAC3F,QAAA,EAAE,mBAAmB,cAAc;AACtC,aAAO,CAAC;AAAA,IAAA;AAET,WAAO,KAAK,QAAQ;AAAA,MACnB,CAAC,KAAK,WAAW,OAAO,yBAAyB,EAAE,SAAS,qBAAqB,cAAc,KAAO,CAAA,KAAK;AAAA,MAC3G;AAAA,IACD;AAAA,EAAA;AAAA,EAGO,kBAAkB,SAAsB,qBAAsE;AACrH,QAAI,gBAAgB,SAAS,QAAQ,OAAO,GAAG;AAC9C,aAAO,CAAC;AAAA,IAAA;AAET,UAAM,OAAqC,CAAC,MAAM,QACjD,KAAK,kBAAkB,MAAM,KAAK,IAAI,GAAG,EAAE,GAAG,qBAAqB,GAAG,KAAK;AAEjE,eAAA,UAAU,KAAK,SAAS;AAC5B,YAAA,SAAS,OAAO,oBAAoB,EAAE,SAAS,MAAM,qBAAqB,cAAc,KAAM,CAAA,KAAK;AACzG,UAAI,WAAW,MAAM;AACb,eAAA;AAAA,MAAA;AAAA,IACR;AAEM,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarkHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/createMarkHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\nexport const createMarkHtmlDeserializer = (markType: string, tagMatcher: (el: HTMLElement) => boolean, attributeMatcher: (el: HTMLElement) => boolean): HtmlDeserializerPlugin => ({\n\tprocessAttributesPaste: ({ element, cumulativeTextAttrs: cta }) => {\n\t\treturn attributeMatcher(element) ? { ...cta, [markType]: true } : cta\n\t},\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (tagMatcher(element)) {\n\t\t\treturn next(element.childNodes, { ...cumulativeTextAttrs, [markType]: true })\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":";;AAEO,MAAM,6BAA6B,CAAC,UAAkB,YAA0C,sBAA4E;AAAA,EAClL,wBAAwB,CAAC,EAAE,SAAS,qBAAqB,UAAU;AAC3D,WAAA,iBAAiB,OAAO,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"createMarkHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/createMarkHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\nexport const createMarkHtmlDeserializer = (markType: string, tagMatcher: (el: HTMLElement) => boolean, attributeMatcher: (el: HTMLElement) => boolean): HtmlDeserializerPlugin => ({\n\tprocessAttributesPaste: ({ element, cumulativeTextAttrs: cta }) => {\n\t\treturn attributeMatcher(element) ? { ...cta, [markType]: true } : cta\n\t},\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (tagMatcher(element)) {\n\t\t\treturn next(element.childNodes, { ...cumulativeTextAttrs, [markType]: true })\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":";;AAEO,MAAM,6BAA6B,CAAC,UAAkB,YAA0C,sBAA4E;AAAA,EAClL,wBAAwB,CAAC,EAAE,SAAS,qBAAqB,UAAU;AAC3D,WAAA,iBAAiB,OAAO,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAA,IAAS;AAAA,EACnE;AAAA,EACA,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC3D,QAAA,WAAW,OAAO,GAAG;AACjB,aAAA,KAAK,QAAQ,YAAY,EAAE,GAAG,qBAAqB,CAAC,QAAQ,GAAG,MAAM;AAAA,IAAA;AAEtE,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarkHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/createMarkHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\nexport const createMarkHtmlDeserializer = (markType: string, tagMatcher: (el: HTMLElement) => boolean, attributeMatcher: (el: HTMLElement) => boolean): HtmlDeserializerPlugin => ({\n\tprocessAttributesPaste: ({ element, cumulativeTextAttrs: cta }) => {\n\t\treturn attributeMatcher(element) ? { ...cta, [markType]: true } : cta\n\t},\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (tagMatcher(element)) {\n\t\t\treturn next(element.childNodes, { ...cumulativeTextAttrs, [markType]: true })\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":"AAEO,MAAM,6BAA6B,CAAC,UAAkB,YAA0C,sBAA4E;AAAA,EAClL,wBAAwB,CAAC,EAAE,SAAS,qBAAqB,UAAU;AAC3D,WAAA,iBAAiB,OAAO,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"createMarkHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/createMarkHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\nexport const createMarkHtmlDeserializer = (markType: string, tagMatcher: (el: HTMLElement) => boolean, attributeMatcher: (el: HTMLElement) => boolean): HtmlDeserializerPlugin => ({\n\tprocessAttributesPaste: ({ element, cumulativeTextAttrs: cta }) => {\n\t\treturn attributeMatcher(element) ? { ...cta, [markType]: true } : cta\n\t},\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (tagMatcher(element)) {\n\t\t\treturn next(element.childNodes, { ...cumulativeTextAttrs, [markType]: true })\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":"AAEO,MAAM,6BAA6B,CAAC,UAAkB,YAA0C,sBAA4E;AAAA,EAClL,wBAAwB,CAAC,EAAE,SAAS,qBAAqB,UAAU;AAC3D,WAAA,iBAAiB,OAAO,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAA,IAAS;AAAA,EACnE;AAAA,EACA,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC3D,QAAA,WAAW,OAAO,GAAG;AACjB,aAAA,KAAK,QAAQ,YAAY,EAAE,GAAG,qBAAqB,CAAC,QAAQ,GAAG,MAAM;AAAA,IAAA;AAEtE,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPaste.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/withPaste.ts"],"sourcesContent":["import { Editor, Transforms } from 'slate'\nimport { EditorPlugin } from '../../../types/plugins'\nimport { HtmlDeserializer } from './HtmlDeserializer'\nimport { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\n\nexport const withPaste = (editor: Editor) => {\n\tconst { insertData } = editor\n\tconst htmlDeserializer = new HtmlDeserializer(editor.createDefaultElement, [])\n\teditor.insertData = data => {\n\t\tif (data.getData('application/x-slate-fragment')) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst html = data.getData('text/html')\n\t\tif (!html) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst document = new DOMParser().parseFromString(html, 'text/html')\n\t\tconst nodes = Array.from(document.body.childNodes)\n\t\tconst result = htmlDeserializer.deserializeBlocks(nodes, {})\n\t\tTransforms.insertFragment(editor, result)\n\t}\n\teditor.htmlDeserializer = htmlDeserializer\n}\n"],"names":["HtmlDeserializer","Transforms"],"mappings":";;;;AAMa,MAAA,YAAY,CAAC,WAAmB;AACtC,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withPaste.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/withPaste.ts"],"sourcesContent":["import { Editor, Transforms } from 'slate'\nimport { EditorPlugin } from '../../../types/plugins'\nimport { HtmlDeserializer } from './HtmlDeserializer'\nimport { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\n\nexport const withPaste = (editor: Editor) => {\n\tconst { insertData } = editor\n\tconst htmlDeserializer = new HtmlDeserializer(editor.createDefaultElement, [])\n\teditor.insertData = data => {\n\t\tif (data.getData('application/x-slate-fragment')) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst html = data.getData('text/html')\n\t\tif (!html) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst document = new DOMParser().parseFromString(html, 'text/html')\n\t\tconst nodes = Array.from(document.body.childNodes)\n\t\tconst result = htmlDeserializer.deserializeBlocks(nodes, {})\n\t\tTransforms.insertFragment(editor, result)\n\t}\n\teditor.htmlDeserializer = htmlDeserializer\n}\n"],"names":["HtmlDeserializer","Transforms"],"mappings":";;;;AAMa,MAAA,YAAY,CAAC,WAAmB;AACtC,QAAA,EAAE,eAAe;AACvB,QAAM,mBAAmB,IAAIA,iBAAAA,iBAAiB,OAAO,sBAAsB,CAAA,CAAE;AAC7E,SAAO,aAAa,CAAQ,SAAA;AACvB,QAAA,KAAK,QAAQ,8BAA8B,GAAG;AACjD,aAAO,WAAW,IAAI;AAAA,IAAA;AAEjB,UAAA,OAAO,KAAK,QAAQ,WAAW;AACrC,QAAI,CAAC,MAAM;AACV,aAAO,WAAW,IAAI;AAAA,IAAA;AAEvB,UAAM,WAAW,IAAI,UAAA,EAAY,gBAAgB,MAAM,WAAW;AAClE,UAAM,QAAQ,MAAM,KAAK,SAAS,KAAK,UAAU;AACjD,UAAM,SAAS,iBAAiB,kBAAkB,OAAO,CAAA,CAAE;AAChDC,qBAAA,eAAe,QAAQ,MAAM;AAAA,EACzC;AACA,SAAO,mBAAmB;AAC3B;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPaste.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/withPaste.ts"],"sourcesContent":["import { Editor, Transforms } from 'slate'\nimport { EditorPlugin } from '../../../types/plugins'\nimport { HtmlDeserializer } from './HtmlDeserializer'\nimport { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\n\nexport const withPaste = (editor: Editor) => {\n\tconst { insertData } = editor\n\tconst htmlDeserializer = new HtmlDeserializer(editor.createDefaultElement, [])\n\teditor.insertData = data => {\n\t\tif (data.getData('application/x-slate-fragment')) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst html = data.getData('text/html')\n\t\tif (!html) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst document = new DOMParser().parseFromString(html, 'text/html')\n\t\tconst nodes = Array.from(document.body.childNodes)\n\t\tconst result = htmlDeserializer.deserializeBlocks(nodes, {})\n\t\tTransforms.insertFragment(editor, result)\n\t}\n\teditor.htmlDeserializer = htmlDeserializer\n}\n"],"names":[],"mappings":";;AAMa,MAAA,YAAY,CAAC,WAAmB;AACtC,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withPaste.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/behaviour/paste/withPaste.ts"],"sourcesContent":["import { Editor, Transforms } from 'slate'\nimport { EditorPlugin } from '../../../types/plugins'\nimport { HtmlDeserializer } from './HtmlDeserializer'\nimport { HtmlDeserializerPlugin } from '../../../types/htmlDeserializer'\n\n\nexport const withPaste = (editor: Editor) => {\n\tconst { insertData } = editor\n\tconst htmlDeserializer = new HtmlDeserializer(editor.createDefaultElement, [])\n\teditor.insertData = data => {\n\t\tif (data.getData('application/x-slate-fragment')) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst html = data.getData('text/html')\n\t\tif (!html) {\n\t\t\treturn insertData(data)\n\t\t}\n\t\tconst document = new DOMParser().parseFromString(html, 'text/html')\n\t\tconst nodes = Array.from(document.body.childNodes)\n\t\tconst result = htmlDeserializer.deserializeBlocks(nodes, {})\n\t\tTransforms.insertFragment(editor, result)\n\t}\n\teditor.htmlDeserializer = htmlDeserializer\n}\n"],"names":[],"mappings":";;AAMa,MAAA,YAAY,CAAC,WAAmB;AACtC,QAAA,EAAE,eAAe;AACvB,QAAM,mBAAmB,IAAI,iBAAiB,OAAO,sBAAsB,CAAA,CAAE;AAC7E,SAAO,aAAa,CAAQ,SAAA;AACvB,QAAA,KAAK,QAAQ,8BAA8B,GAAG;AACjD,aAAO,WAAW,IAAI;AAAA,IAAA;AAEjB,UAAA,OAAO,KAAK,QAAQ,WAAW;AACrC,QAAI,CAAC,MAAM;AACV,aAAO,WAAW,IAAI;AAAA,IAAA;AAEvB,UAAM,WAAW,IAAI,UAAA,EAAY,gBAAgB,MAAM,WAAW;AAClE,UAAM,QAAQ,MAAM,KAAK,SAAS,KAAK,UAAU;AACjD,UAAM,SAAS,iBAAiB,kBAAkB,OAAO,CAAA,CAAE;AAChD,eAAA,eAAe,QAAQ,MAAM;AAAA,EACzC;AACA,SAAO,mBAAmB;AAC3B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Path, Range as SlateRange, Transforms } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const anchorElementType = 'anchor' as const\n\nexport interface AnchorElement extends SlateElement {\n\ttype: typeof anchorElementType\n\thref: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isAnchorElement = (element: SlateNode): element is AnchorElement => SlateElement.isElement(element) && element.type === anchorElementType\n\nexport const isAnchorElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isAnchorElement })\n\treturn !!link\n}\n\n\nexport const anchorElementPlugin = ({ render }: { render: ElementRenderer<AnchorElement> }): EditorElementPlugin<AnchorElement> => ({\n\ttype: anchorElementType,\n\tisInline: true,\n\trender,\n\tisActive: ({ editor }) => isAnchorElementActive(editor),\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t} else {\n\t\t\tconst href = suchThat?.href ?? prompt('Insert the URL:')\n\t\t\tif (!href) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tAnchorModifications.wrapAnchor(editor, href)\n\t\t}\n\t},\n\tnormalizeNode: ({ element, path, editor, preventDefault }) => {\n\t\tif (SlateNode.string(element) === '') {\n\t\t\tconst selection = editor.selection\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\tif (selection && SlateRange.isCollapsed(selection) && Path.isCommon(path, selection.focus.path)) {\n\t\t\t\tTransforms.select(editor, Path.parent(path))\n\t\t\t}\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement","Editor","AnchorModifications","SlateNode","Transforms","SlateRange","Path"],"mappings":";;;;AAIO,MAAM,oBAAoB;AAQpB,MAAA,kBAAkB,CAAC,YAAiDA,
|
|
1
|
+
{"version":3,"file":"AnchorElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Path, Range as SlateRange, Transforms } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const anchorElementType = 'anchor' as const\n\nexport interface AnchorElement extends SlateElement {\n\ttype: typeof anchorElementType\n\thref: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isAnchorElement = (element: SlateNode): element is AnchorElement => SlateElement.isElement(element) && element.type === anchorElementType\n\nexport const isAnchorElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isAnchorElement })\n\treturn !!link\n}\n\n\nexport const anchorElementPlugin = ({ render }: { render: ElementRenderer<AnchorElement> }): EditorElementPlugin<AnchorElement> => ({\n\ttype: anchorElementType,\n\tisInline: true,\n\trender,\n\tisActive: ({ editor }) => isAnchorElementActive(editor),\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t} else {\n\t\t\tconst href = suchThat?.href ?? prompt('Insert the URL:')\n\t\t\tif (!href) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tAnchorModifications.wrapAnchor(editor, href)\n\t\t}\n\t},\n\tnormalizeNode: ({ element, path, editor, preventDefault }) => {\n\t\tif (SlateNode.string(element) === '') {\n\t\t\tconst selection = editor.selection\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\tif (selection && SlateRange.isCollapsed(selection) && Path.isCommon(path, selection.focus.path)) {\n\t\t\t\tTransforms.select(editor, Path.parent(path))\n\t\t\t}\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement","Editor","AnchorModifications","SlateNode","Transforms","SlateRange","Path"],"mappings":";;;;AAIO,MAAM,oBAAoB;AAQpB,MAAA,kBAAkB,CAAC,YAAiDA,MAAA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExH,MAAA,wBAAwB,CAAC,WAAmB;AAClD,QAAA,CAAC,IAAI,IAAIC,aAAO,MAAM,QAAQ,EAAE,OAAO,iBAAiB;AAC9D,SAAO,CAAC,CAAC;AACV;AAGO,MAAM,sBAAsB,CAAC,EAAE,cAA8F;AAAA,EACnI,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,UAAU,CAAC,EAAE,aAAa,sBAAsB,MAAM;AAAA,EACtD,eAAe,CAAC,EAAE,QAAQ,eAAe;AACpC,QAAA,sBAAsB,MAAM,GAAG;AAClCC,0BAAA,oBAAoB,aAAa,MAAM;AAAA,IAAA,OACjC;AACN,YAAM,OAAO,UAAU,QAAQ,OAAO,iBAAiB;AACvD,UAAI,CAAC,MAAM;AACV;AAAA,MAAA;AAEmBA,8CAAA,WAAW,QAAQ,IAAI;AAAA,IAAA;AAAA,EAE7C;AAAA,EACA,eAAe,CAAC,EAAE,SAAS,MAAM,QAAQ,qBAAqB;AAC7D,QAAIC,WAAU,OAAO,OAAO,MAAM,IAAI;AACrC,YAAM,YAAY,OAAO;AACzBC,YAAA,WAAW,YAAY,QAAQ;AAAA,QAC9B,IAAI;AAAA,MAAA,CACJ;AACG,UAAA,aAAaC,MAAAA,MAAW,YAAY,SAAS,KAAKC,MAAAA,KAAK,SAAS,MAAM,UAAU,MAAM,IAAI,GAAG;AAChGF,cAAA,WAAW,OAAO,QAAQE,MAAK,KAAA,OAAO,IAAI,CAAC;AAAA,MAAA;AAE5C,aAAO,eAAe;AAAA,IAAA;AAAA,EACvB;AAEF;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Path, Range as SlateRange, Transforms } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const anchorElementType = 'anchor' as const\n\nexport interface AnchorElement extends SlateElement {\n\ttype: typeof anchorElementType\n\thref: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isAnchorElement = (element: SlateNode): element is AnchorElement => SlateElement.isElement(element) && element.type === anchorElementType\n\nexport const isAnchorElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isAnchorElement })\n\treturn !!link\n}\n\n\nexport const anchorElementPlugin = ({ render }: { render: ElementRenderer<AnchorElement> }): EditorElementPlugin<AnchorElement> => ({\n\ttype: anchorElementType,\n\tisInline: true,\n\trender,\n\tisActive: ({ editor }) => isAnchorElementActive(editor),\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t} else {\n\t\t\tconst href = suchThat?.href ?? prompt('Insert the URL:')\n\t\t\tif (!href) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tAnchorModifications.wrapAnchor(editor, href)\n\t\t}\n\t},\n\tnormalizeNode: ({ element, path, editor, preventDefault }) => {\n\t\tif (SlateNode.string(element) === '') {\n\t\t\tconst selection = editor.selection\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\tif (selection && SlateRange.isCollapsed(selection) && Path.isCommon(path, selection.focus.path)) {\n\t\t\t\tTransforms.select(editor, Path.parent(path))\n\t\t\t}\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement","SlateNode","SlateRange"],"mappings":";;AAIO,MAAM,oBAAoB;AAQpB,MAAA,kBAAkB,CAAC,YAAiDA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExH,MAAA,wBAAwB,CAAC,WAAmB;AAClD,QAAA,CAAC,IAAI,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"AnchorElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Path, Range as SlateRange, Transforms } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const anchorElementType = 'anchor' as const\n\nexport interface AnchorElement extends SlateElement {\n\ttype: typeof anchorElementType\n\thref: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isAnchorElement = (element: SlateNode): element is AnchorElement => SlateElement.isElement(element) && element.type === anchorElementType\n\nexport const isAnchorElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isAnchorElement })\n\treturn !!link\n}\n\n\nexport const anchorElementPlugin = ({ render }: { render: ElementRenderer<AnchorElement> }): EditorElementPlugin<AnchorElement> => ({\n\ttype: anchorElementType,\n\tisInline: true,\n\trender,\n\tisActive: ({ editor }) => isAnchorElementActive(editor),\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t} else {\n\t\t\tconst href = suchThat?.href ?? prompt('Insert the URL:')\n\t\t\tif (!href) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tAnchorModifications.wrapAnchor(editor, href)\n\t\t}\n\t},\n\tnormalizeNode: ({ element, path, editor, preventDefault }) => {\n\t\tif (SlateNode.string(element) === '') {\n\t\t\tconst selection = editor.selection\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\tif (selection && SlateRange.isCollapsed(selection) && Path.isCommon(path, selection.focus.path)) {\n\t\t\t\tTransforms.select(editor, Path.parent(path))\n\t\t\t}\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement","SlateNode","SlateRange"],"mappings":";;AAIO,MAAM,oBAAoB;AAQpB,MAAA,kBAAkB,CAAC,YAAiDA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExH,MAAA,wBAAwB,CAAC,WAAmB;AAClD,QAAA,CAAC,IAAI,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,iBAAiB;AAC9D,SAAO,CAAC,CAAC;AACV;AAGO,MAAM,sBAAsB,CAAC,EAAE,cAA8F;AAAA,EACnI,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,UAAU,CAAC,EAAE,aAAa,sBAAsB,MAAM;AAAA,EACtD,eAAe,CAAC,EAAE,QAAQ,eAAe;AACpC,QAAA,sBAAsB,MAAM,GAAG;AAClC,0BAAoB,aAAa,MAAM;AAAA,IAAA,OACjC;AACN,YAAM,OAAO,UAAU,QAAQ,OAAO,iBAAiB;AACvD,UAAI,CAAC,MAAM;AACV;AAAA,MAAA;AAEmB,0BAAA,WAAW,QAAQ,IAAI;AAAA,IAAA;AAAA,EAE7C;AAAA,EACA,eAAe,CAAC,EAAE,SAAS,MAAM,QAAQ,qBAAqB;AAC7D,QAAIC,KAAU,OAAO,OAAO,MAAM,IAAI;AACrC,YAAM,YAAY,OAAO;AACzB,iBAAW,YAAY,QAAQ;AAAA,QAC9B,IAAI;AAAA,MAAA,CACJ;AACG,UAAA,aAAaC,MAAW,YAAY,SAAS,KAAK,KAAK,SAAS,MAAM,UAAU,MAAM,IAAI,GAAG;AAChG,mBAAW,OAAO,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,MAAA;AAE5C,aAAO,eAAe;AAAA,IAAA;AAAA,EACvB;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\n\nexport const anchorHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'A' && element.getAttribute('href')) {\n\t\t\tconst href = element.getAttribute('href')\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'anchor',\n\t\t\t\t\thref,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":";;AAEO,MAAM,yBAAkD;AAAA,EAC9D,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC/D,QAAI,QAAQ,YAAY,OAAO,QAAQ,aAAa,MAAM,GAAG;AACtD,YAAA,OAAO,QAAQ,aAAa,MAAM;AAEjC,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN;AAAA,UACA,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,
|
|
1
|
+
{"version":3,"file":"AnchorHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\n\nexport const anchorHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'A' && element.getAttribute('href')) {\n\t\t\tconst href = element.getAttribute('href')\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'anchor',\n\t\t\t\t\thref,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":";;AAEO,MAAM,yBAAkD;AAAA,EAC9D,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC/D,QAAI,QAAQ,YAAY,OAAO,QAAQ,aAAa,MAAM,GAAG;AACtD,YAAA,OAAO,QAAQ,aAAa,MAAM;AAEjC,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN;AAAA,UACA,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAEM,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\n\nexport const anchorHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'A' && element.getAttribute('href')) {\n\t\t\tconst href = element.getAttribute('href')\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'anchor',\n\t\t\t\t\thref,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":"AAEO,MAAM,yBAAkD;AAAA,EAC9D,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC/D,QAAI,QAAQ,YAAY,OAAO,QAAQ,aAAa,MAAM,GAAG;AACtD,YAAA,OAAO,QAAQ,aAAa,MAAM;AAEjC,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN;AAAA,UACA,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,
|
|
1
|
+
{"version":3,"file":"AnchorHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\n\nexport const anchorHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessInlinePaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'A' && element.getAttribute('href')) {\n\t\t\tconst href = element.getAttribute('href')\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'anchor',\n\t\t\t\t\thref,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":"AAEO,MAAM,yBAAkD;AAAA,EAC9D,oBAAoB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC/D,QAAI,QAAQ,YAAY,OAAO,QAAQ,aAAa,MAAM,GAAG;AACtD,YAAA,OAAO,QAAQ,aAAa,MAAM;AAEjC,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN;AAAA,UACA,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAEM,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorModifications.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorModifications.ts"],"sourcesContent":["import { Editor, Range, Transforms } from 'slate'\nimport { AnchorElement, isAnchorElement, isAnchorElementActive } from './AnchorElement'\n\nexport class AnchorModifications {\n\tpublic static unwrapAnchor(editor: Editor) {\n\t\tTransforms.unwrapNodes(editor, { match: isAnchorElement })\n\t}\n\n\tpublic static wrapAnchor(editor: Editor, url: string) {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t}\n\n\t\tconst selection = editor.selection\n\t\tconst isCollapsed = selection ? Range.isCollapsed(selection!) : false\n\t\tconst anchor: AnchorElement = {\n\t\t\ttype: 'anchor',\n\t\t\thref: url,\n\t\t\tchildren: isCollapsed ? [{ text: url }] : [{ text: '' }],\n\t\t}\n\n\t\tif (isCollapsed) {\n\t\t\tTransforms.insertNodes(editor, anchor)\n\t\t} else {\n\t\t\tTransforms.wrapNodes(editor, anchor, { split: true })\n\t\t\tTransforms.collapse(editor, { edge: 'end' })\n\t\t}\n\t}\n}\n"],"names":["Transforms","isAnchorElement","isAnchorElementActive","Range"],"mappings":";;;;AAGO,MAAM,oBAAoB;AAAA,EAChC,OAAc,aAAa,QAAgB;AAC1CA,
|
|
1
|
+
{"version":3,"file":"AnchorModifications.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorModifications.ts"],"sourcesContent":["import { Editor, Range, Transforms } from 'slate'\nimport { AnchorElement, isAnchorElement, isAnchorElementActive } from './AnchorElement'\n\nexport class AnchorModifications {\n\tpublic static unwrapAnchor(editor: Editor) {\n\t\tTransforms.unwrapNodes(editor, { match: isAnchorElement })\n\t}\n\n\tpublic static wrapAnchor(editor: Editor, url: string) {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t}\n\n\t\tconst selection = editor.selection\n\t\tconst isCollapsed = selection ? Range.isCollapsed(selection!) : false\n\t\tconst anchor: AnchorElement = {\n\t\t\ttype: 'anchor',\n\t\t\thref: url,\n\t\t\tchildren: isCollapsed ? [{ text: url }] : [{ text: '' }],\n\t\t}\n\n\t\tif (isCollapsed) {\n\t\t\tTransforms.insertNodes(editor, anchor)\n\t\t} else {\n\t\t\tTransforms.wrapNodes(editor, anchor, { split: true })\n\t\t\tTransforms.collapse(editor, { edge: 'end' })\n\t\t}\n\t}\n}\n"],"names":["Transforms","isAnchorElement","isAnchorElementActive","Range"],"mappings":";;;;AAGO,MAAM,oBAAoB;AAAA,EAChC,OAAc,aAAa,QAAgB;AAC1CA,UAAAA,WAAW,YAAY,QAAQ,EAAE,OAAOC,+BAAiB;AAAA,EAAA;AAAA,EAG1D,OAAc,WAAW,QAAgB,KAAa;AACjD,QAAAC,cAAAA,sBAAsB,MAAM,GAAG;AAClC,0BAAoB,aAAa,MAAM;AAAA,IAAA;AAGxC,UAAM,YAAY,OAAO;AACzB,UAAM,cAAc,YAAYC,MAAAA,MAAM,YAAY,SAAU,IAAI;AAChE,UAAM,SAAwB;AAAA,MAC7B,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU,cAAc,CAAC,EAAE,MAAM,IAAA,CAAK,IAAI,CAAC,EAAE,MAAM,GAAI,CAAA;AAAA,IACxD;AAEA,QAAI,aAAa;AACLH,uBAAA,YAAY,QAAQ,MAAM;AAAA,IAAA,OAC/B;AACNA,YAAA,WAAW,UAAU,QAAQ,QAAQ,EAAE,OAAO,MAAM;AACpDA,YAAAA,WAAW,SAAS,QAAQ,EAAE,MAAM,OAAO;AAAA,IAAA;AAAA,EAC5C;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorModifications.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorModifications.ts"],"sourcesContent":["import { Editor, Range, Transforms } from 'slate'\nimport { AnchorElement, isAnchorElement, isAnchorElementActive } from './AnchorElement'\n\nexport class AnchorModifications {\n\tpublic static unwrapAnchor(editor: Editor) {\n\t\tTransforms.unwrapNodes(editor, { match: isAnchorElement })\n\t}\n\n\tpublic static wrapAnchor(editor: Editor, url: string) {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t}\n\n\t\tconst selection = editor.selection\n\t\tconst isCollapsed = selection ? Range.isCollapsed(selection!) : false\n\t\tconst anchor: AnchorElement = {\n\t\t\ttype: 'anchor',\n\t\t\thref: url,\n\t\t\tchildren: isCollapsed ? [{ text: url }] : [{ text: '' }],\n\t\t}\n\n\t\tif (isCollapsed) {\n\t\t\tTransforms.insertNodes(editor, anchor)\n\t\t} else {\n\t\t\tTransforms.wrapNodes(editor, anchor, { split: true })\n\t\t\tTransforms.collapse(editor, { edge: 'end' })\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,oBAAoB;AAAA,EAChC,OAAc,aAAa,QAAgB;AAC1C,eAAW,YAAY,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"AnchorModifications.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/AnchorModifications.ts"],"sourcesContent":["import { Editor, Range, Transforms } from 'slate'\nimport { AnchorElement, isAnchorElement, isAnchorElementActive } from './AnchorElement'\n\nexport class AnchorModifications {\n\tpublic static unwrapAnchor(editor: Editor) {\n\t\tTransforms.unwrapNodes(editor, { match: isAnchorElement })\n\t}\n\n\tpublic static wrapAnchor(editor: Editor, url: string) {\n\t\tif (isAnchorElementActive(editor)) {\n\t\t\tAnchorModifications.unwrapAnchor(editor)\n\t\t}\n\n\t\tconst selection = editor.selection\n\t\tconst isCollapsed = selection ? Range.isCollapsed(selection!) : false\n\t\tconst anchor: AnchorElement = {\n\t\t\ttype: 'anchor',\n\t\t\thref: url,\n\t\t\tchildren: isCollapsed ? [{ text: url }] : [{ text: '' }],\n\t\t}\n\n\t\tif (isCollapsed) {\n\t\t\tTransforms.insertNodes(editor, anchor)\n\t\t} else {\n\t\t\tTransforms.wrapNodes(editor, anchor, { split: true })\n\t\t\tTransforms.collapse(editor, { edge: 'end' })\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,oBAAoB;AAAA,EAChC,OAAc,aAAa,QAAgB;AAC1C,eAAW,YAAY,QAAQ,EAAE,OAAO,iBAAiB;AAAA,EAAA;AAAA,EAG1D,OAAc,WAAW,QAAgB,KAAa;AACjD,QAAA,sBAAsB,MAAM,GAAG;AAClC,0BAAoB,aAAa,MAAM;AAAA,IAAA;AAGxC,UAAM,YAAY,OAAO;AACzB,UAAM,cAAc,YAAY,MAAM,YAAY,SAAU,IAAI;AAChE,UAAM,SAAwB;AAAA,MAC7B,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU,cAAc,CAAC,EAAE,MAAM,IAAA,CAAK,IAAI,CAAC,EAAE,MAAM,GAAI,CAAA;AAAA,IACxD;AAEA,QAAI,aAAa;AACL,iBAAA,YAAY,QAAQ,MAAM;AAAA,IAAA,OAC/B;AACN,iBAAW,UAAU,QAAQ,QAAQ,EAAE,OAAO,MAAM;AACpD,iBAAW,SAAS,QAAQ,EAAE,MAAM,OAAO;AAAA,IAAA;AAAA,EAC5C;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAnchors.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/withAnchors.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { AnchorElement, anchorElementPlugin } from './AnchorElement'\nimport { anchorHtmlDeserializer } from './AnchorHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\nimport { parseUrl } from '../../../internal/utils'\n\nexport const withAnchors = ({ render }: { render: ElementRenderer<AnchorElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(anchorElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(anchorHtmlDeserializer)\n\n\teditor.insertText = text => {\n\t\tif (text && parseUrl(text) !== undefined) {\n\t\t\tAnchorModifications.wrapAnchor(editor, text)\n\t\t} else {\n\t\t\tinsertText(text)\n\t\t}\n\t}\n\n\treturn editor\n}\n"],"names":["anchorElementPlugin","anchorHtmlDeserializer","parseUrl","AnchorModifications"],"mappings":";;;;;;AAOO,MAAM,cAAc,CAAC,EAAE,OAAO,MAAkD,CAAmB,WAAiB;AACpH,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withAnchors.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/withAnchors.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { AnchorElement, anchorElementPlugin } from './AnchorElement'\nimport { anchorHtmlDeserializer } from './AnchorHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\nimport { parseUrl } from '../../../internal/utils'\n\nexport const withAnchors = ({ render }: { render: ElementRenderer<AnchorElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(anchorElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(anchorHtmlDeserializer)\n\n\teditor.insertText = text => {\n\t\tif (text && parseUrl(text) !== undefined) {\n\t\t\tAnchorModifications.wrapAnchor(editor, text)\n\t\t} else {\n\t\t\tinsertText(text)\n\t\t}\n\t}\n\n\treturn editor\n}\n"],"names":["anchorElementPlugin","anchorHtmlDeserializer","parseUrl","AnchorModifications"],"mappings":";;;;;;AAOO,MAAM,cAAc,CAAC,EAAE,OAAO,MAAkD,CAAmB,WAAiB;AACpH,QAAA,EAAE,eAAe;AAEvB,SAAO,gBAAgBA,cAAAA,oBAAoB,EAAE,OAAQ,CAAA,CAAC;AAC/C,SAAA,iBAAiB,eAAeC,6CAAsB;AAE7D,SAAO,aAAa,CAAQ,SAAA;AAC3B,QAAI,QAAQC,SAAA,SAAS,IAAI,MAAM,QAAW;AACrBC,8CAAA,WAAW,QAAQ,IAAI;AAAA,IAAA,OACrC;AACN,iBAAW,IAAI;AAAA,IAAA;AAAA,EAEjB;AAEO,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAnchors.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/withAnchors.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { AnchorElement, anchorElementPlugin } from './AnchorElement'\nimport { anchorHtmlDeserializer } from './AnchorHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\nimport { parseUrl } from '../../../internal/utils'\n\nexport const withAnchors = ({ render }: { render: ElementRenderer<AnchorElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(anchorElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(anchorHtmlDeserializer)\n\n\teditor.insertText = text => {\n\t\tif (text && parseUrl(text) !== undefined) {\n\t\t\tAnchorModifications.wrapAnchor(editor, text)\n\t\t} else {\n\t\t\tinsertText(text)\n\t\t}\n\t}\n\n\treturn editor\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,cAAc,CAAC,EAAE,OAAO,MAAkD,CAAmB,WAAiB;AACpH,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withAnchors.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/anchors/withAnchors.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { AnchorModifications } from './AnchorModifications'\nimport { AnchorElement, anchorElementPlugin } from './AnchorElement'\nimport { anchorHtmlDeserializer } from './AnchorHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\nimport { parseUrl } from '../../../internal/utils'\n\nexport const withAnchors = ({ render }: { render: ElementRenderer<AnchorElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(anchorElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(anchorHtmlDeserializer)\n\n\teditor.insertText = text => {\n\t\tif (text && parseUrl(text) !== undefined) {\n\t\t\tAnchorModifications.wrapAnchor(editor, text)\n\t\t} else {\n\t\t\tinsertText(text)\n\t\t}\n\t}\n\n\treturn editor\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,cAAc,CAAC,EAAE,OAAO,MAAkD,CAAmB,WAAiB;AACpH,QAAA,EAAE,eAAe;AAEvB,SAAO,gBAAgB,oBAAoB,EAAE,OAAQ,CAAA,CAAC;AAC/C,SAAA,iBAAiB,eAAe,sBAAsB;AAE7D,SAAO,aAAa,CAAQ,SAAA;AAC3B,QAAI,QAAQ,SAAS,IAAI,MAAM,QAAW;AACrB,0BAAA,WAAW,QAAQ,IAAI;AAAA,IAAA,OACrC;AACN,iBAAW,IAAI;AAAA,IAAA;AAAA,EAEjB;AAEO,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadingElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingElement.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const headingElementType = 'heading' as const\n\nexport interface HeadingElement extends Element {\n\ttype: typeof headingElementType\n\tlevel: 1 | 2 | 3 | 4 | 5 | 6\n\tisNumbered?: boolean\n\talign?: AlignDirection\n\tchildren: SlateEditor['children']\n}\n\nexport const isHeadingElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<HeadingElement>,\n): element is HeadingElement => ContemberEditor.isElementType(element, headingElementType, suchThat)\n\nexport const ejectHeadingElement = (editor: Editor, elementPath: SlatePath) => {\n\tContemberEditor.ejectElement(editor, elementPath)\n\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: elementPath })\n}\n\n\nexport const headingElementPlugin = ({ render }: { render: ElementRenderer<HeadingElement> }): EditorElementPlugin<HeadingElement> => ({\n\ttype: headingElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\t// TODO in the following function, we need to conditionally trim the selection so that it doesn't potentially\n\t// \tinclude empty strings at the edges of top-level elements.\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tconst headings = Array.from(Editor.nodes(editor, { match: it => isHeadingElement(it, suchThat) }))\n\t\t\tif (headings.length) {\n\t\t\t\tfor (const heading of headings) {\n\t\t\t\t\tejectHeadingElement(editor, heading[1])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.setNodes(editor, {\n\t\t\t\t\t...suchThat,\n\t\t\t\t\tchildren: [],\n\t\t\t\t\ttype: headingElementType,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t},\n})\n"],"names":["ContemberEditor","Transforms","SlateEditor","Editor"],"mappings":";;;;AAKO,MAAM,qBAAqB;AAUrB,MAAA,mBAAmB,CAC/B,SACA,aAC+BA,
|
|
1
|
+
{"version":3,"file":"HeadingElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingElement.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const headingElementType = 'heading' as const\n\nexport interface HeadingElement extends Element {\n\ttype: typeof headingElementType\n\tlevel: 1 | 2 | 3 | 4 | 5 | 6\n\tisNumbered?: boolean\n\talign?: AlignDirection\n\tchildren: SlateEditor['children']\n}\n\nexport const isHeadingElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<HeadingElement>,\n): element is HeadingElement => ContemberEditor.isElementType(element, headingElementType, suchThat)\n\nexport const ejectHeadingElement = (editor: Editor, elementPath: SlatePath) => {\n\tContemberEditor.ejectElement(editor, elementPath)\n\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: elementPath })\n}\n\n\nexport const headingElementPlugin = ({ render }: { render: ElementRenderer<HeadingElement> }): EditorElementPlugin<HeadingElement> => ({\n\ttype: headingElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\t// TODO in the following function, we need to conditionally trim the selection so that it doesn't potentially\n\t// \tinclude empty strings at the edges of top-level elements.\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tconst headings = Array.from(Editor.nodes(editor, { match: it => isHeadingElement(it, suchThat) }))\n\t\t\tif (headings.length) {\n\t\t\t\tfor (const heading of headings) {\n\t\t\t\t\tejectHeadingElement(editor, heading[1])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.setNodes(editor, {\n\t\t\t\t\t...suchThat,\n\t\t\t\t\tchildren: [],\n\t\t\t\t\ttype: headingElementType,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t},\n})\n"],"names":["ContemberEditor","Transforms","SlateEditor","Editor"],"mappings":";;;;AAKO,MAAM,qBAAqB;AAUrB,MAAA,mBAAmB,CAC/B,SACA,aAC+BA,sBAAgB,cAAc,SAAS,oBAAoB,QAAQ;AAEtF,MAAA,sBAAsB,CAAC,QAAgB,gBAA2B;AAC9DA,wBAAA,aAAa,QAAQ,WAAW;AACrCC,mBAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,aAAa;AACrF;AAGO,MAAM,uBAAuB,CAAC,EAAE,cAAgG;AAAA,EACtI,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,mBAAmB,CAAC,EAAE,QAAQ,eAAe;AAC5C,WAAO,WAAW;AAAA,EACnB;AAAA;AAAA;AAAA,EAGA,eAAe,CAAC,EAAE,QAAQ,eAAe;AAC5BC,iBAAA,mBAAmB,QAAQ,MAAM;AAC5C,YAAM,WAAW,MAAM,KAAKC,MAAA,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAA,OAAM,iBAAiB,IAAI,QAAQ,EAAG,CAAA,CAAC;AACjG,UAAI,SAAS,QAAQ;AACpB,mBAAW,WAAW,UAAU;AACX,8BAAA,QAAQ,QAAQ,CAAC,CAAC;AAAA,QAAA;AAAA,MACvC,OACM;AACNF,cAAA,WAAW,SAAS,QAAQ;AAAA,UAC3B,GAAG;AAAA,UACH,UAAU,CAAC;AAAA,UACX,MAAM;AAAA,QAAA,CACN;AAAA,MAAA;AAAA,IACF,CACA;AAAA,EAAA;AAEH;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadingElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingElement.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const headingElementType = 'heading' as const\n\nexport interface HeadingElement extends Element {\n\ttype: typeof headingElementType\n\tlevel: 1 | 2 | 3 | 4 | 5 | 6\n\tisNumbered?: boolean\n\talign?: AlignDirection\n\tchildren: SlateEditor['children']\n}\n\nexport const isHeadingElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<HeadingElement>,\n): element is HeadingElement => ContemberEditor.isElementType(element, headingElementType, suchThat)\n\nexport const ejectHeadingElement = (editor: Editor, elementPath: SlatePath) => {\n\tContemberEditor.ejectElement(editor, elementPath)\n\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: elementPath })\n}\n\n\nexport const headingElementPlugin = ({ render }: { render: ElementRenderer<HeadingElement> }): EditorElementPlugin<HeadingElement> => ({\n\ttype: headingElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\t// TODO in the following function, we need to conditionally trim the selection so that it doesn't potentially\n\t// \tinclude empty strings at the edges of top-level elements.\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tconst headings = Array.from(Editor.nodes(editor, { match: it => isHeadingElement(it, suchThat) }))\n\t\t\tif (headings.length) {\n\t\t\t\tfor (const heading of headings) {\n\t\t\t\t\tejectHeadingElement(editor, heading[1])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.setNodes(editor, {\n\t\t\t\t\t...suchThat,\n\t\t\t\t\tchildren: [],\n\t\t\t\t\ttype: headingElementType,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t},\n})\n"],"names":["SlateEditor"],"mappings":";;AAKO,MAAM,qBAAqB;AAUrB,MAAA,mBAAmB,CAC/B,SACA,aAC+B,gBAAgB,cAAc,SAAS,oBAAoB,QAAQ;AAEtF,MAAA,sBAAsB,CAAC,QAAgB,gBAA2B;AAC9D,kBAAA,aAAa,QAAQ,WAAW;AACrC,aAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"HeadingElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingElement.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const headingElementType = 'heading' as const\n\nexport interface HeadingElement extends Element {\n\ttype: typeof headingElementType\n\tlevel: 1 | 2 | 3 | 4 | 5 | 6\n\tisNumbered?: boolean\n\talign?: AlignDirection\n\tchildren: SlateEditor['children']\n}\n\nexport const isHeadingElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<HeadingElement>,\n): element is HeadingElement => ContemberEditor.isElementType(element, headingElementType, suchThat)\n\nexport const ejectHeadingElement = (editor: Editor, elementPath: SlatePath) => {\n\tContemberEditor.ejectElement(editor, elementPath)\n\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: elementPath })\n}\n\n\nexport const headingElementPlugin = ({ render }: { render: ElementRenderer<HeadingElement> }): EditorElementPlugin<HeadingElement> => ({\n\ttype: headingElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\t// TODO in the following function, we need to conditionally trim the selection so that it doesn't potentially\n\t// \tinclude empty strings at the edges of top-level elements.\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tconst headings = Array.from(Editor.nodes(editor, { match: it => isHeadingElement(it, suchThat) }))\n\t\t\tif (headings.length) {\n\t\t\t\tfor (const heading of headings) {\n\t\t\t\t\tejectHeadingElement(editor, heading[1])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.setNodes(editor, {\n\t\t\t\t\t...suchThat,\n\t\t\t\t\tchildren: [],\n\t\t\t\t\ttype: headingElementType,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t},\n})\n"],"names":["SlateEditor"],"mappings":";;AAKO,MAAM,qBAAqB;AAUrB,MAAA,mBAAmB,CAC/B,SACA,aAC+B,gBAAgB,cAAc,SAAS,oBAAoB,QAAQ;AAEtF,MAAA,sBAAsB,CAAC,QAAgB,gBAA2B;AAC9D,kBAAA,aAAa,QAAQ,WAAW;AACrC,aAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,aAAa;AACrF;AAGO,MAAM,uBAAuB,CAAC,EAAE,cAAgG;AAAA,EACtI,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,mBAAmB,CAAC,EAAE,QAAQ,eAAe;AAC5C,WAAO,WAAW;AAAA,EACnB;AAAA;AAAA;AAAA,EAGA,eAAe,CAAC,EAAE,QAAQ,eAAe;AAC5BA,WAAA,mBAAmB,QAAQ,MAAM;AAC5C,YAAM,WAAW,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,OAAO,CAAA,OAAM,iBAAiB,IAAI,QAAQ,EAAG,CAAA,CAAC;AACjG,UAAI,SAAS,QAAQ;AACpB,mBAAW,WAAW,UAAU;AACX,8BAAA,QAAQ,QAAQ,CAAC,CAAC;AAAA,QAAA;AAAA,MACvC,OACM;AACN,mBAAW,SAAS,QAAQ;AAAA,UAC3B,GAAG;AAAA,UACH,UAAU,CAAC;AAAA,UACX,MAAM;AAAA,QAAA,CACN;AAAA,MAAA;AAAA,IACF,CACA;AAAA,EAAA;AAEH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadingHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingHtmlDeserializer.ts"],"sourcesContent":["import { headingElementType } from './HeadingElement'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport const headingHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tconst match = element.nodeName.match(/^H(?<level>[1-6])$/)\n\t\tif (match !== null) {\n\t\t\tconst isNumbered = (element.getAttribute('style')?.match(/mso-list:\\w+ level\\d+ \\w+/) ?? null) !== null\n\t\t\tconst children = isNumbered ? EditorPasteUtils.wordPasteListItemContent(element.childNodes) : element.childNodes\n\t\t\treturn {\n\t\t\t\ttype: headingElementType,\n\t\t\t\tlevel: parseInt(match.groups!.level),\n\t\t\t\tchildren: next(children, cumulativeTextAttrs),\n\t\t\t\tisNumbered,\n\t\t\t}\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":["EditorPasteUtils","headingElementType"],"mappings":";;;;AAIO,MAAM,0BAAkD;AAAA,EAC9D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC9D,UAAM,QAAQ,QAAQ,SAAS,MAAM,oBAAoB;AACzD,QAAI,UAAU,MAAM;AACb,YAAA,cAAc,QAAQ,aAAa,OAAO,GAAG,MAAM,2BAA2B,KAAK,UAAU;AACnG,YAAM,WAAW,aAAaA,kCAAiB,yBAAyB,QAAQ,UAAU,IAAI,QAAQ;AAC/F,aAAA;AAAA,QACN,MAAMC,eAAA;AAAA,QACN,OAAO,SAAS,MAAM,OAAQ,KAAK;AAAA,QACnC,UAAU,KAAK,UAAU,mBAAmB;AAAA,QAC5C;AAAA,
|
|
1
|
+
{"version":3,"file":"HeadingHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingHtmlDeserializer.ts"],"sourcesContent":["import { headingElementType } from './HeadingElement'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport const headingHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tconst match = element.nodeName.match(/^H(?<level>[1-6])$/)\n\t\tif (match !== null) {\n\t\t\tconst isNumbered = (element.getAttribute('style')?.match(/mso-list:\\w+ level\\d+ \\w+/) ?? null) !== null\n\t\t\tconst children = isNumbered ? EditorPasteUtils.wordPasteListItemContent(element.childNodes) : element.childNodes\n\t\t\treturn {\n\t\t\t\ttype: headingElementType,\n\t\t\t\tlevel: parseInt(match.groups!.level),\n\t\t\t\tchildren: next(children, cumulativeTextAttrs),\n\t\t\t\tisNumbered,\n\t\t\t}\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":["EditorPasteUtils","headingElementType"],"mappings":";;;;AAIO,MAAM,0BAAkD;AAAA,EAC9D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC9D,UAAM,QAAQ,QAAQ,SAAS,MAAM,oBAAoB;AACzD,QAAI,UAAU,MAAM;AACb,YAAA,cAAc,QAAQ,aAAa,OAAO,GAAG,MAAM,2BAA2B,KAAK,UAAU;AACnG,YAAM,WAAW,aAAaA,kCAAiB,yBAAyB,QAAQ,UAAU,IAAI,QAAQ;AAC/F,aAAA;AAAA,QACN,MAAMC,eAAA;AAAA,QACN,OAAO,SAAS,MAAM,OAAQ,KAAK;AAAA,QACnC,UAAU,KAAK,UAAU,mBAAmB;AAAA,QAC5C;AAAA,MACD;AAAA,IAAA;AAEM,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadingHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingHtmlDeserializer.ts"],"sourcesContent":["import { headingElementType } from './HeadingElement'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport const headingHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tconst match = element.nodeName.match(/^H(?<level>[1-6])$/)\n\t\tif (match !== null) {\n\t\t\tconst isNumbered = (element.getAttribute('style')?.match(/mso-list:\\w+ level\\d+ \\w+/) ?? null) !== null\n\t\t\tconst children = isNumbered ? EditorPasteUtils.wordPasteListItemContent(element.childNodes) : element.childNodes\n\t\t\treturn {\n\t\t\t\ttype: headingElementType,\n\t\t\t\tlevel: parseInt(match.groups!.level),\n\t\t\t\tchildren: next(children, cumulativeTextAttrs),\n\t\t\t\tisNumbered,\n\t\t\t}\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":";;AAIO,MAAM,0BAAkD;AAAA,EAC9D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC9D,UAAM,QAAQ,QAAQ,SAAS,MAAM,oBAAoB;AACzD,QAAI,UAAU,MAAM;AACb,YAAA,cAAc,QAAQ,aAAa,OAAO,GAAG,MAAM,2BAA2B,KAAK,UAAU;AACnG,YAAM,WAAW,aAAa,iBAAiB,yBAAyB,QAAQ,UAAU,IAAI,QAAQ;AAC/F,aAAA;AAAA,QACN,MAAM;AAAA,QACN,OAAO,SAAS,MAAM,OAAQ,KAAK;AAAA,QACnC,UAAU,KAAK,UAAU,mBAAmB;AAAA,QAC5C;AAAA,
|
|
1
|
+
{"version":3,"file":"HeadingHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/HeadingHtmlDeserializer.ts"],"sourcesContent":["import { headingElementType } from './HeadingElement'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport const headingHtmlDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tconst match = element.nodeName.match(/^H(?<level>[1-6])$/)\n\t\tif (match !== null) {\n\t\t\tconst isNumbered = (element.getAttribute('style')?.match(/mso-list:\\w+ level\\d+ \\w+/) ?? null) !== null\n\t\t\tconst children = isNumbered ? EditorPasteUtils.wordPasteListItemContent(element.childNodes) : element.childNodes\n\t\t\treturn {\n\t\t\t\ttype: headingElementType,\n\t\t\t\tlevel: parseInt(match.groups!.level),\n\t\t\t\tchildren: next(children, cumulativeTextAttrs),\n\t\t\t\tisNumbered,\n\t\t\t}\n\t\t}\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":";;AAIO,MAAM,0BAAkD;AAAA,EAC9D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC9D,UAAM,QAAQ,QAAQ,SAAS,MAAM,oBAAoB;AACzD,QAAI,UAAU,MAAM;AACb,YAAA,cAAc,QAAQ,aAAa,OAAO,GAAG,MAAM,2BAA2B,KAAK,UAAU;AACnG,YAAM,WAAW,aAAa,iBAAiB,yBAAyB,QAAQ,UAAU,IAAI,QAAQ;AAC/F,aAAA;AAAA,QACN,MAAM;AAAA,QACN,OAAO,SAAS,MAAM,OAAQ,KAAK;AAAA,QACnC,UAAU,KAAK,UAAU,mBAAmB;AAAA,QAC5C;AAAA,MACD;AAAA,IAAA;AAEM,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withHeadings.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/withHeadings.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tejectHeadingElement,\n\tHeadingElement,\n\theadingElementPlugin,\n\theadingElementType,\n\tisHeadingElement,\n} from './HeadingElement'\nimport { headingHtmlDeserializer } from './HeadingHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHeadings = ({ render }: { render: ElementRenderer<HeadingElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tinsertBreak,\n\t\tdeleteBackward,\n\t} = editor\n\n\n\teditor.registerElement(headingElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(headingHtmlDeserializer)\n\n\t// T O D O cache this\n\t// e.getNumberedHeadingSection = function recurse(element): number[] {\n\t// \tconst [topLevelIndex] = ReactEditor.findPath(e, element)\n\t// \tlet previousNumberedHeadingIndex: number = topLevelIndex - 1\n\t//\n\t// \tlet previousNumberedHeading: SlateNode\n\t// \tdo {\n\t// \t\tpreviousNumberedHeading = e.children[previousNumberedHeadingIndex--]\n\t// \t} while (\n\t// \t\tpreviousNumberedHeadingIndex >= 0 &&\n\t// \t\t!(isHeading(previousNumberedHeading) && previousNumberedHeading.isNumbered)\n\t// \t)\n\t//\n\t// \tif (previousNumberedHeadingIndex < 0) {\n\t// \t\treturn Array(element.level).fill(1)\n\t// \t}\n\t// \tconst previousHeadingSection = recurse(previousNumberedHeading as HeadingElement)\n\t//\n\t// \t// Ensures the correct length - this is essentially padRight with zeros\n\t// \tconst normalizedPrevious = previousHeadingSection.concat(Array(element.level).fill(0)).slice(0, element.level)\n\t//\n\t// \tnormalizedPrevious[normalizedPrevious.length - 1]++\n\t//\n\t// \t// The map isn't really necessary for now but would be if we introduced deeper levels\n\t// \treturn normalizedPrevious.map(level => Math.max(level, 1))\n\t// }\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\tif (elementType !== headingElementType) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tif (!editor.selection) {\n\t\t\treturn false\n\t\t}\n\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\tif (closestBlockEntry === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst [closestBlockElement] = closestBlockEntry\n\n\t\treturn (\n\t\t\tSlateElement.isElement(closestBlockElement) && (\n\t\t\t\teditor.isDefaultElement(closestBlockElement)\n\t\t\t\t|| isHeadingElement(closestBlockElement)\n\t\t\t)\n\t\t)\n\t}\n\n\n\n\teditor.insertBreak = () => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tinsertBreak()\n\n\t\t\tconst { selection } = editor\n\n\t\t\tif (selection === null || SlateRange.isExpanded(selection)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [topLevelElement, path] = SlateEditor.node(editor, selection, {\n\t\t\t\tdepth: 1,\n\t\t\t})\n\t\t\tif (isHeadingElement(topLevelElement) && SlateEditor.isEmpty(editor, topLevelElement)) {\n\t\t\t\tejectHeadingElement(editor, path)\n\t\t\t}\n\t\t})\n\t}\n\n\teditor.deleteBackward = unit => {\n\t\tconst selection = editor.selection\n\t\tif (unit !== 'character' || !selection || !SlateRange.isCollapsed(selection) || selection.focus.offset !== 0) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\t// The offset being zero doesn't necessarily imply that selection refers to the start of a heading.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<HeadingElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isHeadingElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, headingPath] = closestNumberedEntry\n\t\tconst headingStartPoint = Editor.start(editor, headingPath)\n\n\t\tif (!Point.equals(headingStartPoint, selection.focus)) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ isNumbered: null }, // null removes the key altogether\n\t\t\t{ at: headingPath },\n\t\t)\n\t}\n\n\treturn editor\n}\n"],"names":["headingElementPlugin","headingHtmlDeserializer","headingElementType","ContemberEditor","SlateElement","isHeadingElement","SlateEditor","SlateRange","ejectHeadingElement","Editor","Point","Transforms"],"mappings":";;;;;;AAYO,MAAM,eAAe,CAAC,EAAE,OAAO,MAAmD,CAAmB,WAAiB;AACtH,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"withHeadings.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/withHeadings.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tejectHeadingElement,\n\tHeadingElement,\n\theadingElementPlugin,\n\theadingElementType,\n\tisHeadingElement,\n} from './HeadingElement'\nimport { headingHtmlDeserializer } from './HeadingHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHeadings = ({ render }: { render: ElementRenderer<HeadingElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tinsertBreak,\n\t\tdeleteBackward,\n\t} = editor\n\n\n\teditor.registerElement(headingElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(headingHtmlDeserializer)\n\n\t// T O D O cache this\n\t// e.getNumberedHeadingSection = function recurse(element): number[] {\n\t// \tconst [topLevelIndex] = ReactEditor.findPath(e, element)\n\t// \tlet previousNumberedHeadingIndex: number = topLevelIndex - 1\n\t//\n\t// \tlet previousNumberedHeading: SlateNode\n\t// \tdo {\n\t// \t\tpreviousNumberedHeading = e.children[previousNumberedHeadingIndex--]\n\t// \t} while (\n\t// \t\tpreviousNumberedHeadingIndex >= 0 &&\n\t// \t\t!(isHeading(previousNumberedHeading) && previousNumberedHeading.isNumbered)\n\t// \t)\n\t//\n\t// \tif (previousNumberedHeadingIndex < 0) {\n\t// \t\treturn Array(element.level).fill(1)\n\t// \t}\n\t// \tconst previousHeadingSection = recurse(previousNumberedHeading as HeadingElement)\n\t//\n\t// \t// Ensures the correct length - this is essentially padRight with zeros\n\t// \tconst normalizedPrevious = previousHeadingSection.concat(Array(element.level).fill(0)).slice(0, element.level)\n\t//\n\t// \tnormalizedPrevious[normalizedPrevious.length - 1]++\n\t//\n\t// \t// The map isn't really necessary for now but would be if we introduced deeper levels\n\t// \treturn normalizedPrevious.map(level => Math.max(level, 1))\n\t// }\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\tif (elementType !== headingElementType) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tif (!editor.selection) {\n\t\t\treturn false\n\t\t}\n\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\tif (closestBlockEntry === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst [closestBlockElement] = closestBlockEntry\n\n\t\treturn (\n\t\t\tSlateElement.isElement(closestBlockElement) && (\n\t\t\t\teditor.isDefaultElement(closestBlockElement)\n\t\t\t\t|| isHeadingElement(closestBlockElement)\n\t\t\t)\n\t\t)\n\t}\n\n\n\n\teditor.insertBreak = () => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tinsertBreak()\n\n\t\t\tconst { selection } = editor\n\n\t\t\tif (selection === null || SlateRange.isExpanded(selection)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [topLevelElement, path] = SlateEditor.node(editor, selection, {\n\t\t\t\tdepth: 1,\n\t\t\t})\n\t\t\tif (isHeadingElement(topLevelElement) && SlateEditor.isEmpty(editor, topLevelElement)) {\n\t\t\t\tejectHeadingElement(editor, path)\n\t\t\t}\n\t\t})\n\t}\n\n\teditor.deleteBackward = unit => {\n\t\tconst selection = editor.selection\n\t\tif (unit !== 'character' || !selection || !SlateRange.isCollapsed(selection) || selection.focus.offset !== 0) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\t// The offset being zero doesn't necessarily imply that selection refers to the start of a heading.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<HeadingElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isHeadingElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, headingPath] = closestNumberedEntry\n\t\tconst headingStartPoint = Editor.start(editor, headingPath)\n\n\t\tif (!Point.equals(headingStartPoint, selection.focus)) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ isNumbered: null }, // null removes the key altogether\n\t\t\t{ at: headingPath },\n\t\t)\n\t}\n\n\treturn editor\n}\n"],"names":["headingElementPlugin","headingHtmlDeserializer","headingElementType","ContemberEditor","SlateElement","isHeadingElement","SlateEditor","SlateRange","ejectHeadingElement","Editor","Point","Transforms"],"mappings":";;;;;;AAYO,MAAM,eAAe,CAAC,EAAE,OAAO,MAAmD,CAAmB,WAAiB;AACtH,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACG;AAGJ,SAAO,gBAAgBA,eAAAA,qBAAqB,EAAE,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AM,EAAE,YAAY,KAAM,CAAA;AAAA,IAAA,CAC1F;AACD,QAAI,yBAAyB,QAAW;AACvC,aAAO,eAAe,IAAI;AAAA,IAAA;AAErB,UAAA,CAAA,EAAG,WAAW,IAAI;AACxB,UAAM,oBAAoBI,MAAA,OAAO,MAAM,QAAQ,WAAW;AAE1D,QAAI,CAACC,MAAM,MAAA,OAAO,mBAAmB,UAAU,KAAK,GAAG;AACtD,aAAO,eAAe,IAAI;AAAA,IAAA;AAEhBC,UAAAA,WAAA;AAAA,MACV;AAAA,MACA,EAAE,YAAY,KAAK;AAAA;AAAA,MACnB,EAAE,IAAI,YAAY;AAAA,IACnB;AAAA,EACD;AAEO,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withHeadings.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/withHeadings.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tejectHeadingElement,\n\tHeadingElement,\n\theadingElementPlugin,\n\theadingElementType,\n\tisHeadingElement,\n} from './HeadingElement'\nimport { headingHtmlDeserializer } from './HeadingHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHeadings = ({ render }: { render: ElementRenderer<HeadingElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tinsertBreak,\n\t\tdeleteBackward,\n\t} = editor\n\n\n\teditor.registerElement(headingElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(headingHtmlDeserializer)\n\n\t// T O D O cache this\n\t// e.getNumberedHeadingSection = function recurse(element): number[] {\n\t// \tconst [topLevelIndex] = ReactEditor.findPath(e, element)\n\t// \tlet previousNumberedHeadingIndex: number = topLevelIndex - 1\n\t//\n\t// \tlet previousNumberedHeading: SlateNode\n\t// \tdo {\n\t// \t\tpreviousNumberedHeading = e.children[previousNumberedHeadingIndex--]\n\t// \t} while (\n\t// \t\tpreviousNumberedHeadingIndex >= 0 &&\n\t// \t\t!(isHeading(previousNumberedHeading) && previousNumberedHeading.isNumbered)\n\t// \t)\n\t//\n\t// \tif (previousNumberedHeadingIndex < 0) {\n\t// \t\treturn Array(element.level).fill(1)\n\t// \t}\n\t// \tconst previousHeadingSection = recurse(previousNumberedHeading as HeadingElement)\n\t//\n\t// \t// Ensures the correct length - this is essentially padRight with zeros\n\t// \tconst normalizedPrevious = previousHeadingSection.concat(Array(element.level).fill(0)).slice(0, element.level)\n\t//\n\t// \tnormalizedPrevious[normalizedPrevious.length - 1]++\n\t//\n\t// \t// The map isn't really necessary for now but would be if we introduced deeper levels\n\t// \treturn normalizedPrevious.map(level => Math.max(level, 1))\n\t// }\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\tif (elementType !== headingElementType) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tif (!editor.selection) {\n\t\t\treturn false\n\t\t}\n\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\tif (closestBlockEntry === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst [closestBlockElement] = closestBlockEntry\n\n\t\treturn (\n\t\t\tSlateElement.isElement(closestBlockElement) && (\n\t\t\t\teditor.isDefaultElement(closestBlockElement)\n\t\t\t\t|| isHeadingElement(closestBlockElement)\n\t\t\t)\n\t\t)\n\t}\n\n\n\n\teditor.insertBreak = () => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tinsertBreak()\n\n\t\t\tconst { selection } = editor\n\n\t\t\tif (selection === null || SlateRange.isExpanded(selection)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [topLevelElement, path] = SlateEditor.node(editor, selection, {\n\t\t\t\tdepth: 1,\n\t\t\t})\n\t\t\tif (isHeadingElement(topLevelElement) && SlateEditor.isEmpty(editor, topLevelElement)) {\n\t\t\t\tejectHeadingElement(editor, path)\n\t\t\t}\n\t\t})\n\t}\n\n\teditor.deleteBackward = unit => {\n\t\tconst selection = editor.selection\n\t\tif (unit !== 'character' || !selection || !SlateRange.isCollapsed(selection) || selection.focus.offset !== 0) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\t// The offset being zero doesn't necessarily imply that selection refers to the start of a heading.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<HeadingElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isHeadingElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, headingPath] = closestNumberedEntry\n\t\tconst headingStartPoint = Editor.start(editor, headingPath)\n\n\t\tif (!Point.equals(headingStartPoint, selection.focus)) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ isNumbered: null }, // null removes the key altogether\n\t\t\t{ at: headingPath },\n\t\t)\n\t}\n\n\treturn editor\n}\n"],"names":["SlateElement","SlateEditor","SlateRange"],"mappings":";;;;AAYO,MAAM,eAAe,CAAC,EAAE,OAAO,MAAmD,CAAmB,WAAiB;AACtH,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"withHeadings.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/headings/withHeadings.ts"],"sourcesContent":["import { Editor, Editor as SlateEditor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tejectHeadingElement,\n\tHeadingElement,\n\theadingElementPlugin,\n\theadingElementType,\n\tisHeadingElement,\n} from './HeadingElement'\nimport { headingHtmlDeserializer } from './HeadingHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHeadings = ({ render }: { render: ElementRenderer<HeadingElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tinsertBreak,\n\t\tdeleteBackward,\n\t} = editor\n\n\n\teditor.registerElement(headingElementPlugin({ render }))\n\teditor.htmlDeserializer.registerPlugin(headingHtmlDeserializer)\n\n\t// T O D O cache this\n\t// e.getNumberedHeadingSection = function recurse(element): number[] {\n\t// \tconst [topLevelIndex] = ReactEditor.findPath(e, element)\n\t// \tlet previousNumberedHeadingIndex: number = topLevelIndex - 1\n\t//\n\t// \tlet previousNumberedHeading: SlateNode\n\t// \tdo {\n\t// \t\tpreviousNumberedHeading = e.children[previousNumberedHeadingIndex--]\n\t// \t} while (\n\t// \t\tpreviousNumberedHeadingIndex >= 0 &&\n\t// \t\t!(isHeading(previousNumberedHeading) && previousNumberedHeading.isNumbered)\n\t// \t)\n\t//\n\t// \tif (previousNumberedHeadingIndex < 0) {\n\t// \t\treturn Array(element.level).fill(1)\n\t// \t}\n\t// \tconst previousHeadingSection = recurse(previousNumberedHeading as HeadingElement)\n\t//\n\t// \t// Ensures the correct length - this is essentially padRight with zeros\n\t// \tconst normalizedPrevious = previousHeadingSection.concat(Array(element.level).fill(0)).slice(0, element.level)\n\t//\n\t// \tnormalizedPrevious[normalizedPrevious.length - 1]++\n\t//\n\t// \t// The map isn't really necessary for now but would be if we introduced deeper levels\n\t// \treturn normalizedPrevious.map(level => Math.max(level, 1))\n\t// }\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\tif (elementType !== headingElementType) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tif (!editor.selection) {\n\t\t\treturn false\n\t\t}\n\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\tif (closestBlockEntry === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst [closestBlockElement] = closestBlockEntry\n\n\t\treturn (\n\t\t\tSlateElement.isElement(closestBlockElement) && (\n\t\t\t\teditor.isDefaultElement(closestBlockElement)\n\t\t\t\t|| isHeadingElement(closestBlockElement)\n\t\t\t)\n\t\t)\n\t}\n\n\n\n\teditor.insertBreak = () => {\n\t\tSlateEditor.withoutNormalizing(editor, () => {\n\t\t\tinsertBreak()\n\n\t\t\tconst { selection } = editor\n\n\t\t\tif (selection === null || SlateRange.isExpanded(selection)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [topLevelElement, path] = SlateEditor.node(editor, selection, {\n\t\t\t\tdepth: 1,\n\t\t\t})\n\t\t\tif (isHeadingElement(topLevelElement) && SlateEditor.isEmpty(editor, topLevelElement)) {\n\t\t\t\tejectHeadingElement(editor, path)\n\t\t\t}\n\t\t})\n\t}\n\n\teditor.deleteBackward = unit => {\n\t\tconst selection = editor.selection\n\t\tif (unit !== 'character' || !selection || !SlateRange.isCollapsed(selection) || selection.focus.offset !== 0) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\t// The offset being zero doesn't necessarily imply that selection refers to the start of a heading.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<HeadingElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isHeadingElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, headingPath] = closestNumberedEntry\n\t\tconst headingStartPoint = Editor.start(editor, headingPath)\n\n\t\tif (!Point.equals(headingStartPoint, selection.focus)) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ isNumbered: null }, // null removes the key altogether\n\t\t\t{ at: headingPath },\n\t\t)\n\t}\n\n\treturn editor\n}\n"],"names":["SlateElement","SlateEditor","SlateRange"],"mappings":";;;;AAYO,MAAM,eAAe,CAAC,EAAE,OAAO,MAAmD,CAAmB,WAAiB;AACtH,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACG;AAGJ,SAAO,gBAAgB,qBAAqB,EAAE,OAAQ,CAAA,CAAC;AAChD,SAAA,iBAAiB,eAAe,uBAAuB;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AACxB,UAAM,oBAAoB,OAAO,MAAM,QAAQ,WAAW;AAE1D,QAAI,CAAC,MAAM,OAAO,mBAAmB,UAAU,KAAK,GAAG;AACtD,aAAO,eAAe,IAAI;AAAA,IAAA;AAEhB,eAAA;AAAA,MACV;AAAA,MACA,EAAE,YAAY,KAAK;AAAA;AAAA,MACnB,EAAE,IAAI,YAAY;AAAA,IACnB;AAAA,EACD;AAEO,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalRuleElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/HorizontalRuleElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Range as SlateRange, Transforms } from 'slate'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const horizontalRuleElementType = 'horizontalRule' as const\n\nexport interface HorizontalRuleElement extends SlateElement {\n\ttype: typeof horizontalRuleElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isHorizontalRuleElement = (element: SlateNode): element is HorizontalRuleElement =>\n\tSlateElement.isElement(element) && element.type === horizontalRuleElementType\n\nexport const isHorizontalRuleElementActive = (editor: Editor) => {\n\tconst [hr] = Editor.nodes(editor, { match: isHorizontalRuleElement })\n\treturn !!hr\n}\n\nexport const horizontalRuleElementPlugin = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }): EditorElementPlugin<HorizontalRuleElement> => ({\n\ttype: horizontalRuleElementType,\n\trender,\n\tisVoid: true,\n\ttoggleElement: ({ editor }) => {\n\t\tif (isHorizontalRuleElementActive(editor)) {\n\t\t\tremoveHorizontalRule(editor)\n\t\t} else {\n\t\t\tinsertHorizontalRule(editor)\n\t\t}\n\t},\n})\n\nconst removeHorizontalRule = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isHorizontalRuleElement })\n}\n\nconst insertHorizontalRule = (editor: Editor) => {\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\n\tif (!isCollapsed || isHorizontalRuleElementActive(editor)) {\n\t\treturn\n\t}\n\tconst horizontalRule: HorizontalRuleElement = {\n\t\ttype: horizontalRuleElementType,\n\t\tchildren: [{ text: '' }],\n\t}\n\tTransforms.insertNodes(editor, horizontalRule)\n}\n"],"names":["SlateElement","Editor","Transforms","SlateRange"],"mappings":";;;AAGO,MAAM,4BAA4B;AAO5B,MAAA,0BAA0B,CAAC,YACvCA,
|
|
1
|
+
{"version":3,"file":"HorizontalRuleElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/HorizontalRuleElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Range as SlateRange, Transforms } from 'slate'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const horizontalRuleElementType = 'horizontalRule' as const\n\nexport interface HorizontalRuleElement extends SlateElement {\n\ttype: typeof horizontalRuleElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isHorizontalRuleElement = (element: SlateNode): element is HorizontalRuleElement =>\n\tSlateElement.isElement(element) && element.type === horizontalRuleElementType\n\nexport const isHorizontalRuleElementActive = (editor: Editor) => {\n\tconst [hr] = Editor.nodes(editor, { match: isHorizontalRuleElement })\n\treturn !!hr\n}\n\nexport const horizontalRuleElementPlugin = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }): EditorElementPlugin<HorizontalRuleElement> => ({\n\ttype: horizontalRuleElementType,\n\trender,\n\tisVoid: true,\n\ttoggleElement: ({ editor }) => {\n\t\tif (isHorizontalRuleElementActive(editor)) {\n\t\t\tremoveHorizontalRule(editor)\n\t\t} else {\n\t\t\tinsertHorizontalRule(editor)\n\t\t}\n\t},\n})\n\nconst removeHorizontalRule = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isHorizontalRuleElement })\n}\n\nconst insertHorizontalRule = (editor: Editor) => {\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\n\tif (!isCollapsed || isHorizontalRuleElementActive(editor)) {\n\t\treturn\n\t}\n\tconst horizontalRule: HorizontalRuleElement = {\n\t\ttype: horizontalRuleElementType,\n\t\tchildren: [{ text: '' }],\n\t}\n\tTransforms.insertNodes(editor, horizontalRule)\n}\n"],"names":["SlateElement","Editor","Transforms","SlateRange"],"mappings":";;;AAGO,MAAM,4BAA4B;AAO5B,MAAA,0BAA0B,CAAC,YACvCA,MAAA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExC,MAAA,gCAAgC,CAAC,WAAmB;AAC1D,QAAA,CAAC,EAAE,IAAIC,aAAO,MAAM,QAAQ,EAAE,OAAO,yBAAyB;AACpE,SAAO,CAAC,CAAC;AACV;AAEO,MAAM,8BAA8B,CAAC,EAAE,cAA8G;AAAA,EAC3J,MAAM;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,eAAe,CAAC,EAAE,aAAa;AAC1B,QAAA,8BAA8B,MAAM,GAAG;AAC1C,2BAAqB,MAAM;AAAA,IAAA,OACrB;AACN,2BAAqB,MAAM;AAAA,IAAA;AAAA,EAC5B;AAEF;AAEA,MAAM,uBAAuB,CAAC,WAAmB;AAChDC,QAAAA,WAAW,YAAY,QAAQ,EAAE,OAAO,yBAAyB;AAClE;AAEA,MAAM,uBAAuB,CAAC,WAAmB;AAChD,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YAAYC,MAAAA,MAAW,YAAY,SAAU,IAAI;AAErE,MAAI,CAAC,eAAe,8BAA8B,MAAM,GAAG;AAC1D;AAAA,EAAA;AAED,QAAM,iBAAwC;AAAA,IAC7C,MAAM;AAAA,IACN,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA;AAAA,EACxB;AACWD,mBAAA,YAAY,QAAQ,cAAc;AAC9C;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalRuleElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/HorizontalRuleElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Range as SlateRange, Transforms } from 'slate'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const horizontalRuleElementType = 'horizontalRule' as const\n\nexport interface HorizontalRuleElement extends SlateElement {\n\ttype: typeof horizontalRuleElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isHorizontalRuleElement = (element: SlateNode): element is HorizontalRuleElement =>\n\tSlateElement.isElement(element) && element.type === horizontalRuleElementType\n\nexport const isHorizontalRuleElementActive = (editor: Editor) => {\n\tconst [hr] = Editor.nodes(editor, { match: isHorizontalRuleElement })\n\treturn !!hr\n}\n\nexport const horizontalRuleElementPlugin = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }): EditorElementPlugin<HorizontalRuleElement> => ({\n\ttype: horizontalRuleElementType,\n\trender,\n\tisVoid: true,\n\ttoggleElement: ({ editor }) => {\n\t\tif (isHorizontalRuleElementActive(editor)) {\n\t\t\tremoveHorizontalRule(editor)\n\t\t} else {\n\t\t\tinsertHorizontalRule(editor)\n\t\t}\n\t},\n})\n\nconst removeHorizontalRule = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isHorizontalRuleElement })\n}\n\nconst insertHorizontalRule = (editor: Editor) => {\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\n\tif (!isCollapsed || isHorizontalRuleElementActive(editor)) {\n\t\treturn\n\t}\n\tconst horizontalRule: HorizontalRuleElement = {\n\t\ttype: horizontalRuleElementType,\n\t\tchildren: [{ text: '' }],\n\t}\n\tTransforms.insertNodes(editor, horizontalRule)\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";AAGO,MAAM,4BAA4B;AAO5B,MAAA,0BAA0B,CAAC,YACvCA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExC,MAAA,gCAAgC,CAAC,WAAmB;AAC1D,QAAA,CAAC,EAAE,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"HorizontalRuleElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/HorizontalRuleElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Range as SlateRange, Transforms } from 'slate'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const horizontalRuleElementType = 'horizontalRule' as const\n\nexport interface HorizontalRuleElement extends SlateElement {\n\ttype: typeof horizontalRuleElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isHorizontalRuleElement = (element: SlateNode): element is HorizontalRuleElement =>\n\tSlateElement.isElement(element) && element.type === horizontalRuleElementType\n\nexport const isHorizontalRuleElementActive = (editor: Editor) => {\n\tconst [hr] = Editor.nodes(editor, { match: isHorizontalRuleElement })\n\treturn !!hr\n}\n\nexport const horizontalRuleElementPlugin = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }): EditorElementPlugin<HorizontalRuleElement> => ({\n\ttype: horizontalRuleElementType,\n\trender,\n\tisVoid: true,\n\ttoggleElement: ({ editor }) => {\n\t\tif (isHorizontalRuleElementActive(editor)) {\n\t\t\tremoveHorizontalRule(editor)\n\t\t} else {\n\t\t\tinsertHorizontalRule(editor)\n\t\t}\n\t},\n})\n\nconst removeHorizontalRule = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isHorizontalRuleElement })\n}\n\nconst insertHorizontalRule = (editor: Editor) => {\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\n\tif (!isCollapsed || isHorizontalRuleElementActive(editor)) {\n\t\treturn\n\t}\n\tconst horizontalRule: HorizontalRuleElement = {\n\t\ttype: horizontalRuleElementType,\n\t\tchildren: [{ text: '' }],\n\t}\n\tTransforms.insertNodes(editor, horizontalRule)\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";AAGO,MAAM,4BAA4B;AAO5B,MAAA,0BAA0B,CAAC,YACvCA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExC,MAAA,gCAAgC,CAAC,WAAmB;AAC1D,QAAA,CAAC,EAAE,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,yBAAyB;AACpE,SAAO,CAAC,CAAC;AACV;AAEO,MAAM,8BAA8B,CAAC,EAAE,cAA8G;AAAA,EAC3J,MAAM;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,eAAe,CAAC,EAAE,aAAa;AAC1B,QAAA,8BAA8B,MAAM,GAAG;AAC1C,2BAAqB,MAAM;AAAA,IAAA,OACrB;AACN,2BAAqB,MAAM;AAAA,IAAA;AAAA,EAC5B;AAEF;AAEA,MAAM,uBAAuB,CAAC,WAAmB;AAChD,aAAW,YAAY,QAAQ,EAAE,OAAO,yBAAyB;AAClE;AAEA,MAAM,uBAAuB,CAAC,WAAmB;AAChD,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YAAYC,MAAW,YAAY,SAAU,IAAI;AAErE,MAAI,CAAC,eAAe,8BAA8B,MAAM,GAAG;AAC1D;AAAA,EAAA;AAED,QAAM,iBAAwC;AAAA,IAC7C,MAAM;AAAA,IACN,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA;AAAA,EACxB;AACW,aAAA,YAAY,QAAQ,cAAc;AAC9C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withHorizontalRules.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/withHorizontalRules.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, NodeEntry, Range as SlateRange, Text, Transforms } from 'slate'\nimport { HorizontalRuleElement, horizontalRuleElementPlugin, horizontalRuleElementType } from './HorizontalRuleElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHorizontalRules = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(horizontalRuleElementPlugin({ render }))\n\n\teditor.insertText = text => {\n\t\tinsertText(text)\n\t\tif (text !== '-') {\n\t\t\treturn\n\t\t}\n\t\tconst selection = editor.selection\n\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\treturn\n\t\t}\n\t\tconst focusPoint = selection.focus\n\n\t\tif (focusPoint.offset < 3) {\n\t\t\treturn\n\t\t}\n\t\tconst [targetTextNode, targetPath] = Editor.node(editor, focusPoint)\n\t\tif (!Text.isText(targetTextNode)) {\n\t\t\treturn\n\t\t}\n\t\tconst slice = targetTextNode.text.slice(focusPoint.offset - 3, focusPoint.offset)\n\t\tif (slice !== '---') {\n\t\t\treturn\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet closestBlockEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\t\tat: focusPoint,\n\t\t\t\tmode: 'lowest',\n\t\t\t\tmatch: matchedNode =>\n\t\t\t\t\tSlateElement.isElement(matchedNode) && !editor.isInline(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t\t})\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\t\t\tif (closestBlockPath.length !== 1 || SlateNode.string(closestBlock) !== '---') {\n\t\t\t\treturn // We only support horizontal rules at the very top level.\n\t\t\t}\n\n\t\t\t// First insert the rule after the closest block\n\t\t\tconst horizontalRule: HorizontalRuleElement = {\n\t\t\t\ttype: horizontalRuleElementType,\n\t\t\t\tchildren: [{ text: '' }],\n\t\t\t}\n\t\t\tconst newHrPath = [...closestBlockPath.slice(0, -1), closestBlockPath[closestBlockPath.length - 1] + 1]\n\t\t\tTransforms.insertNodes(editor, horizontalRule, {\n\t\t\t\tat: newHrPath,\n\t\t\t})\n\n\t\t\t// Remove the '---'\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\n\t\t\tconst pointAfter = Editor.after(editor, newHrPath)\n\t\t\tif (pointAfter) {\n\t\t\t\tTransforms.select(editor, pointAfter)\n\t\t\t} else {\n\t\t\t\t// There's nothing to select so we're likely at the end. Insert a new default element then.\n\t\t\t\tconst targetPath = [...newHrPath.slice(0, -1), newHrPath[newHrPath.length - 1] + 1]\n\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\t\tat: targetPath,\n\t\t\t\t\tselect: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Lastly, if remove the closest block. Need to update the entry though.\n\t\t\tclosestBlockEntry = Editor.node(editor, closestBlockPath)\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: closestBlockEntry[1],\n\t\t\t})\n\t\t})\n\t}\n\n\treturn editor\n}\n"],"names":["horizontalRuleElementPlugin","SlateRange","Editor","Text","SlateElement","SlateNode","horizontalRuleElementType","Transforms","targetPath"],"mappings":";;;;AAIO,MAAM,sBAAsB,CAAC,EAAE,OAAO,MAA0D,CAAmB,WAAiB;AACpI,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withHorizontalRules.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/withHorizontalRules.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, NodeEntry, Range as SlateRange, Text, Transforms } from 'slate'\nimport { HorizontalRuleElement, horizontalRuleElementPlugin, horizontalRuleElementType } from './HorizontalRuleElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHorizontalRules = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(horizontalRuleElementPlugin({ render }))\n\n\teditor.insertText = text => {\n\t\tinsertText(text)\n\t\tif (text !== '-') {\n\t\t\treturn\n\t\t}\n\t\tconst selection = editor.selection\n\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\treturn\n\t\t}\n\t\tconst focusPoint = selection.focus\n\n\t\tif (focusPoint.offset < 3) {\n\t\t\treturn\n\t\t}\n\t\tconst [targetTextNode, targetPath] = Editor.node(editor, focusPoint)\n\t\tif (!Text.isText(targetTextNode)) {\n\t\t\treturn\n\t\t}\n\t\tconst slice = targetTextNode.text.slice(focusPoint.offset - 3, focusPoint.offset)\n\t\tif (slice !== '---') {\n\t\t\treturn\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet closestBlockEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\t\tat: focusPoint,\n\t\t\t\tmode: 'lowest',\n\t\t\t\tmatch: matchedNode =>\n\t\t\t\t\tSlateElement.isElement(matchedNode) && !editor.isInline(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t\t})\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\t\t\tif (closestBlockPath.length !== 1 || SlateNode.string(closestBlock) !== '---') {\n\t\t\t\treturn // We only support horizontal rules at the very top level.\n\t\t\t}\n\n\t\t\t// First insert the rule after the closest block\n\t\t\tconst horizontalRule: HorizontalRuleElement = {\n\t\t\t\ttype: horizontalRuleElementType,\n\t\t\t\tchildren: [{ text: '' }],\n\t\t\t}\n\t\t\tconst newHrPath = [...closestBlockPath.slice(0, -1), closestBlockPath[closestBlockPath.length - 1] + 1]\n\t\t\tTransforms.insertNodes(editor, horizontalRule, {\n\t\t\t\tat: newHrPath,\n\t\t\t})\n\n\t\t\t// Remove the '---'\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\n\t\t\tconst pointAfter = Editor.after(editor, newHrPath)\n\t\t\tif (pointAfter) {\n\t\t\t\tTransforms.select(editor, pointAfter)\n\t\t\t} else {\n\t\t\t\t// There's nothing to select so we're likely at the end. Insert a new default element then.\n\t\t\t\tconst targetPath = [...newHrPath.slice(0, -1), newHrPath[newHrPath.length - 1] + 1]\n\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\t\tat: targetPath,\n\t\t\t\t\tselect: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Lastly, if remove the closest block. Need to update the entry though.\n\t\t\tclosestBlockEntry = Editor.node(editor, closestBlockPath)\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: closestBlockEntry[1],\n\t\t\t})\n\t\t})\n\t}\n\n\treturn editor\n}\n"],"names":["horizontalRuleElementPlugin","SlateRange","Editor","Text","SlateElement","SlateNode","horizontalRuleElementType","Transforms","targetPath"],"mappings":";;;;AAIO,MAAM,sBAAsB,CAAC,EAAE,OAAO,MAA0D,CAAmB,WAAiB;AACpI,QAAA,EAAE,eAAe;AAEvB,SAAO,gBAAgBA,sBAAAA,4BAA4B,EAAE,OAAQ,CAAA,CAAC;AAE9D,SAAO,aAAa,CAAQ,SAAA;AAC3B,eAAW,IAAI;AACf,QAAI,SAAS,KAAK;AACjB;AAAA,IAAA;AAED,UAAM,YAAY,OAAO;AACzB,QAAI,CAAC,aAAa,CAACC,MAAW,MAAA,YAAY,SAAS,GAAG;AACrD;AAAA,IAAA;AAED,UAAM,aAAa,UAAU;AAEzB,QAAA,WAAW,SAAS,GAAG;AAC1B;AAAA,IAAA;AAED,UAAM,CAAC,gBAAgB,UAAU,IAAIC,MAAO,OAAA,KAAK,QAAQ,UAAU;AACnE,QAAI,CAACC,MAAA,KAAK,OAAO,cAAc,GAAG;AACjC;AAAA,IAAA;AAEK,UAAA,QAAQ,eAAe,KAAK,MAAM,WAAW,SAAS,GAAG,WAAW,MAAM;AAChF,QAAI,UAAU,OAAO;AACpB;AAAA,IAAA;AAGMD,iBAAA,mBAAmB,QAAQ,MAAM;AACnC,UAAA,oBAA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AkB,CAAC;AAAA,MAAA,CACvB;AAAA,IAAA,CACD;AAAA,EACF;AAEO,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withHorizontalRules.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/withHorizontalRules.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, NodeEntry, Range as SlateRange, Text, Transforms } from 'slate'\nimport { HorizontalRuleElement, horizontalRuleElementPlugin, horizontalRuleElementType } from './HorizontalRuleElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHorizontalRules = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(horizontalRuleElementPlugin({ render }))\n\n\teditor.insertText = text => {\n\t\tinsertText(text)\n\t\tif (text !== '-') {\n\t\t\treturn\n\t\t}\n\t\tconst selection = editor.selection\n\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\treturn\n\t\t}\n\t\tconst focusPoint = selection.focus\n\n\t\tif (focusPoint.offset < 3) {\n\t\t\treturn\n\t\t}\n\t\tconst [targetTextNode, targetPath] = Editor.node(editor, focusPoint)\n\t\tif (!Text.isText(targetTextNode)) {\n\t\t\treturn\n\t\t}\n\t\tconst slice = targetTextNode.text.slice(focusPoint.offset - 3, focusPoint.offset)\n\t\tif (slice !== '---') {\n\t\t\treturn\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet closestBlockEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\t\tat: focusPoint,\n\t\t\t\tmode: 'lowest',\n\t\t\t\tmatch: matchedNode =>\n\t\t\t\t\tSlateElement.isElement(matchedNode) && !editor.isInline(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t\t})\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\t\t\tif (closestBlockPath.length !== 1 || SlateNode.string(closestBlock) !== '---') {\n\t\t\t\treturn // We only support horizontal rules at the very top level.\n\t\t\t}\n\n\t\t\t// First insert the rule after the closest block\n\t\t\tconst horizontalRule: HorizontalRuleElement = {\n\t\t\t\ttype: horizontalRuleElementType,\n\t\t\t\tchildren: [{ text: '' }],\n\t\t\t}\n\t\t\tconst newHrPath = [...closestBlockPath.slice(0, -1), closestBlockPath[closestBlockPath.length - 1] + 1]\n\t\t\tTransforms.insertNodes(editor, horizontalRule, {\n\t\t\t\tat: newHrPath,\n\t\t\t})\n\n\t\t\t// Remove the '---'\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\n\t\t\tconst pointAfter = Editor.after(editor, newHrPath)\n\t\t\tif (pointAfter) {\n\t\t\t\tTransforms.select(editor, pointAfter)\n\t\t\t} else {\n\t\t\t\t// There's nothing to select so we're likely at the end. Insert a new default element then.\n\t\t\t\tconst targetPath = [...newHrPath.slice(0, -1), newHrPath[newHrPath.length - 1] + 1]\n\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\t\tat: targetPath,\n\t\t\t\t\tselect: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Lastly, if remove the closest block. Need to update the entry though.\n\t\t\tclosestBlockEntry = Editor.node(editor, closestBlockPath)\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: closestBlockEntry[1],\n\t\t\t})\n\t\t})\n\t}\n\n\treturn editor\n}\n"],"names":["SlateRange","SlateElement","SlateNode","targetPath"],"mappings":";;AAIO,MAAM,sBAAsB,CAAC,EAAE,OAAO,MAA0D,CAAmB,WAAiB;AACpI,QAAA,EAAE,
|
|
1
|
+
{"version":3,"file":"withHorizontalRules.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/horizonalRules/withHorizontalRules.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, NodeEntry, Range as SlateRange, Text, Transforms } from 'slate'\nimport { HorizontalRuleElement, horizontalRuleElementPlugin, horizontalRuleElementType } from './HorizontalRuleElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withHorizontalRules = ({ render }: { render: ElementRenderer<HorizontalRuleElement> }) => <E extends Editor>(editor: E): E => {\n\tconst { insertText } = editor\n\n\teditor.registerElement(horizontalRuleElementPlugin({ render }))\n\n\teditor.insertText = text => {\n\t\tinsertText(text)\n\t\tif (text !== '-') {\n\t\t\treturn\n\t\t}\n\t\tconst selection = editor.selection\n\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\treturn\n\t\t}\n\t\tconst focusPoint = selection.focus\n\n\t\tif (focusPoint.offset < 3) {\n\t\t\treturn\n\t\t}\n\t\tconst [targetTextNode, targetPath] = Editor.node(editor, focusPoint)\n\t\tif (!Text.isText(targetTextNode)) {\n\t\t\treturn\n\t\t}\n\t\tconst slice = targetTextNode.text.slice(focusPoint.offset - 3, focusPoint.offset)\n\t\tif (slice !== '---') {\n\t\t\treturn\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet closestBlockEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\t\tat: focusPoint,\n\t\t\t\tmode: 'lowest',\n\t\t\t\tmatch: matchedNode =>\n\t\t\t\t\tSlateElement.isElement(matchedNode) && !editor.isInline(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t\t})\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\t\t\tif (closestBlockPath.length !== 1 || SlateNode.string(closestBlock) !== '---') {\n\t\t\t\treturn // We only support horizontal rules at the very top level.\n\t\t\t}\n\n\t\t\t// First insert the rule after the closest block\n\t\t\tconst horizontalRule: HorizontalRuleElement = {\n\t\t\t\ttype: horizontalRuleElementType,\n\t\t\t\tchildren: [{ text: '' }],\n\t\t\t}\n\t\t\tconst newHrPath = [...closestBlockPath.slice(0, -1), closestBlockPath[closestBlockPath.length - 1] + 1]\n\t\t\tTransforms.insertNodes(editor, horizontalRule, {\n\t\t\t\tat: newHrPath,\n\t\t\t})\n\n\t\t\t// Remove the '---'\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\t\t\teditor.deleteBackward('character')\n\n\t\t\tconst pointAfter = Editor.after(editor, newHrPath)\n\t\t\tif (pointAfter) {\n\t\t\t\tTransforms.select(editor, pointAfter)\n\t\t\t} else {\n\t\t\t\t// There's nothing to select so we're likely at the end. Insert a new default element then.\n\t\t\t\tconst targetPath = [...newHrPath.slice(0, -1), newHrPath[newHrPath.length - 1] + 1]\n\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\t\tat: targetPath,\n\t\t\t\t\tselect: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Lastly, if remove the closest block. Need to update the entry though.\n\t\t\tclosestBlockEntry = Editor.node(editor, closestBlockPath)\n\t\t\tif (!closestBlockEntry) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: closestBlockEntry[1],\n\t\t\t})\n\t\t})\n\t}\n\n\treturn editor\n}\n"],"names":["SlateRange","SlateElement","SlateNode","targetPath"],"mappings":";;AAIO,MAAM,sBAAsB,CAAC,EAAE,OAAO,MAA0D,CAAmB,WAAiB;AACpI,QAAA,EAAE,eAAe;AAEvB,SAAO,gBAAgB,4BAA4B,EAAE,OAAQ,CAAA,CAAC;AAE9D,SAAO,aAAa,CAAQ,SAAA;AAC3B,eAAW,IAAI;AACf,QAAI,SAAS,KAAK;AACjB;AAAA,IAAA;AAED,UAAM,YAAY,OAAO;AACzB,QAAI,CAAC,aAAa,CAACA,MAAW,YAAY,SAAS,GAAG;AACrD;AAAA,IAAA;AAED,UAAM,aAAa,U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