@contember/react-slate-editor-base 2.0.0-alpha.9 → 2.0.0-beta.2
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 +3 -3
- package/dist/development/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/development/src/components/RichTextEditor.js +3 -3
- 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 +36 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js +36 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -0
- 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 +2 -0
- package/dist/development/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.js +2 -0
- 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 +3 -3
- package/dist/production/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/production/src/components/RichTextEditor.js +3 -3
- 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 +36 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js +36 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -0
- 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 +2 -0
- package/dist/production/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.js +2 -0
- 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/editor/createEditor.d.ts +1 -1
- package/dist/types/editor/createEditor.d.ts.map +1 -1
- package/dist/types/plugins/element/tables/TableHtmlDeserializer.d.ts +3 -0
- package/dist/types/plugins/element/tables/TableHtmlDeserializer.d.ts.map +1 -0
- package/dist/types/plugins/element/tables/withTables.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/plugins.d.ts +1 -2
- package/dist/types/types/plugins.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/components/RichTextEditor.tsx +3 -3
- package/src/editor/createEditor.ts +1 -1
- package/src/plugins/element/tables/TableHtmlDeserializer.ts +37 -0
- package/src/plugins/element/tables/withTables.ts +3 -0
- package/src/tsconfig.json +0 -1
- package/src/types/plugins.ts +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLists.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/withLists.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tPath as SlatePath,\n\tRange as SlateRange,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement, ListItemElement, listItemElementPlugin } from './ListItemElement'\nimport { OrderedListElement, orderedListElementPlugin } from './OrderedListElement'\nimport { dedentListItem, indentListItem } from './transforms'\nimport { UnorderedListElement, unorderedListElementPlugin } from './UnorderedListElement'\nimport { isListElement } from './ListElement'\nimport { listHtmlDeserializerFactory } from './ListHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withLists = ({ renderListItem, renderUnorderedList, renderOrderedList }: {\n\trenderListItem: ElementRenderer<ListItemElement>\n\trenderOrderedList: ElementRenderer<OrderedListElement>\n\trenderUnorderedList: ElementRenderer<UnorderedListElement>\n}) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tinsertBreak,\n\t\tonKeyDown,\n\t} = editor\n\n\teditor.registerElement(listItemElementPlugin({ render: renderListItem }))\n\teditor.registerElement(orderedListElementPlugin({ render: renderOrderedList }))\n\teditor.registerElement(unorderedListElementPlugin({ render: renderUnorderedList }))\n\n\teditor.htmlDeserializer.registerPlugin(listHtmlDeserializerFactory())\n\n\tObject.assign<Editor, Partial<Editor>>(editor, {\n\t\tinsertBreak: () => {\n\t\t\tconst { selection } = editor\n\n\t\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\n\t\t\tlet containingListItem: ListItemElement\n\t\t\tlet containingListItemPath: SlatePath\n\n\t\t\tif (!isListItemElement(closestBlock)) {\n\t\t\t\tif (closestBlockPath.length < 2) {\n\t\t\t\t\t// This block cannot be inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\n\t\t\t\tcontainingListItemPath = SlatePath.parent(closestBlockPath)\n\t\t\t\tconst closestListItem = SlateNode.get(editor, containingListItemPath)\n\n\t\t\t\tif (!isListItemElement(closestListItem)) {\n\t\t\t\t\t// The block is not inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tcontainingListItem = closestListItem\n\t\t\t} else {\n\t\t\t\tcontainingListItem = closestBlock\n\t\t\t\tcontainingListItemPath = closestBlockPath\n\t\t\t}\n\n\t\t\tif (SlateNode.string(containingListItem) !== '') {\n\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\talways: true,\n\t\t\t\t\tat: selection.focus,\n\t\t\t\t\tmatch: node => isListItemElement(node),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// We're in a list and want to leave this list.\n\n\t\t\tconst containingListPath = SlatePath.parent(containingListItemPath)\n\t\t\tconst containingList = SlateNode.get(editor, containingListPath)\n\n\t\t\tif (!isListElement(containingList)) {\n\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\n\t\t\tconst followingListItemPath = SlatePath.next(containingListItemPath)\n\t\t\tconst hasFollowingListItem = SlateNode.has(editor, followingListItemPath)\n\n\t\t\tif (hasFollowingListItem) {\n\t\t\t\tconst followingListItemNode = SlateNode.get(editor, followingListItemPath)\n\t\t\t\tif (!isListItemElement(followingListItemNode)) {\n\t\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tif (containingListItemPath[containingListItemPath.length - 1] === 0) {\n\t\t\t\t\t// We're at the beginning of a list\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: containingListPath, select: true })\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\t// We're in the middle of a list.\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.splitNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// We're at the end of a list.\n\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\tonKeyDown: event => {\n\t\t\t// TODO this should also work for expanded selections\n\t\t\tif (\n\t\t\t\t(event.key !== 'Tab' && event.key !== 'Enter') ||\n\t\t\t\t!editor.selection ||\n\t\t\t\t!SlateRange.isCollapsed(editor.selection)\n\t\t\t) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tconst selection = editor.selection\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor, { at: selection.focus })\n\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tlet [closestBlockElement, closestBlockPath] = closestBlockEntry\n\t\t\tif (!SlateElement.isElement(closestBlockElement)) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\n\t\t\tif (event.key === 'Tab') {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\t[closestBlockElement, closestBlockPath] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t}\n\t\t\t\tif (!isListItemElement(closestBlockElement)) {\n\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t}\n\t\t\t\tconst succeeded = event.shiftKey\n\t\t\t\t\t? dedentListItem(editor, closestBlockElement, closestBlockPath)\n\t\t\t\t\t: indentListItem(editor, closestBlockElement, closestBlockPath)\n\n\t\t\t\tif (succeeded) {\n\t\t\t\t\treturn event.preventDefault()\n\t\t\t\t}\n\t\t\t} else if (event.key === 'Enter' && event.shiftKey) {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\tconst [listItem] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t\tif (!isListItemElement(listItem)) {\n\t\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t\t}\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\t\talways: true,\n\t\t\t\t\t\tat: selection.focus,\n\t\t\t\t\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && editor.isDefaultElement(node),\n\t\t\t\t\t})\n\t\t\t\t} else if (isListItemElement(closestBlockElement)) {\n\t\t\t\t\t// We want to create a newline but the closest block is the list item.\n\t\t\t\t\t// This should mean that it only contains inlines. Hence we wrap them in a default element\n\t\t\t\t\t// and then split it.\n\t\t\t\t\tconst [listItemStart, listItemEnd] = Editor.edges(editor, closestBlockPath)\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tanchor: listItemStart,\n\t\t\t\t\t\t\t\tfocus: listItemEnd,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst relative = SlatePath.relative(selection.focus.path, closestBlockPath)\n\t\t\t\t\t\tTransforms.splitNodes(editor, {\n\t\t\t\t\t\t\t// The zero should be the newly created default element.\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tpath: [...closestBlockPath, 0, ...relative],\n\t\t\t\t\t\t\t\toffset: selection.focus.offset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\talways: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onKeyDown(event)\n\t\t},\n\t})\n\n\n\n\treturn editor\n}\n"],"names":["listItemElementPlugin","orderedListElementPlugin","unorderedListElementPlugin","listHtmlDeserializerFactory","SlateRange","ContemberEditor","isListItemElement","SlatePath","SlateNode","Transforms","isListElement","Editor","SlateElement","dedentListItem","indentListItem","Text"],"mappings":";;;;;;;;;;;AAkBa,MAAA,YAAY,CAAC,EAAE,gBAAgB,qBAAqB,kBAAkB,MAI7E,CAAmB,WAAiB;AACnC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EACG,IAAA;AAEJ,SAAO,gBAAgBA,gBAAs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eAAe;AACd,iBAAAG,MAAA,WAAW,WAAW,QAAQ;AAAA,YACpC,QAAQ;AAAA,YACR,IAAI,UAAU;AAAA,YACd,OAAO,CAAA,SAAQG,MAAa,QAAA,UAAU,IAAI,KAAKD,MAAAA,OAAO,QAAQ,QAAQ,IAAI,KAAK,OAAO,iBAAiB,IAAI;AAAA,UAAA,CAC3G;AAAA,QAAA,WACSL,gBAAAA,kBAAkB,mBAAmB,GAAG;AAIlD,gBAAM,CAAC,eAAe,WAAW,IAAIK,MAAO,OAAA,MAAM,QAAQ,gBAAgB;AAC1E,gBAAM,eAAe;AACd,iBAAAA,MAAA,OAAO,mBAAmB,QAAQ,MAAM;AAC9CF,kBAAA,WAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,cAC7D,OAAO,CAAA,SAAQM,WAAK,OAAO,IAAI,KAAMH,cAAa,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI;AAAA,cACzF,IAAI;AAAA,gBACH,QAAQ;AAAA,gBACR,OAAO;AAAA,cACR;AAAA,YAAA,CACA;AACD,kBAAM,WAAWL,MAAAA,KAAU,SAAS,UAAU,MAAM,MAAM,gBAAgB;AAC1EE,kBAAA,WAAW,WAAW,QAAQ;AAAA;AAAA,cAE7B,IAAI;AAAA,gBACH,MAAM,CAAC,GAAG,kBAAkB,GAAG,GAAG,QAAQ;AAAA,gBAC1C,QAAQ,UAAU,MAAM;AAAA,cACzB;AAAA,cACA,QAAQ;AAAA,YAAA,CACR;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACD;AACA,aAAO,UAAU,KAAK;AAAA,IACvB;AAAA,EAAA,CACA;AAIM,SAAA;AACR;;"}
|
|
1
|
+
{"version":3,"file":"withLists.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/withLists.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tPath as SlatePath,\n\tRange as SlateRange,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement, ListItemElement, listItemElementPlugin } from './ListItemElement'\nimport { OrderedListElement, orderedListElementPlugin } from './OrderedListElement'\nimport { dedentListItem, indentListItem } from './transforms'\nimport { UnorderedListElement, unorderedListElementPlugin } from './UnorderedListElement'\nimport { isListElement } from './ListElement'\nimport { listHtmlDeserializerFactory } from './ListHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withLists = ({ renderListItem, renderUnorderedList, renderOrderedList }: {\n\trenderListItem: ElementRenderer<ListItemElement>\n\trenderOrderedList: ElementRenderer<OrderedListElement>\n\trenderUnorderedList: ElementRenderer<UnorderedListElement>\n}) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tinsertBreak,\n\t\tonKeyDown,\n\t} = editor\n\n\teditor.registerElement(listItemElementPlugin({ render: renderListItem }))\n\teditor.registerElement(orderedListElementPlugin({ render: renderOrderedList }))\n\teditor.registerElement(unorderedListElementPlugin({ render: renderUnorderedList }))\n\n\teditor.htmlDeserializer.registerPlugin(listHtmlDeserializerFactory())\n\n\tObject.assign<Editor, Partial<Editor>>(editor, {\n\t\tinsertBreak: () => {\n\t\t\tconst { selection } = editor\n\n\t\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\n\t\t\tlet containingListItem: ListItemElement\n\t\t\tlet containingListItemPath: SlatePath\n\n\t\t\tif (!isListItemElement(closestBlock)) {\n\t\t\t\tif (closestBlockPath.length < 2) {\n\t\t\t\t\t// This block cannot be inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\n\t\t\t\tcontainingListItemPath = SlatePath.parent(closestBlockPath)\n\t\t\t\tconst closestListItem = SlateNode.get(editor, containingListItemPath)\n\n\t\t\t\tif (!isListItemElement(closestListItem)) {\n\t\t\t\t\t// The block is not inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tcontainingListItem = closestListItem\n\t\t\t} else {\n\t\t\t\tcontainingListItem = closestBlock\n\t\t\t\tcontainingListItemPath = closestBlockPath\n\t\t\t}\n\n\t\t\tif (SlateNode.string(containingListItem) !== '') {\n\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\talways: true,\n\t\t\t\t\tat: selection.focus,\n\t\t\t\t\tmatch: node => isListItemElement(node),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// We're in a list and want to leave this list.\n\n\t\t\tconst containingListPath = SlatePath.parent(containingListItemPath)\n\t\t\tconst containingList = SlateNode.get(editor, containingListPath)\n\n\t\t\tif (!isListElement(containingList)) {\n\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\n\t\t\tconst followingListItemPath = SlatePath.next(containingListItemPath)\n\t\t\tconst hasFollowingListItem = SlateNode.has(editor, followingListItemPath)\n\n\t\t\tif (hasFollowingListItem) {\n\t\t\t\tconst followingListItemNode = SlateNode.get(editor, followingListItemPath)\n\t\t\t\tif (!isListItemElement(followingListItemNode)) {\n\t\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tif (containingListItemPath[containingListItemPath.length - 1] === 0) {\n\t\t\t\t\t// We're at the beginning of a list\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: containingListPath, select: true })\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\t// We're in the middle of a list.\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.splitNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// We're at the end of a list.\n\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\tonKeyDown: event => {\n\t\t\t// TODO this should also work for expanded selections\n\t\t\tif (\n\t\t\t\t(event.key !== 'Tab' && event.key !== 'Enter') ||\n\t\t\t\t!editor.selection ||\n\t\t\t\t!SlateRange.isCollapsed(editor.selection)\n\t\t\t) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tconst selection = editor.selection\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor, { at: selection.focus })\n\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tlet [closestBlockElement, closestBlockPath] = closestBlockEntry\n\t\t\tif (!SlateElement.isElement(closestBlockElement)) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\n\t\t\tif (event.key === 'Tab') {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\t[closestBlockElement, closestBlockPath] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t}\n\t\t\t\tif (!isListItemElement(closestBlockElement)) {\n\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t}\n\t\t\t\tconst succeeded = event.shiftKey\n\t\t\t\t\t? dedentListItem(editor, closestBlockElement, closestBlockPath)\n\t\t\t\t\t: indentListItem(editor, closestBlockElement, closestBlockPath)\n\n\t\t\t\tif (succeeded) {\n\t\t\t\t\treturn event.preventDefault()\n\t\t\t\t}\n\t\t\t} else if (event.key === 'Enter' && event.shiftKey) {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\tconst [listItem] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t\tif (!isListItemElement(listItem)) {\n\t\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t\t}\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\t\talways: true,\n\t\t\t\t\t\tat: selection.focus,\n\t\t\t\t\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && editor.isDefaultElement(node),\n\t\t\t\t\t})\n\t\t\t\t} else if (isListItemElement(closestBlockElement)) {\n\t\t\t\t\t// We want to create a newline but the closest block is the list item.\n\t\t\t\t\t// This should mean that it only contains inlines. Hence we wrap them in a default element\n\t\t\t\t\t// and then split it.\n\t\t\t\t\tconst [listItemStart, listItemEnd] = Editor.edges(editor, closestBlockPath)\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tanchor: listItemStart,\n\t\t\t\t\t\t\t\tfocus: listItemEnd,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst relative = SlatePath.relative(selection.focus.path, closestBlockPath)\n\t\t\t\t\t\tTransforms.splitNodes(editor, {\n\t\t\t\t\t\t\t// The zero should be the newly created default element.\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tpath: [...closestBlockPath, 0, ...relative],\n\t\t\t\t\t\t\t\toffset: selection.focus.offset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\talways: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onKeyDown(event)\n\t\t},\n\t})\n\n\n\n\treturn editor\n}\n"],"names":["listItemElementPlugin","orderedListElementPlugin","unorderedListElementPlugin","listHtmlDeserializerFactory","SlateRange","ContemberEditor","isListItemElement","SlatePath","SlateNode","Transforms","isListElement","Editor","SlateElement","dedentListItem","indentListItem","Text"],"mappings":";;;;;;;;;;;AAkBa,MAAA,YAAY,CAAC,EAAE,gBAAgB,qBAAqB,kBAAkB,MAI7E,CAAmB,WAAiB;AACnC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA,IACG;AAEJ,SAAO,gBAAgBA,gBAAsB,sBAAA,EAAE,QAAQ,eAAgB,CAAA,CAAC;AACxE,SAAO,gBAAgBC,mBAAyB,yBAAA,EAAE,QAAQ,kBAAmB,CAAA,CAAC;AAC9E,SAAO,gBAAgBC,qBAA2B,2BAAA,EAAE,QAAQ,oBAAqB,CAAA,CAAC;AAE3E,SAAA,iBAAiB,eAAeC,qBAAAA,6BAA6B;AAEpE,SAAO,OAAgC,QAAQ;AAAA,IAC9C,aAAa,MAAM;AACZ,YAAA,EAAE,cAAc;AAEtB,UAAI,CAAC,aAAa,CAACC,MAAW,MAAA,YAAY,SAAS,GAAG;AACrD,eAAO,YAAY;AAAA,MAAA;AAEd,YAAA,oBAAoBC,MAAAA,gBAAgB,kBAAkB,MAAM;AAClE,UAAI,sBAAsB,QAAW;AACpC,eAAO,YAAY;AAAA,MAAA;AAEd,YAAA,CAAC,cAAc,gBAAgB,IAAI;AAErC,UAAA;AACA,UAAA;AAEA,UAAA,CAACC,gBAAAA,kBAAkB,YAAY,GAAG;AACjC,YAAA,iBAAiB,SAAS,GAAG;AAE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,CACA;AACD,kBAAM,WAAWL,MAAAA,KAAU,SAAS,UAAU,MAAM,MAAM,gBAAgB;AAC1EE,kBAAA,WAAW,WAAW,QAAQ;AAAA;AAAA,cAE7B,IAAI;AAAA,gBACH,MAAM,CAAC,GAAG,kBAAkB,GAAG,GAAG,QAAQ;AAAA,gBAC1C,QAAQ,UAAU,MAAM;AAAA,cACzB;AAAA,cACA,QAAQ;AAAA,YAAA,CACR;AAAA,UAAA,CACD;AAAA,QAAA;AAAA,MACF;AAED,aAAO,UAAU,KAAK;AAAA,IAAA;AAAA,EACvB,CACA;AAIM,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLists.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/withLists.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tPath as SlatePath,\n\tRange as SlateRange,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement, ListItemElement, listItemElementPlugin } from './ListItemElement'\nimport { OrderedListElement, orderedListElementPlugin } from './OrderedListElement'\nimport { dedentListItem, indentListItem } from './transforms'\nimport { UnorderedListElement, unorderedListElementPlugin } from './UnorderedListElement'\nimport { isListElement } from './ListElement'\nimport { listHtmlDeserializerFactory } from './ListHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withLists = ({ renderListItem, renderUnorderedList, renderOrderedList }: {\n\trenderListItem: ElementRenderer<ListItemElement>\n\trenderOrderedList: ElementRenderer<OrderedListElement>\n\trenderUnorderedList: ElementRenderer<UnorderedListElement>\n}) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tinsertBreak,\n\t\tonKeyDown,\n\t} = editor\n\n\teditor.registerElement(listItemElementPlugin({ render: renderListItem }))\n\teditor.registerElement(orderedListElementPlugin({ render: renderOrderedList }))\n\teditor.registerElement(unorderedListElementPlugin({ render: renderUnorderedList }))\n\n\teditor.htmlDeserializer.registerPlugin(listHtmlDeserializerFactory())\n\n\tObject.assign<Editor, Partial<Editor>>(editor, {\n\t\tinsertBreak: () => {\n\t\t\tconst { selection } = editor\n\n\t\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\n\t\t\tlet containingListItem: ListItemElement\n\t\t\tlet containingListItemPath: SlatePath\n\n\t\t\tif (!isListItemElement(closestBlock)) {\n\t\t\t\tif (closestBlockPath.length < 2) {\n\t\t\t\t\t// This block cannot be inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\n\t\t\t\tcontainingListItemPath = SlatePath.parent(closestBlockPath)\n\t\t\t\tconst closestListItem = SlateNode.get(editor, containingListItemPath)\n\n\t\t\t\tif (!isListItemElement(closestListItem)) {\n\t\t\t\t\t// The block is not inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tcontainingListItem = closestListItem\n\t\t\t} else {\n\t\t\t\tcontainingListItem = closestBlock\n\t\t\t\tcontainingListItemPath = closestBlockPath\n\t\t\t}\n\n\t\t\tif (SlateNode.string(containingListItem) !== '') {\n\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\talways: true,\n\t\t\t\t\tat: selection.focus,\n\t\t\t\t\tmatch: node => isListItemElement(node),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// We're in a list and want to leave this list.\n\n\t\t\tconst containingListPath = SlatePath.parent(containingListItemPath)\n\t\t\tconst containingList = SlateNode.get(editor, containingListPath)\n\n\t\t\tif (!isListElement(containingList)) {\n\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\n\t\t\tconst followingListItemPath = SlatePath.next(containingListItemPath)\n\t\t\tconst hasFollowingListItem = SlateNode.has(editor, followingListItemPath)\n\n\t\t\tif (hasFollowingListItem) {\n\t\t\t\tconst followingListItemNode = SlateNode.get(editor, followingListItemPath)\n\t\t\t\tif (!isListItemElement(followingListItemNode)) {\n\t\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tif (containingListItemPath[containingListItemPath.length - 1] === 0) {\n\t\t\t\t\t// We're at the beginning of a list\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: containingListPath, select: true })\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\t// We're in the middle of a list.\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.splitNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// We're at the end of a list.\n\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\tonKeyDown: event => {\n\t\t\t// TODO this should also work for expanded selections\n\t\t\tif (\n\t\t\t\t(event.key !== 'Tab' && event.key !== 'Enter') ||\n\t\t\t\t!editor.selection ||\n\t\t\t\t!SlateRange.isCollapsed(editor.selection)\n\t\t\t) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tconst selection = editor.selection\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor, { at: selection.focus })\n\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tlet [closestBlockElement, closestBlockPath] = closestBlockEntry\n\t\t\tif (!SlateElement.isElement(closestBlockElement)) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\n\t\t\tif (event.key === 'Tab') {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\t[closestBlockElement, closestBlockPath] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t}\n\t\t\t\tif (!isListItemElement(closestBlockElement)) {\n\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t}\n\t\t\t\tconst succeeded = event.shiftKey\n\t\t\t\t\t? dedentListItem(editor, closestBlockElement, closestBlockPath)\n\t\t\t\t\t: indentListItem(editor, closestBlockElement, closestBlockPath)\n\n\t\t\t\tif (succeeded) {\n\t\t\t\t\treturn event.preventDefault()\n\t\t\t\t}\n\t\t\t} else if (event.key === 'Enter' && event.shiftKey) {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\tconst [listItem] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t\tif (!isListItemElement(listItem)) {\n\t\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t\t}\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\t\talways: true,\n\t\t\t\t\t\tat: selection.focus,\n\t\t\t\t\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && editor.isDefaultElement(node),\n\t\t\t\t\t})\n\t\t\t\t} else if (isListItemElement(closestBlockElement)) {\n\t\t\t\t\t// We want to create a newline but the closest block is the list item.\n\t\t\t\t\t// This should mean that it only contains inlines. Hence we wrap them in a default element\n\t\t\t\t\t// and then split it.\n\t\t\t\t\tconst [listItemStart, listItemEnd] = Editor.edges(editor, closestBlockPath)\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tanchor: listItemStart,\n\t\t\t\t\t\t\t\tfocus: listItemEnd,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst relative = SlatePath.relative(selection.focus.path, closestBlockPath)\n\t\t\t\t\t\tTransforms.splitNodes(editor, {\n\t\t\t\t\t\t\t// The zero should be the newly created default element.\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tpath: [...closestBlockPath, 0, ...relative],\n\t\t\t\t\t\t\t\toffset: selection.focus.offset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\talways: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onKeyDown(event)\n\t\t},\n\t})\n\n\n\n\treturn editor\n}\n"],"names":["SlateRange","SlatePath","SlateNode","SlateElement"],"mappings":";;;;;;;;;AAkBa,MAAA,YAAY,CAAC,EAAE,gBAAgB,qBAAqB,kBAAkB,MAI7E,CAAmB,WAAiB;AACnC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EACG,IAAA;AAEJ,SAAO,gBAAgB,sBAAsB,EAAE,QAAQ,eAAgB,CAAA,CAAC;AACxE,SAAO,gBAAgB,yBAAyB,EAAE,QAAQ,kBAAmB,CAAA,CAAC;AAC9E,SAAO,gBAAgB,2BAA2B,EAAE,QAAQ,oBAAqB,CAAA,CAAC;AAE3E,SAAA,i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AO,CAAA,SAAQ,KAAK,OAAO,IAAI,KAAMA,QAAa,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI;AAAA,cACzF,IAAI;AAAA,gBACH,QAAQ;AAAA,gBACR,OAAO;AAAA,cACR;AAAA,YAAA,CACA;AACD,kBAAM,WAAWF,KAAU,SAAS,UAAU,MAAM,MAAM,gBAAgB;AAC1E,uBAAW,WAAW,QAAQ;AAAA;AAAA,cAE7B,IAAI;AAAA,gBACH,MAAM,CAAC,GAAG,kBAAkB,GAAG,GAAG,QAAQ;AAAA,gBAC1C,QAAQ,UAAU,MAAM;AAAA,cACzB;AAAA,cACA,QAAQ;AAAA,YAAA,CACR;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACD;AACA,aAAO,UAAU,KAAK;AAAA,IACvB;AAAA,EAAA,CACA;AAIM,SAAA;AACR;"}
|
|
1
|
+
{"version":3,"file":"withLists.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/withLists.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tPath as SlatePath,\n\tRange as SlateRange,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement, ListItemElement, listItemElementPlugin } from './ListItemElement'\nimport { OrderedListElement, orderedListElementPlugin } from './OrderedListElement'\nimport { dedentListItem, indentListItem } from './transforms'\nimport { UnorderedListElement, unorderedListElementPlugin } from './UnorderedListElement'\nimport { isListElement } from './ListElement'\nimport { listHtmlDeserializerFactory } from './ListHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withLists = ({ renderListItem, renderUnorderedList, renderOrderedList }: {\n\trenderListItem: ElementRenderer<ListItemElement>\n\trenderOrderedList: ElementRenderer<OrderedListElement>\n\trenderUnorderedList: ElementRenderer<UnorderedListElement>\n}) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tinsertBreak,\n\t\tonKeyDown,\n\t} = editor\n\n\teditor.registerElement(listItemElementPlugin({ render: renderListItem }))\n\teditor.registerElement(orderedListElementPlugin({ render: renderOrderedList }))\n\teditor.registerElement(unorderedListElementPlugin({ render: renderUnorderedList }))\n\n\teditor.htmlDeserializer.registerPlugin(listHtmlDeserializerFactory())\n\n\tObject.assign<Editor, Partial<Editor>>(editor, {\n\t\tinsertBreak: () => {\n\t\t\tconst { selection } = editor\n\n\t\t\tif (!selection || !SlateRange.isCollapsed(selection)) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor)\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\t\t\tconst [closestBlock, closestBlockPath] = closestBlockEntry\n\n\t\t\tlet containingListItem: ListItemElement\n\t\t\tlet containingListItemPath: SlatePath\n\n\t\t\tif (!isListItemElement(closestBlock)) {\n\t\t\t\tif (closestBlockPath.length < 2) {\n\t\t\t\t\t// This block cannot be inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\n\t\t\t\tcontainingListItemPath = SlatePath.parent(closestBlockPath)\n\t\t\t\tconst closestListItem = SlateNode.get(editor, containingListItemPath)\n\n\t\t\t\tif (!isListItemElement(closestListItem)) {\n\t\t\t\t\t// The block is not inside a list\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tcontainingListItem = closestListItem\n\t\t\t} else {\n\t\t\t\tcontainingListItem = closestBlock\n\t\t\t\tcontainingListItemPath = closestBlockPath\n\t\t\t}\n\n\t\t\tif (SlateNode.string(containingListItem) !== '') {\n\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\talways: true,\n\t\t\t\t\tat: selection.focus,\n\t\t\t\t\tmatch: node => isListItemElement(node),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// We're in a list and want to leave this list.\n\n\t\t\tconst containingListPath = SlatePath.parent(containingListItemPath)\n\t\t\tconst containingList = SlateNode.get(editor, containingListPath)\n\n\t\t\tif (!isListElement(containingList)) {\n\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\treturn insertBreak()\n\t\t\t}\n\n\t\t\tconst followingListItemPath = SlatePath.next(containingListItemPath)\n\t\t\tconst hasFollowingListItem = SlateNode.has(editor, followingListItemPath)\n\n\t\t\tif (hasFollowingListItem) {\n\t\t\t\tconst followingListItemNode = SlateNode.get(editor, followingListItemPath)\n\t\t\t\tif (!isListItemElement(followingListItemNode)) {\n\t\t\t\t\t// This shouldn't really happen. It's more of a sanity check.\n\t\t\t\t\treturn insertBreak()\n\t\t\t\t}\n\t\t\t\tif (containingListItemPath[containingListItemPath.length - 1] === 0) {\n\t\t\t\t\t// We're at the beginning of a list\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: containingListPath, select: true })\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\t// We're in the middle of a list.\n\t\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tTransforms.splitNodes(editor, { at: containingListItemPath })\n\t\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// We're at the end of a list.\n\t\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\t\tconst afterListParent = SlatePath.next(containingListPath)\n\t\t\t\t\t// Remove the trailing empty listItem\n\t\t\t\t\tTransforms.removeNodes(editor, { at: containingListItemPath })\n\t\t\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), { at: afterListParent, select: true })\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\tonKeyDown: event => {\n\t\t\t// TODO this should also work for expanded selections\n\t\t\tif (\n\t\t\t\t(event.key !== 'Tab' && event.key !== 'Enter') ||\n\t\t\t\t!editor.selection ||\n\t\t\t\t!SlateRange.isCollapsed(editor.selection)\n\t\t\t) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tconst selection = editor.selection\n\t\t\tconst closestBlockEntry = ContemberEditor.closestBlockEntry(editor, { at: selection.focus })\n\n\t\t\tif (closestBlockEntry === undefined) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\t\t\tlet [closestBlockElement, closestBlockPath] = closestBlockEntry\n\t\t\tif (!SlateElement.isElement(closestBlockElement)) {\n\t\t\t\treturn onKeyDown(event)\n\t\t\t}\n\n\t\t\tif (event.key === 'Tab') {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\t[closestBlockElement, closestBlockPath] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t}\n\t\t\t\tif (!isListItemElement(closestBlockElement)) {\n\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t}\n\t\t\t\tconst succeeded = event.shiftKey\n\t\t\t\t\t? dedentListItem(editor, closestBlockElement, closestBlockPath)\n\t\t\t\t\t: indentListItem(editor, closestBlockElement, closestBlockPath)\n\n\t\t\t\tif (succeeded) {\n\t\t\t\t\treturn event.preventDefault()\n\t\t\t\t}\n\t\t\t} else if (event.key === 'Enter' && event.shiftKey) {\n\t\t\t\tif (editor.isDefaultElement(closestBlockElement)) {\n\t\t\t\t\tconst [listItem] = Editor.parent(editor, closestBlockPath)\n\t\t\t\t\tif (!isListItemElement(listItem)) {\n\t\t\t\t\t\treturn onKeyDown(event)\n\t\t\t\t\t}\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Transforms.splitNodes(editor, {\n\t\t\t\t\t\talways: true,\n\t\t\t\t\t\tat: selection.focus,\n\t\t\t\t\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && editor.isDefaultElement(node),\n\t\t\t\t\t})\n\t\t\t\t} else if (isListItemElement(closestBlockElement)) {\n\t\t\t\t\t// We want to create a newline but the closest block is the list item.\n\t\t\t\t\t// This should mean that it only contains inlines. Hence we wrap them in a default element\n\t\t\t\t\t// and then split it.\n\t\t\t\t\tconst [listItemStart, listItemEnd] = Editor.edges(editor, closestBlockPath)\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tanchor: listItemStart,\n\t\t\t\t\t\t\t\tfocus: listItemEnd,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst relative = SlatePath.relative(selection.focus.path, closestBlockPath)\n\t\t\t\t\t\tTransforms.splitNodes(editor, {\n\t\t\t\t\t\t\t// The zero should be the newly created default element.\n\t\t\t\t\t\t\tat: {\n\t\t\t\t\t\t\t\tpath: [...closestBlockPath, 0, ...relative],\n\t\t\t\t\t\t\t\toffset: selection.focus.offset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\talways: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onKeyDown(event)\n\t\t},\n\t})\n\n\n\n\treturn editor\n}\n"],"names":["SlateRange","SlatePath","SlateNode","SlateElement"],"mappings":";;;;;;;;;AAkBa,MAAA,YAAY,CAAC,EAAE,gBAAgB,qBAAqB,kBAAkB,MAI7E,CAAmB,WAAiB;AACnC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA,IACG;AAEJ,SAAO,gBAAgB,sBAAsB,EAAE,QAAQ,eAAgB,CAAA,CAAC;AACxE,SAAO,gBAAg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,eAAe;AACd,iBAAA,OAAO,mBAAmB,QAAQ,MAAM;AAC9C,uBAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,cAC7D,OAAO,CAAA,SAAQ,KAAK,OAAO,IAAI,KAAMA,QAAa,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI;AAAA,cACzF,IAAI;AAAA,gBACH,QAAQ;AAAA,gBACR,OAAO;AAAA,cAAA;AAAA,YACR,CACA;AACD,kBAAM,WAAWF,KAAU,SAAS,UAAU,MAAM,MAAM,gBAAgB;AAC1E,uBAAW,WAAW,QAAQ;AAAA;AAAA,cAE7B,IAAI;AAAA,gBACH,MAAM,CAAC,GAAG,kBAAkB,GAAG,GAAG,QAAQ;AAAA,gBAC1C,QAAQ,UAAU,MAAM;AAAA,cACzB;AAAA,cACA,QAAQ;AAAA,YAAA,CACR;AAAA,UAAA,CACD;AAAA,QAAA;AAAA,MACF;AAED,aAAO,UAAU,KAAK;AAAA,IAAA;AAAA,EACvB,CACA;AAIM,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParagraphElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/ParagraphElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const paragraphElementType = 'paragraph' as const\n\nexport interface ParagraphElement extends SlateElement {\n\ttype: typeof paragraphElementType\n\tisNumbered?: boolean\n\tchildren: SlateEditor['children']\n\talign?: AlignDirection\n}\n\nexport const isParagraphElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ParagraphElement>,\n): element is ParagraphElement => ContemberEditor.isElementType(element, paragraphElementType, suchThat)\n\nexport const paragraphElementPlugin = ({ render }: {render: ElementRenderer<ParagraphElement>}): EditorElementPlugin<ParagraphElement> => ({\n\ttype: paragraphElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tconst topLevelNodes = Array.from(ContemberEditor.topLevelNodes(editor))\n\n\t\t\tif (topLevelNodes.every(([node]) => isParagraphElement(node, suchThat))) {\n\t\t\t\tfor (const [, path] of topLevelNodes) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: path })\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [node, path] of topLevelNodes) {\n\t\t\t\t\tif (isParagraphElement(node, suchThat)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tconst newProps: Partial<ParagraphElement> = {\n\t\t\t\t\t\t...suchThat,\n\t\t\t\t\t\ttype: paragraphElementType,\n\t\t\t\t\t}\n\t\t\t\t\tTransforms.setNodes(editor, newProps, { at: path })\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t},\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tfor (const [i, child] of element.children.entries()) {\n\t\t\tif (SlateElement.isElement(child) && Editor.isBlock(editor, child)) {\n\t\t\t\tTransforms.unwrapNodes(editor, { at: [...path, i] })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t},\n})\n"],"names":["ContemberEditor","Editor","Transforms","SlateElement"],"mappings":";;;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CACjC,SACA,aACiCA,
|
|
1
|
+
{"version":3,"file":"ParagraphElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/ParagraphElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const paragraphElementType = 'paragraph' as const\n\nexport interface ParagraphElement extends SlateElement {\n\ttype: typeof paragraphElementType\n\tisNumbered?: boolean\n\tchildren: SlateEditor['children']\n\talign?: AlignDirection\n}\n\nexport const isParagraphElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ParagraphElement>,\n): element is ParagraphElement => ContemberEditor.isElementType(element, paragraphElementType, suchThat)\n\nexport const paragraphElementPlugin = ({ render }: {render: ElementRenderer<ParagraphElement>}): EditorElementPlugin<ParagraphElement> => ({\n\ttype: paragraphElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tconst topLevelNodes = Array.from(ContemberEditor.topLevelNodes(editor))\n\n\t\t\tif (topLevelNodes.every(([node]) => isParagraphElement(node, suchThat))) {\n\t\t\t\tfor (const [, path] of topLevelNodes) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: path })\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [node, path] of topLevelNodes) {\n\t\t\t\t\tif (isParagraphElement(node, suchThat)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tconst newProps: Partial<ParagraphElement> = {\n\t\t\t\t\t\t...suchThat,\n\t\t\t\t\t\ttype: paragraphElementType,\n\t\t\t\t\t}\n\t\t\t\t\tTransforms.setNodes(editor, newProps, { at: path })\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t},\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tfor (const [i, child] of element.children.entries()) {\n\t\t\tif (SlateElement.isElement(child) && Editor.isBlock(editor, child)) {\n\t\t\t\tTransforms.unwrapNodes(editor, { at: [...path, i] })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t},\n})\n"],"names":["ContemberEditor","Editor","Transforms","SlateElement"],"mappings":";;;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CACjC,SACA,aACiCA,sBAAgB,cAAc,SAAS,sBAAsB,QAAQ;AAEhG,MAAM,yBAAyB,CAAC,EAAE,cAAkG;AAAA,EAC1I,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,mBAAmB,CAAC,EAAE,QAAQ,eAAe;AAC5C,WAAO,WAAW;AAAA,EACnB;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,eAAe;AACjCC,iBAAA,mBAAmB,QAAQ,MAAM;AACvC,YAAM,gBAAgB,MAAM,KAAKD,MAAAA,gBAAgB,cAAc,MAAM,CAAC;AAElE,UAAA,cAAc,MAAM,CAAC,CAAC,IAAI,MAAM,mBAAmB,MAAM,QAAQ,CAAC,GAAG;AACxE,mBAAW,CAAA,EAAG,IAAI,KAAK,eAAe;AACrBA,gCAAA,aAAa,QAAQ,IAAI;AAC9BE,2BAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,MAAM;AAAA,QAAA;AAAA,MAC9E,OACM;AACN,mBAAW,CAAC,MAAM,IAAI,KAAK,eAAe;AACrC,cAAA,mBAAmB,MAAM,QAAQ,GAAG;AACvC;AAAA,UAAA;AAEeF,gCAAA,aAAa,QAAQ,IAAI;AACzC,gBAAM,WAAsC;AAAA,YAC3C,GAAG;AAAA,YACH,MAAM;AAAA,UACP;AACAE,gBAAA,WAAW,SAAS,QAAQ,UAAU,EAAE,IAAI,MAAM;AAAA,QAAA;AAAA,MACnD;AAAA,IACD,CACA;AAAA,EACF;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,SAAS,MAAM,qBAAqB;AAC7D,eAAW,CAAC,GAAG,KAAK,KAAK,QAAQ,SAAS,WAAW;AAChD,UAAAC,MAAA,QAAa,UAAU,KAAK,KAAKF,aAAO,QAAQ,QAAQ,KAAK,GAAG;AACxDC,yBAAA,YAAY,QAAQ,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG;AACnD,eAAO,eAAe;AAAA,MAAA;AAAA,IACvB;AAAA,EACD;AAEF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParagraphElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/ParagraphElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const paragraphElementType = 'paragraph' as const\n\nexport interface ParagraphElement extends SlateElement {\n\ttype: typeof paragraphElementType\n\tisNumbered?: boolean\n\tchildren: SlateEditor['children']\n\talign?: AlignDirection\n}\n\nexport const isParagraphElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ParagraphElement>,\n): element is ParagraphElement => ContemberEditor.isElementType(element, paragraphElementType, suchThat)\n\nexport const paragraphElementPlugin = ({ render }: {render: ElementRenderer<ParagraphElement>}): EditorElementPlugin<ParagraphElement> => ({\n\ttype: paragraphElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tconst topLevelNodes = Array.from(ContemberEditor.topLevelNodes(editor))\n\n\t\t\tif (topLevelNodes.every(([node]) => isParagraphElement(node, suchThat))) {\n\t\t\t\tfor (const [, path] of topLevelNodes) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: path })\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [node, path] of topLevelNodes) {\n\t\t\t\t\tif (isParagraphElement(node, suchThat)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tconst newProps: Partial<ParagraphElement> = {\n\t\t\t\t\t\t...suchThat,\n\t\t\t\t\t\ttype: paragraphElementType,\n\t\t\t\t\t}\n\t\t\t\t\tTransforms.setNodes(editor, newProps, { at: path })\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t},\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tfor (const [i, child] of element.children.entries()) {\n\t\t\tif (SlateElement.isElement(child) && Editor.isBlock(editor, child)) {\n\t\t\t\tTransforms.unwrapNodes(editor, { at: [...path, i] })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t},\n})\n"],"names":["SlateElement"],"mappings":";;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CACjC,SACA,aACiC,gBAAgB,cAAc,SAAS,sBAAsB,QAAQ;AAEhG,MAAM,yBAAyB,CAAC,EAAE,cAAkG;AAAA,EAC1I,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,mBAAmB,CAAC,EAAE,QAAQ,eAAe;AAC5C,WAAO,WAAW;AAAA,EACnB;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,eAAe;AACjC,WAAA,mBAAmB,QAAQ,MAAM;AACvC,YAAM,gBAAgB,MAAM,KAAK,gBAAgB,cAAc,MAAM,CAAC;AAElE,UAAA,cAAc,MAAM,CAAC,CAAC,IAAI,MAAM,mBAAmB,MAAM,QAAQ,CAAC,GAAG;AACxE,mBAAW,CAAA,EAAG,IAAI,KAAK,eAAe;AACrB,0BAAA,aAAa,QAAQ,IAAI;AAC9B,qBAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"ParagraphElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/ParagraphElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { AlignDirection } from '../../attributes'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const paragraphElementType = 'paragraph' as const\n\nexport interface ParagraphElement extends SlateElement {\n\ttype: typeof paragraphElementType\n\tisNumbered?: boolean\n\tchildren: SlateEditor['children']\n\talign?: AlignDirection\n}\n\nexport const isParagraphElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ParagraphElement>,\n): element is ParagraphElement => ContemberEditor.isElementType(element, paragraphElementType, suchThat)\n\nexport const paragraphElementPlugin = ({ render }: {render: ElementRenderer<ParagraphElement>}): EditorElementPlugin<ParagraphElement> => ({\n\ttype: paragraphElementType,\n\trender,\n\tcanContainAnyBlocks: false,\n\tacceptsAttributes: ({ editor, suchThat }) => {\n\t\treturn 'align' in suchThat\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tconst topLevelNodes = Array.from(ContemberEditor.topLevelNodes(editor))\n\n\t\t\tif (topLevelNodes.every(([node]) => isParagraphElement(node, suchThat))) {\n\t\t\t\tfor (const [, path] of topLevelNodes) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tTransforms.setNodes(editor, { type: editor.defaultElementType }, { at: path })\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [node, path] of topLevelNodes) {\n\t\t\t\t\tif (isParagraphElement(node, suchThat)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tContemberEditor.ejectElement(editor, path)\n\t\t\t\t\tconst newProps: Partial<ParagraphElement> = {\n\t\t\t\t\t\t...suchThat,\n\t\t\t\t\t\ttype: paragraphElementType,\n\t\t\t\t\t}\n\t\t\t\t\tTransforms.setNodes(editor, newProps, { at: path })\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t},\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tfor (const [i, child] of element.children.entries()) {\n\t\t\tif (SlateElement.isElement(child) && Editor.isBlock(editor, child)) {\n\t\t\t\tTransforms.unwrapNodes(editor, { at: [...path, i] })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t},\n})\n"],"names":["SlateElement"],"mappings":";;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CACjC,SACA,aACiC,gBAAgB,cAAc,SAAS,sBAAsB,QAAQ;AAEhG,MAAM,yBAAyB,CAAC,EAAE,cAAkG;AAAA,EAC1I,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,mBAAmB,CAAC,EAAE,QAAQ,eAAe;AAC5C,WAAO,WAAW;AAAA,EACnB;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,eAAe;AACjC,WAAA,mBAAmB,QAAQ,MAAM;AACvC,YAAM,gBAAgB,MAAM,KAAK,gBAAgB,cAAc,MAAM,CAAC;AAElE,UAAA,cAAc,MAAM,CAAC,CAAC,IAAI,MAAM,mBAAmB,MAAM,QAAQ,CAAC,GAAG;AACxE,mBAAW,CAAA,EAAG,IAAI,KAAK,eAAe;AACrB,0BAAA,aAAa,QAAQ,IAAI;AAC9B,qBAAA,SAAS,QAAQ,EAAE,MAAM,OAAO,sBAAsB,EAAE,IAAI,MAAM;AAAA,QAAA;AAAA,MAC9E,OACM;AACN,mBAAW,CAAC,MAAM,IAAI,KAAK,eAAe;AACrC,cAAA,mBAAmB,MAAM,QAAQ,GAAG;AACvC;AAAA,UAAA;AAEe,0BAAA,aAAa,QAAQ,IAAI;AACzC,gBAAM,WAAsC;AAAA,YAC3C,GAAG;AAAA,YACH,MAAM;AAAA,UACP;AACA,qBAAW,SAAS,QAAQ,UAAU,EAAE,IAAI,MAAM;AAAA,QAAA;AAAA,MACnD;AAAA,IACD,CACA;AAAA,EACF;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,SAAS,MAAM,qBAAqB;AAC7D,eAAW,CAAC,GAAG,KAAK,KAAK,QAAQ,SAAS,WAAW;AAChD,UAAAA,QAAa,UAAU,KAAK,KAAK,OAAO,QAAQ,QAAQ,KAAK,GAAG;AACxD,mBAAA,YAAY,QAAQ,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG;AACnD,eAAO,eAAe;AAAA,MAAA;AAAA,IACvB;AAAA,EACD;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withParagraphs.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/withParagraphs.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isParagraphElement, ParagraphElement, paragraphElementPlugin, paragraphElementType } from './ParagraphElement'\nimport { paragraphHtmlDeserializer } from './ParagraphHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withParagraphs = ({ render }: { render: ElementRenderer<ParagraphElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tdeleteBackward,\n\t} = editor\n\n\teditor.registerElement(paragraphElementPlugin({ render }))\n\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\t// This only allows numbered paragraphs at the top level.\n\t\t// TODO this is pretty bad but in order to fix this, we'd also have to fix toggleElement and there's no time now.\n\n\t\tif (elementType !== paragraphElementType || suchThat === undefined) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tconst isNumbered = suchThat.isNumbered\n\n\t\tif (isNumbered !== true) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\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, closestBlockPath] = closestBlockEntry\n\n\t\treturn closestBlockPath.length === 1 && SlateElement.isElement(closestBlockElement) && closestBlockElement.type === paragraphElementType\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 paragraph.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<ParagraphElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isParagraphElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, paragraphPath] = closestNumberedEntry\n\t\tconst paragraphStartPoint = Editor.start(editor, paragraphPath)\n\n\t\tif (!Point.equals(paragraphStartPoint, 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: paragraphPath },\n\t\t)\n\t}\n\teditor.htmlDeserializer.registerPlugin(paragraphHtmlDeserializer)\n\n\treturn editor\n}\n"],"names":["paragraphElementPlugin","paragraphElementType","ContemberEditor","SlateElement","SlateRange","Editor","isParagraphElement","Point","Transforms","paragraphHtmlDeserializer"],"mappings":";;;;;;AAMO,MAAM,iBAAiB,CAAC,EAAE,OAAO,MAAqD,CAAmB,WAAiB;AAC1H,QAAA;AAAA,IACL;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"withParagraphs.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/withParagraphs.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isParagraphElement, ParagraphElement, paragraphElementPlugin, paragraphElementType } from './ParagraphElement'\nimport { paragraphHtmlDeserializer } from './ParagraphHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withParagraphs = ({ render }: { render: ElementRenderer<ParagraphElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tdeleteBackward,\n\t} = editor\n\n\teditor.registerElement(paragraphElementPlugin({ render }))\n\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\t// This only allows numbered paragraphs at the top level.\n\t\t// TODO this is pretty bad but in order to fix this, we'd also have to fix toggleElement and there's no time now.\n\n\t\tif (elementType !== paragraphElementType || suchThat === undefined) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tconst isNumbered = suchThat.isNumbered\n\n\t\tif (isNumbered !== true) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\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, closestBlockPath] = closestBlockEntry\n\n\t\treturn closestBlockPath.length === 1 && SlateElement.isElement(closestBlockElement) && closestBlockElement.type === paragraphElementType\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 paragraph.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<ParagraphElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isParagraphElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, paragraphPath] = closestNumberedEntry\n\t\tconst paragraphStartPoint = Editor.start(editor, paragraphPath)\n\n\t\tif (!Point.equals(paragraphStartPoint, 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: paragraphPath },\n\t\t)\n\t}\n\teditor.htmlDeserializer.registerPlugin(paragraphHtmlDeserializer)\n\n\treturn editor\n}\n"],"names":["paragraphElementPlugin","paragraphElementType","ContemberEditor","SlateElement","SlateRange","Editor","isParagraphElement","Point","Transforms","paragraphHtmlDeserializer"],"mappings":";;;;;;AAMO,MAAM,iBAAiB,CAAC,EAAE,OAAO,MAAqD,CAAmB,WAAiB;AAC1H,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA,IACG;AAEJ,SAAO,gBAAgBA,iBAAAA,uBAAuB,EAAE,OAAQ,CAAA,CAAC;AAGlD,SAAA,mBAAmB,CAAC,aAAa,aAAa;AAIhD,QAAA,gBAAgBC,iBAAAA,wBAAwB,aAAa,QAAW;AAC5D,aAAA,iBAAiB,aAAa,QAAQ;AAAA,IAAA;AAE9C,UAAM,aAAa,SAAS;AAE5B,QAAI,eAAe,MAAM;AACjB,aAAA,iBAAiB,aAAa,QAAQ;AAAA,IAAA;AAG1C,QAAA,CAAC,OAAO,WAAW;AACf,aAAA;AAAA,IAAA;AAEF,UAAA,oBAAoBC,MAAAA,gBAAgB,kBAAkB,MAAM;AAClE,QAAI,sBAAsB,QAAW;AAC7B,aAAA;AAAA,IAAA;AAEF,UAAA,CAAC,qBAAqB,gBAAgB,IAAI;AAEzC,WAAA,iBAAiB,WAAW,KAAMC,MAAA,QAAa,UAAU,mBAAmB,KAAK,oBAAoB,SAASF,iBAAA;AAAA,EACtH;AAEA,SAAO,iBAAiB,CAAQ,SAAA;AAC/B,UAAM,YAAY,OAAO;AACzB,QAAI,SAAS,eAAe,CAAC,aAAa,CAACG,MAAA,MAAW,YAAY,SAAS,KAAK,UAAU,MAAM,WAAW,GAAG;AAC7G,aAAO,eAAe,IAAI;AAAA,IAAA;AAKrB,UAAA,uBAAuBC,MAAAA,OAAO,MAAwB,QAAQ;AAAA,MACnE,OAAO,CAAQ,SAAAF,MAAA,QAAa,UAAU,IAAI,KAAKG,iBAAAA,mBAAmB,MAAM,EAAE,YAAY,KAAM,CAAA;AAAA,IAAA,CAC5F;AACD,QAAI,yBAAyB,QAAW;AACvC,aAAO,eAAe,IAAI;AAAA,IAAA;AAErB,UAAA,CAAA,EAAG,aAAa,IAAI;AAC1B,UAAM,sBAAsBD,MAAA,OAAO,MAAM,QAAQ,aAAa;AAE9D,QAAI,CAACE,MAAM,MAAA,OAAO,qBAAqB,UAAU,KAAK,GAAG;AACxD,aAAO,eAAe,IAAI;AAAA,IAAA;AAEhBC,UAAAA,WAAA;AAAA,MACV;AAAA,MACA,EAAE,YAAY,KAAK;AAAA;AAAA,MACnB,EAAE,IAAI,cAAc;AAAA,IACrB;AAAA,EACD;AACO,SAAA,iBAAiB,eAAeC,mDAAyB;AAEzD,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withParagraphs.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/withParagraphs.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isParagraphElement, ParagraphElement, paragraphElementPlugin, paragraphElementType } from './ParagraphElement'\nimport { paragraphHtmlDeserializer } from './ParagraphHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withParagraphs = ({ render }: { render: ElementRenderer<ParagraphElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tdeleteBackward,\n\t} = editor\n\n\teditor.registerElement(paragraphElementPlugin({ render }))\n\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\t// This only allows numbered paragraphs at the top level.\n\t\t// TODO this is pretty bad but in order to fix this, we'd also have to fix toggleElement and there's no time now.\n\n\t\tif (elementType !== paragraphElementType || suchThat === undefined) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tconst isNumbered = suchThat.isNumbered\n\n\t\tif (isNumbered !== true) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\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, closestBlockPath] = closestBlockEntry\n\n\t\treturn closestBlockPath.length === 1 && SlateElement.isElement(closestBlockElement) && closestBlockElement.type === paragraphElementType\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 paragraph.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<ParagraphElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isParagraphElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, paragraphPath] = closestNumberedEntry\n\t\tconst paragraphStartPoint = Editor.start(editor, paragraphPath)\n\n\t\tif (!Point.equals(paragraphStartPoint, 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: paragraphPath },\n\t\t)\n\t}\n\teditor.htmlDeserializer.registerPlugin(paragraphHtmlDeserializer)\n\n\treturn editor\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";;;;AAMO,MAAM,iBAAiB,CAAC,EAAE,OAAO,MAAqD,CAAmB,WAAiB;AAC1H,QAAA;AAAA,IACL;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"withParagraphs.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/paragraphs/withParagraphs.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Point, Range as SlateRange, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isParagraphElement, ParagraphElement, paragraphElementPlugin, paragraphElementType } from './ParagraphElement'\nimport { paragraphHtmlDeserializer } from './ParagraphHtmlDeserializer'\nimport { ElementRenderer } from '../../../types'\n\nexport const withParagraphs = ({ render }: { render: ElementRenderer<ParagraphElement> }) => <E extends Editor>(editor: E): E => {\n\tconst {\n\t\tcanToggleElement,\n\t\tdeleteBackward,\n\t} = editor\n\n\teditor.registerElement(paragraphElementPlugin({ render }))\n\n\n\teditor.canToggleElement = (elementType, suchThat) => {\n\t\t// This only allows numbered paragraphs at the top level.\n\t\t// TODO this is pretty bad but in order to fix this, we'd also have to fix toggleElement and there's no time now.\n\n\t\tif (elementType !== paragraphElementType || suchThat === undefined) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\t\tconst isNumbered = suchThat.isNumbered\n\n\t\tif (isNumbered !== true) {\n\t\t\treturn canToggleElement(elementType, suchThat)\n\t\t}\n\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, closestBlockPath] = closestBlockEntry\n\n\t\treturn closestBlockPath.length === 1 && SlateElement.isElement(closestBlockElement) && closestBlockElement.type === paragraphElementType\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 paragraph.\n\t\t// It's just a way to early-exit.\n\n\t\tconst closestNumberedEntry = Editor.above<ParagraphElement>(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && isParagraphElement(node, { isNumbered: true }),\n\t\t})\n\t\tif (closestNumberedEntry === undefined) {\n\t\t\treturn deleteBackward(unit)\n\t\t}\n\t\tconst [, paragraphPath] = closestNumberedEntry\n\t\tconst paragraphStartPoint = Editor.start(editor, paragraphPath)\n\n\t\tif (!Point.equals(paragraphStartPoint, 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: paragraphPath },\n\t\t)\n\t}\n\teditor.htmlDeserializer.registerPlugin(paragraphHtmlDeserializer)\n\n\treturn editor\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";;;;AAMO,MAAM,iBAAiB,CAAC,EAAE,OAAO,MAAqD,CAAmB,WAAiB;AAC1H,QAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA,IACG;AAEJ,SAAO,gBAAgB,uBAAuB,EAAE,OAAQ,CAAA,CAAC;AAGlD,SAAA,mBAAmB,CAAC,aAAa,aAAa;AAIhD,QAAA,gBAAgB,wBAAwB,aAAa,QAAW;AAC5D,aAAA,iBAAiB,aAAa,QAAQ;AAAA,IAAA;AAE9C,UAAM,aAAa,SAAS;AAE5B,QAAI,eAAe,MAAM;AACjB,aAAA,iBAAiB,aAAa,QAAQ;AAAA,IAAA;AAG1C,QAAA,CAAC,OAAO,WAAW;AACf,aAAA;AAAA,IAAA;AAEF,UAAA,oBAAoB,gBAAgB,kBAAkB,MAAM;AAClE,QAAI,sBAAsB,QAAW;AAC7B,aAAA;AAAA,IAAA;AAEF,UAAA,CAAC,qBAAqB,gBAAgB,IAAI;AAEzC,WAAA,iBAAiB,WAAW,KAAMA,QAAa,UAAU,mBAAmB,KAAK,oBAAoB,SAAS;AAAA,EACtH;AAEA,SAAO,iBAAiB,CAAQ,SAAA;AAC/B,UAAM,YAAY,OAAO;AACzB,QAAI,SAAS,eAAe,CAAC,aAAa,CAACC,MAAW,YAAY,SAAS,KAAK,UAAU,MAAM,WAAW,GAAG;AAC7G,aAAO,eAAe,IAAI;AAAA,IAAA;AAKrB,UAAA,uBAAuB,OAAO,MAAwB,QAAQ;AAAA,MACnE,OAAO,CAAQ,SAAAD,QAAa,UAAU,IAAI,KAAK,mBAAmB,MAAM,EAAE,YAAY,KAAM,CAAA;AAAA,IAAA,CAC5F;AACD,QAAI,yBAAyB,QAAW;AACvC,aAAO,eAAe,IAAI;AAAA,IAAA;AAErB,UAAA,CAAA,EAAG,aAAa,IAAI;AAC1B,UAAM,sBAAsB,OAAO,MAAM,QAAQ,aAAa;AAE9D,QAAI,CAAC,MAAM,OAAO,qBAAqB,UAAU,KAAK,GAAG;AACxD,aAAO,eAAe,IAAI;AAAA,IAAA;AAEhB,eAAA;AAAA,MACV;AAAA,MACA,EAAE,YAAY,KAAK;AAAA;AAAA,MACnB,EAAE,IAAI,cAAc;AAAA,IACrB;AAAA,EACD;AACO,SAAA,iBAAiB,eAAe,yBAAyB;AAEzD,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollTargetElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/ScrollTargetElement.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 scrollTargetElementType = 'scrollTarget' as const\n\nexport interface ScrollTargetElement extends SlateElement {\n\ttype: typeof scrollTargetElementType\n\tidentifier: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isScrollTargetElement = (element: SlateNode): element is ScrollTargetElement =>\n\tSlateElement.isElement(element) && element.type === scrollTargetElementType\n\nexport const isScrollTargetElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isScrollTargetElement })\n\treturn !!link\n}\n\nexport const scrollTargetElementPlugin = ({ render }: { render: ElementRenderer<ScrollTargetElement> }): EditorElementPlugin<ScrollTargetElement> => ({\n\ttype: scrollTargetElementType,\n\trender,\n\tisActive: ({ editor }) => isScrollTargetElementActive(editor),\n\tisInline: true,\n\tisVoid: true,\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isScrollTargetElementActive(editor)) {\n\t\t\tunwrapScrollTarget(editor)\n\t\t} else {\n\t\t\tlet identifier =\n\t\t\t\tsuchThat?.identifier ??\n\t\t\t\tprompt('Insert the identifier:')\n\n\t\t\tif (!identifier) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\twrapScrollTarget(editor, identifier)\n\t\t}\n\t},\n})\nconst unwrapScrollTarget = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isScrollTargetElement })\n}\nconst wrapScrollTarget = (editor: Editor, identifier: string) => {\n\tif (isScrollTargetElementActive(editor)) {\n\t\tunwrapScrollTarget(editor)\n\t}\n\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\tconst ScrollTarget: ScrollTargetElement = {\n\t\ttype: scrollTargetElementType,\n\t\tidentifier,\n\t\tchildren: [{ text: '' }],\n\t}\n\n\tif (!isCollapsed) {\n\t\tTransforms.collapse(editor, { edge: 'start' })\n\t}\n\tTransforms.insertNodes(editor, ScrollTarget)\n}\n"],"names":["SlateElement","Editor","Transforms","SlateRange"],"mappings":";;;AAGO,MAAM,0BAA0B;AAQ1B,MAAA,wBAAwB,CAAC,YACrCA,
|
|
1
|
+
{"version":3,"file":"ScrollTargetElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/ScrollTargetElement.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 scrollTargetElementType = 'scrollTarget' as const\n\nexport interface ScrollTargetElement extends SlateElement {\n\ttype: typeof scrollTargetElementType\n\tidentifier: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isScrollTargetElement = (element: SlateNode): element is ScrollTargetElement =>\n\tSlateElement.isElement(element) && element.type === scrollTargetElementType\n\nexport const isScrollTargetElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isScrollTargetElement })\n\treturn !!link\n}\n\nexport const scrollTargetElementPlugin = ({ render }: { render: ElementRenderer<ScrollTargetElement> }): EditorElementPlugin<ScrollTargetElement> => ({\n\ttype: scrollTargetElementType,\n\trender,\n\tisActive: ({ editor }) => isScrollTargetElementActive(editor),\n\tisInline: true,\n\tisVoid: true,\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isScrollTargetElementActive(editor)) {\n\t\t\tunwrapScrollTarget(editor)\n\t\t} else {\n\t\t\tlet identifier =\n\t\t\t\tsuchThat?.identifier ??\n\t\t\t\tprompt('Insert the identifier:')\n\n\t\t\tif (!identifier) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\twrapScrollTarget(editor, identifier)\n\t\t}\n\t},\n})\nconst unwrapScrollTarget = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isScrollTargetElement })\n}\nconst wrapScrollTarget = (editor: Editor, identifier: string) => {\n\tif (isScrollTargetElementActive(editor)) {\n\t\tunwrapScrollTarget(editor)\n\t}\n\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\tconst ScrollTarget: ScrollTargetElement = {\n\t\ttype: scrollTargetElementType,\n\t\tidentifier,\n\t\tchildren: [{ text: '' }],\n\t}\n\n\tif (!isCollapsed) {\n\t\tTransforms.collapse(editor, { edge: 'start' })\n\t}\n\tTransforms.insertNodes(editor, ScrollTarget)\n}\n"],"names":["SlateElement","Editor","Transforms","SlateRange"],"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etElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/ScrollTargetElement.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 scrollTargetElementType = 'scrollTarget' as const\n\nexport interface ScrollTargetElement extends SlateElement {\n\ttype: typeof scrollTargetElementType\n\tidentifier: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isScrollTargetElement = (element: SlateNode): element is ScrollTargetElement =>\n\tSlateElement.isElement(element) && element.type === scrollTargetElementType\n\nexport const isScrollTargetElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isScrollTargetElement })\n\treturn !!link\n}\n\nexport const scrollTargetElementPlugin = ({ render }: { render: ElementRenderer<ScrollTargetElement> }): EditorElementPlugin<ScrollTargetElement> => ({\n\ttype: scrollTargetElementType,\n\trender,\n\tisActive: ({ editor }) => isScrollTargetElementActive(editor),\n\tisInline: true,\n\tisVoid: true,\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isScrollTargetElementActive(editor)) {\n\t\t\tunwrapScrollTarget(editor)\n\t\t} else {\n\t\t\tlet identifier =\n\t\t\t\tsuchThat?.identifier ??\n\t\t\t\tprompt('Insert the identifier:')\n\n\t\t\tif (!identifier) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\twrapScrollTarget(editor, identifier)\n\t\t}\n\t},\n})\nconst unwrapScrollTarget = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isScrollTargetElement })\n}\nconst wrapScrollTarget = (editor: Editor, identifier: string) => {\n\tif (isScrollTargetElementActive(editor)) {\n\t\tunwrapScrollTarget(editor)\n\t}\n\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\tconst ScrollTarget: ScrollTargetElement = {\n\t\ttype: scrollTargetElementType,\n\t\tidentifier,\n\t\tchildren: [{ text: '' }],\n\t}\n\n\tif (!isCollapsed) {\n\t\tTransforms.collapse(editor, { edge: 'start' })\n\t}\n\tTransforms.insertNodes(editor, ScrollTarget)\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";AAGO,MAAM,0BAA0B;AAQ1B,MAAA,wBAAwB,CAAC,YACrCA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExC,MAAA,8BAA8B,CAAC,WAAmB;AACxD,QAAA,CAAC,IAAI,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"ScrollTargetElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/ScrollTargetElement.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 scrollTargetElementType = 'scrollTarget' as const\n\nexport interface ScrollTargetElement extends SlateElement {\n\ttype: typeof scrollTargetElementType\n\tidentifier: string\n\tchildren: SlateEditor['children']\n}\n\nexport const isScrollTargetElement = (element: SlateNode): element is ScrollTargetElement =>\n\tSlateElement.isElement(element) && element.type === scrollTargetElementType\n\nexport const isScrollTargetElementActive = (editor: Editor) => {\n\tconst [link] = Editor.nodes(editor, { match: isScrollTargetElement })\n\treturn !!link\n}\n\nexport const scrollTargetElementPlugin = ({ render }: { render: ElementRenderer<ScrollTargetElement> }): EditorElementPlugin<ScrollTargetElement> => ({\n\ttype: scrollTargetElementType,\n\trender,\n\tisActive: ({ editor }) => isScrollTargetElementActive(editor),\n\tisInline: true,\n\tisVoid: true,\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\tif (isScrollTargetElementActive(editor)) {\n\t\t\tunwrapScrollTarget(editor)\n\t\t} else {\n\t\t\tlet identifier =\n\t\t\t\tsuchThat?.identifier ??\n\t\t\t\tprompt('Insert the identifier:')\n\n\t\t\tif (!identifier) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\twrapScrollTarget(editor, identifier)\n\t\t}\n\t},\n})\nconst unwrapScrollTarget = (editor: Editor) => {\n\tTransforms.removeNodes(editor, { match: isScrollTargetElement })\n}\nconst wrapScrollTarget = (editor: Editor, identifier: string) => {\n\tif (isScrollTargetElementActive(editor)) {\n\t\tunwrapScrollTarget(editor)\n\t}\n\n\tconst selection = editor.selection\n\tconst isCollapsed = selection ? SlateRange.isCollapsed(selection!) : false\n\tconst ScrollTarget: ScrollTargetElement = {\n\t\ttype: scrollTargetElementType,\n\t\tidentifier,\n\t\tchildren: [{ text: '' }],\n\t}\n\n\tif (!isCollapsed) {\n\t\tTransforms.collapse(editor, { edge: 'start' })\n\t}\n\tTransforms.insertNodes(editor, ScrollTarget)\n}\n"],"names":["SlateElement","SlateRange"],"mappings":";AAGO,MAAM,0BAA0B;AAQ1B,MAAA,wBAAwB,CAAC,YACrCA,QAAa,UAAU,OAAO,KAAK,QAAQ,SAAS;AAExC,MAAA,8BAA8B,CAAC,WAAmB;AACxD,QAAA,CAAC,IAAI,IAAI,OAAO,MAAM,QAAQ,EAAE,OAAO,uBAAuB;AACpE,SAAO,CAAC,CAAC;AACV;AAEO,MAAM,4BAA4B,CAAC,EAAE,cAA0G;AAAA,EACrJ,MAAM;AAAA,EACN;AAAA,EACA,UAAU,CAAC,EAAE,aAAa,4BAA4B,MAAM;AAAA,EAC5D,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe,CAAC,EAAE,QAAQ,eAAe;AACpC,QAAA,4BAA4B,MAAM,GAAG;AACxC,yBAAmB,MAAM;AAAA,IAAA,OACnB;AACN,UAAI,aACH,UAAU,cACV,OAAO,wBAAwB;AAEhC,UAAI,CAAC,YAAY;AAChB;AAAA,MAAA;AAED,uBAAiB,QAAQ,UAAU;AAAA,IAAA;AAAA,EACpC;AAEF;AACA,MAAM,qBAAqB,CAAC,WAAmB;AAC9C,aAAW,YAAY,QAAQ,EAAE,OAAO,uBAAuB;AAChE;AACA,MAAM,mBAAmB,CAAC,QAAgB,eAAuB;AAC5D,MAAA,4BAA4B,MAAM,GAAG;AACxC,uBAAmB,MAAM;AAAA,EAAA;AAG1B,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YAAYC,MAAW,YAAY,SAAU,IAAI;AACrE,QAAM,eAAoC;AAAA,IACzC,MAAM;AAAA,IACN;AAAA,IACA,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA;AAAA,EACxB;AAEA,MAAI,CAAC,aAAa;AACjB,eAAW,SAAS,QAAQ,EAAE,MAAM,SAAS;AAAA,EAAA;AAEnC,aAAA,YAAY,QAAQ,YAAY;AAC5C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withScrollTargets.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/withScrollTargets.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { ScrollTargetElement, scrollTargetElementPlugin } from './ScrollTargetElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withScrollTargets = ({ render }: { render: ElementRenderer<ScrollTargetElement> }) => <E extends Editor>(editor: E): E => {\n\teditor.registerElement(scrollTargetElementPlugin({ render }))\n\treturn editor\n}\n"],"names":["scrollTargetElementPlugin"],"mappings":";;;AAIO,MAAM,oBAAoB,CAAC,EAAE,OAAO,MAAwD,CAAmB,WAAiB;AACtI,SAAO,gBAAgBA,oBAAAA,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"withScrollTargets.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/withScrollTargets.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { ScrollTargetElement, scrollTargetElementPlugin } from './ScrollTargetElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withScrollTargets = ({ render }: { render: ElementRenderer<ScrollTargetElement> }) => <E extends Editor>(editor: E): E => {\n\teditor.registerElement(scrollTargetElementPlugin({ render }))\n\treturn editor\n}\n"],"names":["scrollTargetElementPlugin"],"mappings":";;;AAIO,MAAM,oBAAoB,CAAC,EAAE,OAAO,MAAwD,CAAmB,WAAiB;AACtI,SAAO,gBAAgBA,oBAAAA,0BAA0B,EAAE,OAAQ,CAAA,CAAC;AACrD,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withScrollTargets.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/withScrollTargets.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { ScrollTargetElement, scrollTargetElementPlugin } from './ScrollTargetElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withScrollTargets = ({ render }: { render: ElementRenderer<ScrollTargetElement> }) => <E extends Editor>(editor: E): E => {\n\teditor.registerElement(scrollTargetElementPlugin({ render }))\n\treturn editor\n}\n"],"names":[],"mappings":";AAIO,MAAM,oBAAoB,CAAC,EAAE,OAAO,MAAwD,CAAmB,WAAiB;AACtI,SAAO,gBAAgB,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"withScrollTargets.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/scrollTargets/withScrollTargets.ts"],"sourcesContent":["import { Editor } from 'slate'\nimport { ScrollTargetElement, scrollTargetElementPlugin } from './ScrollTargetElement'\nimport { ElementRenderer } from '../../../types'\n\nexport const withScrollTargets = ({ render }: { render: ElementRenderer<ScrollTargetElement> }) => <E extends Editor>(editor: E): E => {\n\teditor.registerElement(scrollTargetElementPlugin({ render }))\n\treturn editor\n}\n"],"names":[],"mappings":";AAIO,MAAM,oBAAoB,CAAC,EAAE,OAAO,MAAwD,CAAmB,WAAiB;AACtI,SAAO,gBAAgB,0BAA0B,EAAE,OAAQ,CAAA,CAAC;AACrD,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCellElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableCellElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element, Element as SlateElement, Node, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { tableRowElementType } from './TableRowElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableCellElementType = 'tableCell' as const\n\nexport interface TableCellElement extends SlateElement {\n\ttype: typeof tableCellElementType\n\tchildren: SlateEditor['children']\n\theaderScope?: 'row'\n\tjustify?: 'start' | 'center' | 'end'\n}\n\nexport const isTableCellElement = (element: Node): element is TableCellElement => Element.isElement(element) && element.type === tableCellElementType\n\nexport const createEmptyTableCellElement = () => ({\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n\nexport const tableCellElementPlugin = ({ render }: {render: ElementRenderer<TableCellElement>}): EditorElementPlugin<TableCellElement> => ({\n\ttype: tableCellElementType,\n\trender,\n\tnormalizeNode: ({ element, editor, path, preventDefault }) => {\n\t\tif (element.children.length === 1) {\n\t\t\tconst onlyChild = element.children[0]\n\t\t\tif (SlateElement.isElement(onlyChild) && editor.isDefaultElement(onlyChild)) {\n\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\tat: [...path, 0],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!ContemberEditor.hasParentOfType(editor, [element, path], tableRowElementType)) {\n\t\t\tTransforms.unwrapNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t\tif (path[path.length - 1] > 0 && element.headerScope) {\n\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n\tcanContainAnyBlocks: true,\n})\n"],"names":["Element","SlateElement","Transforms","ContemberEditor","tableRowElementType"],"mappings":";;;;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CAAC,YAA+CA,
|
|
1
|
+
{"version":3,"file":"TableCellElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableCellElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element, Element as SlateElement, Node, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { tableRowElementType } from './TableRowElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableCellElementType = 'tableCell' as const\n\nexport interface TableCellElement extends SlateElement {\n\ttype: typeof tableCellElementType\n\tchildren: SlateEditor['children']\n\theaderScope?: 'row'\n\tjustify?: 'start' | 'center' | 'end'\n}\n\nexport const isTableCellElement = (element: Node): element is TableCellElement => Element.isElement(element) && element.type === tableCellElementType\n\nexport const createEmptyTableCellElement = () => ({\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n\nexport const tableCellElementPlugin = ({ render }: {render: ElementRenderer<TableCellElement>}): EditorElementPlugin<TableCellElement> => ({\n\ttype: tableCellElementType,\n\trender,\n\tnormalizeNode: ({ element, editor, path, preventDefault }) => {\n\t\tif (element.children.length === 1) {\n\t\t\tconst onlyChild = element.children[0]\n\t\t\tif (SlateElement.isElement(onlyChild) && editor.isDefaultElement(onlyChild)) {\n\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\tat: [...path, 0],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!ContemberEditor.hasParentOfType(editor, [element, path], tableRowElementType)) {\n\t\t\tTransforms.unwrapNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t\tif (path[path.length - 1] > 0 && element.headerScope) {\n\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n\tcanContainAnyBlocks: true,\n})\n"],"names":["Element","SlateElement","Transforms","ContemberEditor","tableRowElementType"],"mappings":";;;;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CAAC,YAA+CA,MAAA,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAE1H,MAAM,8BAA8B,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA;AACxB;AAGO,MAAM,yBAAyB,CAAC,EAAE,cAAkG;AAAA,EAC1I,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,EAAE,SAAS,QAAQ,MAAM,qBAAqB;AACzD,QAAA,QAAQ,SAAS,WAAW,GAAG;AAC5B,YAAA,YAAY,QAAQ,SAAS,CAAC;AACpC,UAAIC,MAAAA,QAAa,UAAU,SAAS,KAAK,OAAO,iBAAiB,SAAS,GAAG;AAC5EC,cAAA,WAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI,CAAC,GAAG,MAAM,CAAC;AAAA,QAAA,CACf;AAAA,MAAA;AAAA,IACF;AAEG,QAAA,CAACC,MAAAA,gBAAgB,gBAAgB,QAAQ,CAAC,SAAS,IAAI,GAAGC,gBAAAA,mBAAmB,GAAG;AACnFF,YAAAA,WAAW,YAAY,QAAQ,EAAE,IAAI,MAAM;AAC3C,aAAO,eAAe;AAAA,IAAA;AAEvB,QAAI,KAAK,KAAK,SAAS,CAAC,IAAI,KAAK,QAAQ,aAAa;AAC1CA,uBAAA,SAAS,QAAQ,EAAE,aAAa,QAAQ,EAAE,IAAI,MAAM;AAC/D,aAAO,eAAe;AAAA,IAAA;AAAA,EAExB;AAAA,EACA,qBAAqB;AACtB;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCellElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableCellElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element, Element as SlateElement, Node, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { tableRowElementType } from './TableRowElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableCellElementType = 'tableCell' as const\n\nexport interface TableCellElement extends SlateElement {\n\ttype: typeof tableCellElementType\n\tchildren: SlateEditor['children']\n\theaderScope?: 'row'\n\tjustify?: 'start' | 'center' | 'end'\n}\n\nexport const isTableCellElement = (element: Node): element is TableCellElement => Element.isElement(element) && element.type === tableCellElementType\n\nexport const createEmptyTableCellElement = () => ({\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n\nexport const tableCellElementPlugin = ({ render }: {render: ElementRenderer<TableCellElement>}): EditorElementPlugin<TableCellElement> => ({\n\ttype: tableCellElementType,\n\trender,\n\tnormalizeNode: ({ element, editor, path, preventDefault }) => {\n\t\tif (element.children.length === 1) {\n\t\t\tconst onlyChild = element.children[0]\n\t\t\tif (SlateElement.isElement(onlyChild) && editor.isDefaultElement(onlyChild)) {\n\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\tat: [...path, 0],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!ContemberEditor.hasParentOfType(editor, [element, path], tableRowElementType)) {\n\t\t\tTransforms.unwrapNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t\tif (path[path.length - 1] > 0 && element.headerScope) {\n\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n\tcanContainAnyBlocks: true,\n})\n"],"names":["SlateElement"],"mappings":";;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CAAC,YAA+C,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAE1H,MAAM,8BAA8B,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,UAAU,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TableCellElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableCellElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element, Element as SlateElement, Node, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { tableRowElementType } from './TableRowElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableCellElementType = 'tableCell' as const\n\nexport interface TableCellElement extends SlateElement {\n\ttype: typeof tableCellElementType\n\tchildren: SlateEditor['children']\n\theaderScope?: 'row'\n\tjustify?: 'start' | 'center' | 'end'\n}\n\nexport const isTableCellElement = (element: Node): element is TableCellElement => Element.isElement(element) && element.type === tableCellElementType\n\nexport const createEmptyTableCellElement = () => ({\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n\nexport const tableCellElementPlugin = ({ render }: {render: ElementRenderer<TableCellElement>}): EditorElementPlugin<TableCellElement> => ({\n\ttype: tableCellElementType,\n\trender,\n\tnormalizeNode: ({ element, editor, path, preventDefault }) => {\n\t\tif (element.children.length === 1) {\n\t\t\tconst onlyChild = element.children[0]\n\t\t\tif (SlateElement.isElement(onlyChild) && editor.isDefaultElement(onlyChild)) {\n\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\tat: [...path, 0],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!ContemberEditor.hasParentOfType(editor, [element, path], tableRowElementType)) {\n\t\t\tTransforms.unwrapNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t\tif (path[path.length - 1] > 0 && element.headerScope) {\n\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n\tcanContainAnyBlocks: true,\n})\n"],"names":["SlateElement"],"mappings":";;;AAKO,MAAM,uBAAuB;AASvB,MAAA,qBAAqB,CAAC,YAA+C,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAE1H,MAAM,8BAA8B,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA;AACxB;AAGO,MAAM,yBAAyB,CAAC,EAAE,cAAkG;AAAA,EAC1I,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,EAAE,SAAS,QAAQ,MAAM,qBAAqB;AACzD,QAAA,QAAQ,SAAS,WAAW,GAAG;AAC5B,YAAA,YAAY,QAAQ,SAAS,CAAC;AACpC,UAAIA,QAAa,UAAU,SAAS,KAAK,OAAO,iBAAiB,SAAS,GAAG;AAC5E,mBAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI,CAAC,GAAG,MAAM,CAAC;AAAA,QAAA,CACf;AAAA,MAAA;AAAA,IACF;AAEG,QAAA,CAAC,gBAAgB,gBAAgB,QAAQ,CAAC,SAAS,IAAI,GAAG,mBAAmB,GAAG;AACnF,iBAAW,YAAY,QAAQ,EAAE,IAAI,MAAM;AAC3C,aAAO,eAAe;AAAA,IAAA;AAEvB,QAAI,KAAK,KAAK,SAAS,CAAC,IAAI,KAAK,QAAQ,aAAa;AAC1C,iBAAA,SAAS,QAAQ,EAAE,aAAa,QAAQ,EAAE,IAAI,MAAM;AAC/D,aAAO,eAAe;AAAA,IAAA;AAAA,EAExB;AAAA,EACA,qBAAqB;AACtB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Element, Node as SlateNode, Node, NodeEntry, Path as SlatePath, Range as SlateRange, Transforms } from 'slate'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport { gaugeTableColumnCount } from './gaugeTableColumnCount'\nimport { createEmptyTableCellElement } from './TableCellElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableElementType = 'table' as const\n\nexport interface TableElement extends SlateElement {\n\ttype: typeof tableElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isTableElement = (element: Node): element is TableElement => Element.isElement(element) && element.type === tableElementType\n\nexport const createEmptyTableElement = (rowCount = 3, columnCount = 2) => ({\n\ttype: tableElementType,\n\tchildren: Array.from({ length: rowCount }, () => createEmptyTableRowElement(columnCount)),\n})\n\nexport const getTableElementRowCount = (element: TableElement): number => {\n\treturn element.children.length\n}\n\nexport const getTableElementColumnCount = (element: TableElement): number => {\n\tconst firstRow = element.children[0] as TableRowElement | undefined\n\treturn firstRow?.children.length ?? 0\n}\n\nexport const tableElementPlugin = ({ render }: {render: ElementRenderer<TableElement>}): EditorElementPlugin<TableElement> => ({\n\ttype: tableElementType,\n\trender,\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tif (element.children.length === 0) {\n\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\n\t\tlet didTransform = false\n\t\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\t\tif (SlateElement.isElement(child)) {\n\t\t\t\tif (!isTableRowElement(child)) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\t\tTransforms.setNodes(editor, { type: tableRowElementType }, { at: childPath })\n\t\t\t\t\tdidTransform = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tif (didTransform) {\n\t\t\treturn preventDefault()\n\t\t}\n\t\tconst columnCount = gaugeTableColumnCount(element)\n\t\tfor (const [row, childPath] of SlateNode.children(editor, path) as Iterable<NodeEntry<TableRowElement>>) {\n\t\t\tconst currentColumnCount = row.children.length\n\t\t\tif (currentColumnCount === columnCount) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// For the first row, we prepend or insert at the start which in most cases will likely preserve the\n\t\t\t// already existing cells' positions.\n\t\t\tif (currentColumnCount > columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = columnCount; i < currentColumnCount; i++) {\n\t\t\t\t\tTransforms.removeNodes(editor, { at: [...childPath, shouldBiasTowardsStart ? 0 : i] })\n\t\t\t\t}\n\t\t\t} else if (currentColumnCount < columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = currentColumnCount; i < columnCount; i++) {\n\t\t\t\t\tTransforms.insertNodes(editor, createEmptyTableCellElement(), {\n\t\t\t\t\t\tat: [...childPath, shouldBiasTowardsStart ? 0 : i],\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tcanContainAnyBlocks: false,\n\ttoggleElement: ({ editor }) => {\n\t\tconst closestTableEntry = Editor.above(editor, {\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && isTableElement(matchedNode),\n\t\t})\n\t\tif (closestTableEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst { selection } = editor\n\t\tif (!selection || SlateRange.isExpanded(selection)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst closestDefaultEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\tat: selection.focus,\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t})\n\t\tif (!closestDefaultEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst [closestDefault, closestDefaultPath] = closestDefaultEntry\n\n\t\tif (closestDefaultPath.length !== 1) {\n\t\t\treturn // We only support tables at the very top level\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet targetPath: SlatePath\n\t\t\tif (SlateNode.string(closestDefault) === '') {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: closestDefaultPath,\n\t\t\t\t})\n\t\t\t\ttargetPath = closestDefaultPath\n\t\t\t} else {\n\t\t\t\ttargetPath = [closestDefaultPath[0] + 1]\n\t\t\t}\n\t\t\tconst table = createEmptyTableElement()\n\n\t\t\tTransforms.insertNodes(editor, table, {\n\t\t\t\tat: targetPath,\n\t\t\t})\n\t\t})\n\t},\n})\n"],"names":["Element","createEmptyTableRowElement","Transforms","SlateNode","SlateElement","isTableRowElement","ContemberEditor","tableRowElementType","gaugeTableColumnCount","createEmptyTableCellElement","Editor","SlateRange"],"mappings":";;;;;;;AAOO,MAAM,mBAAmB;AAOnB,MAAA,iBAAiB,CAAC,YAA2CA,
|
|
1
|
+
{"version":3,"file":"TableElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Element, Node as SlateNode, Node, NodeEntry, Path as SlatePath, Range as SlateRange, Transforms } from 'slate'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport { gaugeTableColumnCount } from './gaugeTableColumnCount'\nimport { createEmptyTableCellElement } from './TableCellElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableElementType = 'table' as const\n\nexport interface TableElement extends SlateElement {\n\ttype: typeof tableElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isTableElement = (element: Node): element is TableElement => Element.isElement(element) && element.type === tableElementType\n\nexport const createEmptyTableElement = (rowCount = 3, columnCount = 2) => ({\n\ttype: tableElementType,\n\tchildren: Array.from({ length: rowCount }, () => createEmptyTableRowElement(columnCount)),\n})\n\nexport const getTableElementRowCount = (element: TableElement): number => {\n\treturn element.children.length\n}\n\nexport const getTableElementColumnCount = (element: TableElement): number => {\n\tconst firstRow = element.children[0] as TableRowElement | undefined\n\treturn firstRow?.children.length ?? 0\n}\n\nexport const tableElementPlugin = ({ render }: {render: ElementRenderer<TableElement>}): EditorElementPlugin<TableElement> => ({\n\ttype: tableElementType,\n\trender,\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tif (element.children.length === 0) {\n\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\n\t\tlet didTransform = false\n\t\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\t\tif (SlateElement.isElement(child)) {\n\t\t\t\tif (!isTableRowElement(child)) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\t\tTransforms.setNodes(editor, { type: tableRowElementType }, { at: childPath })\n\t\t\t\t\tdidTransform = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tif (didTransform) {\n\t\t\treturn preventDefault()\n\t\t}\n\t\tconst columnCount = gaugeTableColumnCount(element)\n\t\tfor (const [row, childPath] of SlateNode.children(editor, path) as Iterable<NodeEntry<TableRowElement>>) {\n\t\t\tconst currentColumnCount = row.children.length\n\t\t\tif (currentColumnCount === columnCount) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// For the first row, we prepend or insert at the start which in most cases will likely preserve the\n\t\t\t// already existing cells' positions.\n\t\t\tif (currentColumnCount > columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = columnCount; i < currentColumnCount; i++) {\n\t\t\t\t\tTransforms.removeNodes(editor, { at: [...childPath, shouldBiasTowardsStart ? 0 : i] })\n\t\t\t\t}\n\t\t\t} else if (currentColumnCount < columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = currentColumnCount; i < columnCount; i++) {\n\t\t\t\t\tTransforms.insertNodes(editor, createEmptyTableCellElement(), {\n\t\t\t\t\t\tat: [...childPath, shouldBiasTowardsStart ? 0 : i],\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tcanContainAnyBlocks: false,\n\ttoggleElement: ({ editor }) => {\n\t\tconst closestTableEntry = Editor.above(editor, {\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && isTableElement(matchedNode),\n\t\t})\n\t\tif (closestTableEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst { selection } = editor\n\t\tif (!selection || SlateRange.isExpanded(selection)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst closestDefaultEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\tat: selection.focus,\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t})\n\t\tif (!closestDefaultEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst [closestDefault, closestDefaultPath] = closestDefaultEntry\n\n\t\tif (closestDefaultPath.length !== 1) {\n\t\t\treturn // We only support tables at the very top level\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet targetPath: SlatePath\n\t\t\tif (SlateNode.string(closestDefault) === '') {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: closestDefaultPath,\n\t\t\t\t})\n\t\t\t\ttargetPath = closestDefaultPath\n\t\t\t} else {\n\t\t\t\ttargetPath = [closestDefaultPath[0] + 1]\n\t\t\t}\n\t\t\tconst table = createEmptyTableElement()\n\n\t\t\tTransforms.insertNodes(editor, table, {\n\t\t\t\tat: targetPath,\n\t\t\t})\n\t\t})\n\t},\n})\n"],"names":["Element","createEmptyTableRowElement","Transforms","SlateNode","SlateElement","isTableRowElement","ContemberEditor","tableRowElementType","gaugeTableColumnCount","createEmptyTableCellElement","Editor","SlateRange"],"mappings":";;;;;;;AAOO,MAAM,mBAAmB;AAOnB,MAAA,iBAAiB,CAAC,YAA2CA,MAAA,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAElH,MAAM,0BAA0B,CAAC,WAAW,GAAG,cAAc,OAAO;AAAA,EAC1E,MAAM;AAAA,EACN,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,MAAMC,gBAA2B,2BAAA,WAAW,CAAC;AACzF;AAEa,MAAA,0BAA0B,CAAC,YAAkC;AACzE,SAAO,QAAQ,SAAS;AACzB;AAEa,MAAA,6BAA6B,CAAC,YAAkC;AACtE,QAAA,WAAW,QAAQ,SAAS,CAAC;AAC5B,SAAA,UAAU,SAAS,UAAU;AACrC;AAEO,MAAM,qBAAqB,CAAC,EAAE,cAA0F;AAAA,EAC9H,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC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ages/react-slate-editor-base/src/plugins/element/tables/TableElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Element, Node as SlateNode, Node, NodeEntry, Path as SlatePath, Range as SlateRange, Transforms } from 'slate'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport { gaugeTableColumnCount } from './gaugeTableColumnCount'\nimport { createEmptyTableCellElement } from './TableCellElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableElementType = 'table' as const\n\nexport interface TableElement extends SlateElement {\n\ttype: typeof tableElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isTableElement = (element: Node): element is TableElement => Element.isElement(element) && element.type === tableElementType\n\nexport const createEmptyTableElement = (rowCount = 3, columnCount = 2) => ({\n\ttype: tableElementType,\n\tchildren: Array.from({ length: rowCount }, () => createEmptyTableRowElement(columnCount)),\n})\n\nexport const getTableElementRowCount = (element: TableElement): number => {\n\treturn element.children.length\n}\n\nexport const getTableElementColumnCount = (element: TableElement): number => {\n\tconst firstRow = element.children[0] as TableRowElement | undefined\n\treturn firstRow?.children.length ?? 0\n}\n\nexport const tableElementPlugin = ({ render }: {render: ElementRenderer<TableElement>}): EditorElementPlugin<TableElement> => ({\n\ttype: tableElementType,\n\trender,\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tif (element.children.length === 0) {\n\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\n\t\tlet didTransform = false\n\t\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\t\tif (SlateElement.isElement(child)) {\n\t\t\t\tif (!isTableRowElement(child)) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\t\tTransforms.setNodes(editor, { type: tableRowElementType }, { at: childPath })\n\t\t\t\t\tdidTransform = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tif (didTransform) {\n\t\t\treturn preventDefault()\n\t\t}\n\t\tconst columnCount = gaugeTableColumnCount(element)\n\t\tfor (const [row, childPath] of SlateNode.children(editor, path) as Iterable<NodeEntry<TableRowElement>>) {\n\t\t\tconst currentColumnCount = row.children.length\n\t\t\tif (currentColumnCount === columnCount) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// For the first row, we prepend or insert at the start which in most cases will likely preserve the\n\t\t\t// already existing cells' positions.\n\t\t\tif (currentColumnCount > columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = columnCount; i < currentColumnCount; i++) {\n\t\t\t\t\tTransforms.removeNodes(editor, { at: [...childPath, shouldBiasTowardsStart ? 0 : i] })\n\t\t\t\t}\n\t\t\t} else if (currentColumnCount < columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = currentColumnCount; i < columnCount; i++) {\n\t\t\t\t\tTransforms.insertNodes(editor, createEmptyTableCellElement(), {\n\t\t\t\t\t\tat: [...childPath, shouldBiasTowardsStart ? 0 : i],\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tcanContainAnyBlocks: false,\n\ttoggleElement: ({ editor }) => {\n\t\tconst closestTableEntry = Editor.above(editor, {\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && isTableElement(matchedNode),\n\t\t})\n\t\tif (closestTableEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst { selection } = editor\n\t\tif (!selection || SlateRange.isExpanded(selection)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst closestDefaultEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\tat: selection.focus,\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t})\n\t\tif (!closestDefaultEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst [closestDefault, closestDefaultPath] = closestDefaultEntry\n\n\t\tif (closestDefaultPath.length !== 1) {\n\t\t\treturn // We only support tables at the very top level\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet targetPath: SlatePath\n\t\t\tif (SlateNode.string(closestDefault) === '') {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: closestDefaultPath,\n\t\t\t\t})\n\t\t\t\ttargetPath = closestDefaultPath\n\t\t\t} else {\n\t\t\t\ttargetPath = [closestDefaultPath[0] + 1]\n\t\t\t}\n\t\t\tconst table = createEmptyTableElement()\n\n\t\t\tTransforms.insertNodes(editor, table, {\n\t\t\t\tat: targetPath,\n\t\t\t})\n\t\t})\n\t},\n})\n"],"names":["SlateNode","SlateElement","SlateRange"],"mappings":";;;;;AAOO,MAAM,mBAAmB;AAOnB,MAAA,iBAAiB,CAAC,YAA2C,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAElH,MAAM,0BAA0B,CAAC,WAAW,GAAG,cAAc,OAAO;AAAA,EAC1E,MAAM;AAAA,EACN,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,MAAM,2BAA2B,WAAW,CAAC;AACzF;AAEa,MAAA,0BAA0B,CAAC,YAAkC;AACzE,SAAO,QAAQ,SAAS;AACzB;AAEa,MAAA,6BAA6B,CAAC,YAAkC;AACtE,QAAA,WAAW,QAAQ,SAAS,CAAC;AAC5B,SAAA,UAAU,SAAS,UAAU;AACrC;AAEO,MAAM,qBAAqB,CAAC,EAAE,cAA0F;AAAA,EAC9H,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,SAAS,MAAM,qBAAqB;AACzD,QAAA,QAAQ,SAAS,WAAW,GAAG;AAClC,iBAAW,YAAY,QAAQ,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"TableElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Element, Node as SlateNode, Node, NodeEntry, Path as SlatePath, Range as SlateRange, Transforms } from 'slate'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport { gaugeTableColumnCount } from './gaugeTableColumnCount'\nimport { createEmptyTableCellElement } from './TableCellElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const tableElementType = 'table' as const\n\nexport interface TableElement extends SlateElement {\n\ttype: typeof tableElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isTableElement = (element: Node): element is TableElement => Element.isElement(element) && element.type === tableElementType\n\nexport const createEmptyTableElement = (rowCount = 3, columnCount = 2) => ({\n\ttype: tableElementType,\n\tchildren: Array.from({ length: rowCount }, () => createEmptyTableRowElement(columnCount)),\n})\n\nexport const getTableElementRowCount = (element: TableElement): number => {\n\treturn element.children.length\n}\n\nexport const getTableElementColumnCount = (element: TableElement): number => {\n\tconst firstRow = element.children[0] as TableRowElement | undefined\n\treturn firstRow?.children.length ?? 0\n}\n\nexport const tableElementPlugin = ({ render }: {render: ElementRenderer<TableElement>}): EditorElementPlugin<TableElement> => ({\n\ttype: tableElementType,\n\trender,\n\tnormalizeNode: ({ editor, element, path, preventDefault }) => {\n\t\tif (element.children.length === 0) {\n\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\treturn preventDefault()\n\t\t}\n\n\t\tlet didTransform = false\n\t\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\t\tif (SlateElement.isElement(child)) {\n\t\t\t\tif (!isTableRowElement(child)) {\n\t\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\t\tTransforms.setNodes(editor, { type: tableRowElementType }, { at: childPath })\n\t\t\t\t\tdidTransform = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTransforms.removeNodes(editor, { at: path })\n\t\t\t\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tif (didTransform) {\n\t\t\treturn preventDefault()\n\t\t}\n\t\tconst columnCount = gaugeTableColumnCount(element)\n\t\tfor (const [row, childPath] of SlateNode.children(editor, path) as Iterable<NodeEntry<TableRowElement>>) {\n\t\t\tconst currentColumnCount = row.children.length\n\t\t\tif (currentColumnCount === columnCount) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// For the first row, we prepend or insert at the start which in most cases will likely preserve the\n\t\t\t// already existing cells' positions.\n\t\t\tif (currentColumnCount > columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = columnCount; i < currentColumnCount; i++) {\n\t\t\t\t\tTransforms.removeNodes(editor, { at: [...childPath, shouldBiasTowardsStart ? 0 : i] })\n\t\t\t\t}\n\t\t\t} else if (currentColumnCount < columnCount) {\n\t\t\t\tconst shouldBiasTowardsStart = childPath[childPath.length - 1] === 0\n\t\t\t\tfor (let i = currentColumnCount; i < columnCount; i++) {\n\t\t\t\t\tTransforms.insertNodes(editor, createEmptyTableCellElement(), {\n\t\t\t\t\t\tat: [...childPath, shouldBiasTowardsStart ? 0 : i],\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tcanContainAnyBlocks: false,\n\ttoggleElement: ({ editor }) => {\n\t\tconst closestTableEntry = Editor.above(editor, {\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && isTableElement(matchedNode),\n\t\t})\n\t\tif (closestTableEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst { selection } = editor\n\t\tif (!selection || SlateRange.isExpanded(selection)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst closestDefaultEntry: NodeEntry | undefined = Editor.above(editor, {\n\t\t\tat: selection.focus,\n\t\t\tmode: 'lowest',\n\t\t\tmatch: matchedNode => SlateElement.isElement(matchedNode) && editor.isDefaultElement(matchedNode),\n\t\t})\n\t\tif (!closestDefaultEntry) {\n\t\t\treturn\n\t\t}\n\t\tconst [closestDefault, closestDefaultPath] = closestDefaultEntry\n\n\t\tif (closestDefaultPath.length !== 1) {\n\t\t\treturn // We only support tables at the very top level\n\t\t}\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tlet targetPath: SlatePath\n\t\t\tif (SlateNode.string(closestDefault) === '') {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: closestDefaultPath,\n\t\t\t\t})\n\t\t\t\ttargetPath = closestDefaultPath\n\t\t\t} else {\n\t\t\t\ttargetPath = [closestDefaultPath[0] + 1]\n\t\t\t}\n\t\t\tconst table = createEmptyTableElement()\n\n\t\t\tTransforms.insertNodes(editor, table, {\n\t\t\t\tat: targetPath,\n\t\t\t})\n\t\t})\n\t},\n})\n"],"names":["SlateNode","SlateElement","SlateRange"],"mappings":";;;;;AAOO,MAAM,mBAAmB;AAOnB,MAAA,iBAAiB,CAAC,YAA2C,QAAQ,UAAU,OAAO,KAAK,QAAQ,SAAS;AAElH,MAAM,0BAA0B,CAAC,WAAW,GAAG,cAAc,OAAO;AAAA,EAC1E,MAAM;AAAA,EACN,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,MAAM,2BAA2B,WAAW,CAAC;AACzF;AAEa,MAAA,0BAA0B,CAAC,YAAkC;AACzE,SAAO,QAAQ,SAAS;AACzB;AAEa,MAAA,6BAA6B,CAAC,YAAkC;AACtE,QAAA,WAAW,QAAQ,SAAS,CAAC;AAC5B,SAAA,UAAU,SAAS,UAAU;AACrC;AAEO,MAAM,qBAAqB,CAAC,EAAE,cAA0F;AAAA,EAC9H,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,SAAS,MAAM,qBAAqB;AACzD,QAAA,QAAQ,SAAS,WAAW,GAAG;AAClC,iBAAW,YAAY,QAAQ,EAAE,IAAI,MAAM;AAC3C,aAA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QAAQ;AAAA,MAC9C,MAAM;AAAA,MACN,OAAO,CAAe,gBAAAC,QAAa,UAAU,WAAW,KAAK,eAAe,WAAW;AAAA,IAAA,CACvF;AACD,QAAI,mBAAmB;AACtB;AAAA,IAAA;AAEK,UAAA,EAAE,cAAc;AACtB,QAAI,CAAC,aAAaC,MAAW,WAAW,SAAS,GAAG;AACnD;AAAA,IAAA;AAGK,UAAA,sBAA6C,OAAO,MAAM,QAAQ;AAAA,MACvE,IAAI,UAAU;AAAA,MACd,MAAM;AAAA,MACN,OAAO,iBAAeD,QAAa,UAAU,WAAW,KAAK,OAAO,iBAAiB,WAAW;AAAA,IAAA,CAChG;AACD,QAAI,CAAC,qBAAqB;AACzB;AAAA,IAAA;AAEK,UAAA,CAAC,gBAAgB,kBAAkB,IAAI;AAEzC,QAAA,mBAAmB,WAAW,GAAG;AACpC;AAAA,IAAA;AAGM,WAAA,mBAAmB,QAAQ,MAAM;AACnC,UAAA;AACJ,UAAID,KAAU,OAAO,cAAc,MAAM,IAAI;AAC5C,mBAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI;AAAA,QAAA,CACJ;AACY,qBAAA;AAAA,MAAA,OACP;AACN,qBAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC;AAAA,MAAA;AAExC,YAAM,QAAQ,wBAAwB;AAE3B,iBAAA,YAAY,QAAQ,OAAO;AAAA,QACrC,IAAI;AAAA,MAAA,CACJ;AAAA,IAAA,CACD;AAAA,EAAA;AAEH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableElementSelection.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElementSelection.ts"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Path as SlatePath, Transforms } from 'slate'\nimport { TableCellElement } from './TableCellElement'\nimport { TableElement } from './TableElement'\n\nexport const selectTableCellContents = (editor: Editor, table: TableElement | SlatePath, rowIndex: number, columnIndex: number) => {\n\tif (!Array.isArray(table)) {\n\t\ttable = ReactEditor.findPath(editor, table)\n\t}\n\tTransforms.select(editor, {\n\t\tanchor: Editor.start(editor, [...table, rowIndex, columnIndex]),\n\t\tfocus: Editor.end(editor, [...table, rowIndex, columnIndex]),\n\t})\n}\n\nexport const getTableCellCoordinates = (editor: Editor, element: TableCellElement) => {\n\tconst cellPath = ReactEditor.findPath(editor, element)\n\treturn cellPath.slice(-2) as [number, number]\n}\n"],"names":["ReactEditor","Transforms","Editor"],"mappings":";;;;AAKO,MAAM,0BAA0B,CAAC,QAAgB,OAAiC,UAAkB,gBAAwB;AAClI,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAAA,
|
|
1
|
+
{"version":3,"file":"TableElementSelection.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElementSelection.ts"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Path as SlatePath, Transforms } from 'slate'\nimport { TableCellElement } from './TableCellElement'\nimport { TableElement } from './TableElement'\n\nexport const selectTableCellContents = (editor: Editor, table: TableElement | SlatePath, rowIndex: number, columnIndex: number) => {\n\tif (!Array.isArray(table)) {\n\t\ttable = ReactEditor.findPath(editor, table)\n\t}\n\tTransforms.select(editor, {\n\t\tanchor: Editor.start(editor, [...table, rowIndex, columnIndex]),\n\t\tfocus: Editor.end(editor, [...table, rowIndex, columnIndex]),\n\t})\n}\n\nexport const getTableCellCoordinates = (editor: Editor, element: TableCellElement) => {\n\tconst cellPath = ReactEditor.findPath(editor, element)\n\treturn cellPath.slice(-2) as [number, number]\n}\n"],"names":["ReactEditor","Transforms","Editor"],"mappings":";;;;AAKO,MAAM,0BAA0B,CAAC,QAAgB,OAAiC,UAAkB,gBAAwB;AAClI,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAAA,WAAA,YAAY,SAAS,QAAQ,KAAK;AAAA,EAAA;AAE3CC,QAAA,WAAW,OAAO,QAAQ;AAAA,IACzB,QAAQC,MAAAA,OAAO,MAAM,QAAQ,CAAC,GAAG,OAAO,UAAU,WAAW,CAAC;AAAA,IAC9D,OAAOA,aAAO,IAAI,QAAQ,CAAC,GAAG,OAAO,UAAU,WAAW,CAAC;AAAA,EAAA,CAC3D;AACF;AAEa,MAAA,0BAA0B,CAAC,QAAgB,YAA8B;AACrF,QAAM,WAAWF,WAAA,YAAY,SAAS,QAAQ,OAAO;AAC9C,SAAA,SAAS,MAAM,EAAE;AACzB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableElementSelection.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElementSelection.ts"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Path as SlatePath, Transforms } from 'slate'\nimport { TableCellElement } from './TableCellElement'\nimport { TableElement } from './TableElement'\n\nexport const selectTableCellContents = (editor: Editor, table: TableElement | SlatePath, rowIndex: number, columnIndex: number) => {\n\tif (!Array.isArray(table)) {\n\t\ttable = ReactEditor.findPath(editor, table)\n\t}\n\tTransforms.select(editor, {\n\t\tanchor: Editor.start(editor, [...table, rowIndex, columnIndex]),\n\t\tfocus: Editor.end(editor, [...table, rowIndex, columnIndex]),\n\t})\n}\n\nexport const getTableCellCoordinates = (editor: Editor, element: TableCellElement) => {\n\tconst cellPath = ReactEditor.findPath(editor, element)\n\treturn cellPath.slice(-2) as [number, number]\n}\n"],"names":[],"mappings":";;AAKO,MAAM,0BAA0B,CAAC,QAAgB,OAAiC,UAAkB,gBAAwB;AAClI,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAA,YAAY,SAAS,QAAQ,KAAK;AAAA,
|
|
1
|
+
{"version":3,"file":"TableElementSelection.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableElementSelection.ts"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Path as SlatePath, Transforms } from 'slate'\nimport { TableCellElement } from './TableCellElement'\nimport { TableElement } from './TableElement'\n\nexport const selectTableCellContents = (editor: Editor, table: TableElement | SlatePath, rowIndex: number, columnIndex: number) => {\n\tif (!Array.isArray(table)) {\n\t\ttable = ReactEditor.findPath(editor, table)\n\t}\n\tTransforms.select(editor, {\n\t\tanchor: Editor.start(editor, [...table, rowIndex, columnIndex]),\n\t\tfocus: Editor.end(editor, [...table, rowIndex, columnIndex]),\n\t})\n}\n\nexport const getTableCellCoordinates = (editor: Editor, element: TableCellElement) => {\n\tconst cellPath = ReactEditor.findPath(editor, element)\n\treturn cellPath.slice(-2) as [number, number]\n}\n"],"names":[],"mappings":";;AAKO,MAAM,0BAA0B,CAAC,QAAgB,OAAiC,UAAkB,gBAAwB;AAClI,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAA,YAAY,SAAS,QAAQ,KAAK;AAAA,EAAA;AAE3C,aAAW,OAAO,QAAQ;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,GAAG,OAAO,UAAU,WAAW,CAAC;AAAA,IAC9D,OAAO,OAAO,IAAI,QAAQ,CAAC,GAAG,OAAO,UAAU,WAAW,CAAC;AAAA,EAAA,CAC3D;AACF;AAEa,MAAA,0BAA0B,CAAC,QAAgB,YAA8B;AACrF,QAAM,WAAW,YAAY,SAAS,QAAQ,OAAO;AAC9C,SAAA,SAAS,MAAM,EAAE;AACzB;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const TableCellElement = require("./TableCellElement.cjs");
|
|
4
|
+
const TableElement = require("./TableElement.cjs");
|
|
5
|
+
const TableRowElement = require("./TableRowElement.cjs");
|
|
6
|
+
const tableHTMLDeserializer = {
|
|
7
|
+
processBlockPaste: ({ element, next, cumulativeTextAttrs }) => {
|
|
8
|
+
if (element.tagName === "TABLE") {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
type: TableElement.tableElementType,
|
|
12
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
if (element.tagName === "TR") {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
type: TableRowElement.tableRowElementType,
|
|
20
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
if (element.tagName === "TD" || element.tagName === "TH") {
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
type: TableCellElement.tableCellElementType,
|
|
28
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.tableHTMLDeserializer = tableHTMLDeserializer;
|
|
36
|
+
//# sourceMappingURL=TableHtmlDeserializer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\nimport { tableCellElementType } from './TableCellElement'\nimport { tableElementType } from './TableElement'\nimport { tableRowElementType } from './TableRowElement'\n\nexport const tableHTMLDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'TABLE') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\tif (element.tagName === 'TR') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableRowElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\tif (element.tagName === 'TD' || element.tagName === 'TH') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableCellElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn null\n\t},\n}\n"],"names":["tableElementType","tableRowElementType","tableCellElementType"],"mappings":";;;;;AAKO,MAAM,wBAAgD;AAAA,EAC5D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC1D,QAAA,QAAQ,YAAY,SAAS;AACzB,aAAA;AAAA,QACN;AAAA,UACC,MAAMA,aAAA;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGG,QAAA,QAAQ,YAAY,MAAM;AACtB,aAAA;AAAA,QACN;AAAA,UACC,MAAMC,gBAAA;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGD,QAAI,QAAQ,YAAY,QAAQ,QAAQ,YAAY,MAAM;AAClD,aAAA;AAAA,QACN;AAAA,UACC,MAAMC,iBAAA;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGM,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { tableCellElementType } from "./TableCellElement.js";
|
|
2
|
+
import { tableElementType } from "./TableElement.js";
|
|
3
|
+
import { tableRowElementType } from "./TableRowElement.js";
|
|
4
|
+
const tableHTMLDeserializer = {
|
|
5
|
+
processBlockPaste: ({ element, next, cumulativeTextAttrs }) => {
|
|
6
|
+
if (element.tagName === "TABLE") {
|
|
7
|
+
return [
|
|
8
|
+
{
|
|
9
|
+
type: tableElementType,
|
|
10
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
if (element.tagName === "TR") {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
type: tableRowElementType,
|
|
18
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
if (element.tagName === "TD" || element.tagName === "TH") {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
type: tableCellElementType,
|
|
26
|
+
children: next(element.childNodes, cumulativeTextAttrs)
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
tableHTMLDeserializer
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=TableHtmlDeserializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableHtmlDeserializer.ts"],"sourcesContent":["import { HtmlDeserializerPlugin } from '../../../types'\nimport { tableCellElementType } from './TableCellElement'\nimport { tableElementType } from './TableElement'\nimport { tableRowElementType } from './TableRowElement'\n\nexport const tableHTMLDeserializer: HtmlDeserializerPlugin = {\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'TABLE') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\tif (element.tagName === 'TR') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableRowElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\tif (element.tagName === 'TD' || element.tagName === 'TH') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: tableCellElementType,\n\t\t\t\t\tchildren: next(element.childNodes, cumulativeTextAttrs),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn null\n\t},\n}\n"],"names":[],"mappings":";;;AAKO,MAAM,wBAAgD;AAAA,EAC5D,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC1D,QAAA,QAAQ,YAAY,SAAS;AACzB,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGG,QAAA,QAAQ,YAAY,MAAM;AACtB,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGD,QAAI,QAAQ,YAAY,QAAQ,QAAQ,YAAY,MAAM;AAClD,aAAA;AAAA,QACN;AAAA,UACC,MAAM;AAAA,UACN,UAAU,KAAK,QAAQ,YAAY,mBAAmB;AAAA,QAAA;AAAA,MAExD;AAAA,IAAA;AAGM,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableModifications.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableModifications.ts"],"sourcesContent":["import { Editor, NodeEntry, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\nimport { getTableElementColumnCount, getTableElementRowCount, TableElement } from './TableElement'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tcreateEmptyTableCellElement,\n\tisTableCellElement,\n\tTableCellElement,\n\ttableCellElementType,\n} from './TableCellElement'\n\nexport class TableModifications {\n\tpublic static deleteTableColumn(editor: Editor, element: TableElement, index: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst rowCount = element.children.length\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: [...tablePath, rowIndex, index],\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic static addTableRow(editor: Editor, element: TableElement, index?: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst columnCount = getTableElementColumnCount(element)\n\t\tconst rowIndex = index ?? element.children.length\n\n\t\tlet tableRow: TableRowElement\n\t\tif (element.children.length === 0) {\n\t\t\ttableRow = createEmptyTableRowElement(columnCount)\n\t\t} else {\n\t\t\tconst blueprintRow = element.children[rowIndex === 0 ? 0 : rowIndex - 1] as TableRowElement\n\n\t\t\ttableRow = {\n\t\t\t\t...ContemberEditor.elementToSpecifics(blueprintRow),\n\t\t\t\ttype: tableRowElementType,\n\t\t\t\tchildren: Array.from(\n\t\t\t\t\t{ length: columnCount },\n\t\t\t\t\t(_, columnIndex): TableCellElement => copyTableCell(blueprintRow.children[columnIndex] as TableCellElement),\n\t\t\t\t),\n\t\t\t}\n\n\t\t\tif (rowIndex === 0) {\n\t\t\t\tconst firstRow = element.children[0] as TableRowElement\n\t\t\t\tif (firstRow.headerScope) {\n\t\t\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: [...tablePath, 0] })\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tTransforms.insertNodes(editor, tableRow, {\n\t\t\tat: [...tablePath, rowIndex],\n\t\t})\n\t}\n\n\tpublic static addTableColumn(editor: Editor, element: TableElement, index?: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst columnCount = getTableElementColumnCount(element)\n\t\tconst rowCount = getTableElementRowCount(element)\n\t\tconst columnIndex = index ?? columnCount ?? 0\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\t\tconst tableRow = element.children[rowIndex] as TableRowElement\n\n\t\t\t\tlet tableCell: TableCellElement\n\t\t\t\tif (tableRow.children.length === 0) {\n\t\t\t\t\ttableCell = createEmptyTableCellElement()\n\t\t\t\t} else {\n\t\t\t\t\ttableCell = copyTableCell(tableRow.children[columnIndex === 0 ? 0 : columnIndex - 1] as TableCellElement)\n\n\t\t\t\t\tif (columnIndex === 0) {\n\t\t\t\t\t\tconst firstCell = tableRow.children[0] as TableCellElement\n\t\t\t\t\t\tif (firstCell.headerScope) {\n\t\t\t\t\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: [...tablePath, rowIndex, 0] })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tTransforms.insertNodes(editor, tableCell, {\n\t\t\t\t\tat: [...tablePath, rowIndex, columnIndex],\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic static justifyTableColumn(editor: Editor, element: TableElement, columnIndex: number, direction: TableCellElement['justify']) {\n\t\tforEachCellInColumn(editor, element, columnIndex, ([, cellPath]) => {\n\t\t\tTransforms.setNodes(\n\t\t\t\teditor,\n\t\t\t\t{ justify: direction ?? undefined },\n\t\t\t\t{ match: node => isTableCellElement(node), at: cellPath },\n\t\t\t)\n\t\t})\n\t}\n\n\tpublic static toggleTableRowHeaderScope(editor: Editor, element: TableElement, rowIndex: number, scope: TableRowElement['headerScope']) {\n\t\tconst rowCount = element.children.length\n\t\tif (rowIndex !== 0 || rowCount < 1) {\n\t\t\treturn\n\t\t}\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst firstRow = element.children[0] as TableRowElement\n\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ headerScope: firstRow.headerScope === scope ? undefined : scope },\n\t\t\t{ match: node => isTableRowElement(node), at: [...tablePath, 0] },\n\t\t)\n\t}\n\n\tpublic static toggleTableColumnHeaderScope(editor: Editor, element: TableElement, columnIndex: number, scope: TableCellElement['headerScope']) {\n\t\tlet currentStatusScore = 0\n\t\tconst rowCount = element.children.length\n\n\t\tforEachCellInColumn(editor, element, columnIndex, ([cell]) => {\n\t\t\tcurrentStatusScore += cell.headerScope === scope ? 1 : -1\n\t\t})\n\n\t\t// If none have it or the majority does but not all.\n\t\tconst shouldSetScope =\n\t\t\t-currentStatusScore === rowCount || (currentStatusScore > 0 && currentStatusScore !== rowCount)\n\n\t\tforEachCellInColumn(editor, element, columnIndex, ([, cellPath]) => {\n\t\t\tTransforms.setNodes(\n\t\t\t\teditor,\n\t\t\t\t{ headerScope: shouldSetScope ? scope : undefined },\n\t\t\t\t{ match: node => isTableCellElement(node), at: cellPath },\n\t\t\t)\n\t\t})\n\t}\n\n\tpublic static deleteTableRow(editor: Editor, element: TableElement, index: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tTransforms.removeNodes(editor, {\n\t\t\tat: [...tablePath, index],\n\t\t})\n\t}\n}\n\nconst forEachCellInColumn = (\n\teditor: Editor,\n\telement: TableElement,\n\tcolumnIndex: number,\n\tcallback: (cellEntry: NodeEntry<TableCellElement>) => void,\n) => {\n\tconst tablePath = ReactEditor.findPath(editor, element)\n\tconst rowCount = getTableElementRowCount(element)\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\tcallback(Editor.node(editor, [...tablePath, rowIndex, columnIndex]) as NodeEntry<TableCellElement>)\n\t\t}\n\t})\n}\nconst copyTableCell = (tableCellElement: TableCellElement): TableCellElement => ({\n\t...ContemberEditor.elementToSpecifics(tableCellElement),\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n"],"names":["index","ReactEditor","Editor","Transforms","getTableElementColumnCount","createEmptyTableRowElement","ContemberEditor","tableRowElementType","getTableElementRowCount","createEmptyTableCellElement","isTableCellElement","isTableRowElement","tableCellElementType"],"mappings":";;;;;;;;AAYO,MAAM,mBAAmB;AAAA,EAC/B,OAAc,kBAAkB,QAAgB,SAAuBA,QAAe;AACrF,UAAM,YAAYC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AM;AACvC,aAAS,WAAW,GAAG,WAAW,UAAU,YAAY;AAC9C,eAAAA,MAAAA,OAAO,KAAK,QAAQ,CAAC,GAAG,WAAW,UAAU,WAAW,CAAC,CAAgC;AAAA,IACnG;AAAA,EAAA,CACA;AACF;AACA,MAAM,gBAAgB,CAAC,sBAA0D;AAAA,EAChF,GAAGI,MAAgB,gBAAA,mBAAmB,gBAAgB;AAAA,EACtD,MAAMM,iBAAA;AAAA,EACN,UAAU,CAAC,EAAE,MAAM,IAAI;AACxB;;"}
|
|
1
|
+
{"version":3,"file":"TableModifications.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/tables/TableModifications.ts"],"sourcesContent":["import { Editor, NodeEntry, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\nimport { getTableElementColumnCount, getTableElementRowCount, TableElement } from './TableElement'\nimport { createEmptyTableRowElement, isTableRowElement, TableRowElement, tableRowElementType } from './TableRowElement'\nimport { ContemberEditor } from '../../../editor'\nimport {\n\tcreateEmptyTableCellElement,\n\tisTableCellElement,\n\tTableCellElement,\n\ttableCellElementType,\n} from './TableCellElement'\n\nexport class TableModifications {\n\tpublic static deleteTableColumn(editor: Editor, element: TableElement, index: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst rowCount = element.children.length\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: [...tablePath, rowIndex, index],\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic static addTableRow(editor: Editor, element: TableElement, index?: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst columnCount = getTableElementColumnCount(element)\n\t\tconst rowIndex = index ?? element.children.length\n\n\t\tlet tableRow: TableRowElement\n\t\tif (element.children.length === 0) {\n\t\t\ttableRow = createEmptyTableRowElement(columnCount)\n\t\t} else {\n\t\t\tconst blueprintRow = element.children[rowIndex === 0 ? 0 : rowIndex - 1] as TableRowElement\n\n\t\t\ttableRow = {\n\t\t\t\t...ContemberEditor.elementToSpecifics(blueprintRow),\n\t\t\t\ttype: tableRowElementType,\n\t\t\t\tchildren: Array.from(\n\t\t\t\t\t{ length: columnCount },\n\t\t\t\t\t(_, columnIndex): TableCellElement => copyTableCell(blueprintRow.children[columnIndex] as TableCellElement),\n\t\t\t\t),\n\t\t\t}\n\n\t\t\tif (rowIndex === 0) {\n\t\t\t\tconst firstRow = element.children[0] as TableRowElement\n\t\t\t\tif (firstRow.headerScope) {\n\t\t\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: [...tablePath, 0] })\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tTransforms.insertNodes(editor, tableRow, {\n\t\t\tat: [...tablePath, rowIndex],\n\t\t})\n\t}\n\n\tpublic static addTableColumn(editor: Editor, element: TableElement, index?: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst columnCount = getTableElementColumnCount(element)\n\t\tconst rowCount = getTableElementRowCount(element)\n\t\tconst columnIndex = index ?? columnCount ?? 0\n\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\t\tconst tableRow = element.children[rowIndex] as TableRowElement\n\n\t\t\t\tlet tableCell: TableCellElement\n\t\t\t\tif (tableRow.children.length === 0) {\n\t\t\t\t\ttableCell = createEmptyTableCellElement()\n\t\t\t\t} else {\n\t\t\t\t\ttableCell = copyTableCell(tableRow.children[columnIndex === 0 ? 0 : columnIndex - 1] as TableCellElement)\n\n\t\t\t\t\tif (columnIndex === 0) {\n\t\t\t\t\t\tconst firstCell = tableRow.children[0] as TableCellElement\n\t\t\t\t\t\tif (firstCell.headerScope) {\n\t\t\t\t\t\t\tTransforms.setNodes(editor, { headerScope: null }, { at: [...tablePath, rowIndex, 0] })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tTransforms.insertNodes(editor, tableCell, {\n\t\t\t\t\tat: [...tablePath, rowIndex, columnIndex],\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic static justifyTableColumn(editor: Editor, element: TableElement, columnIndex: number, direction: TableCellElement['justify']) {\n\t\tforEachCellInColumn(editor, element, columnIndex, ([, cellPath]) => {\n\t\t\tTransforms.setNodes(\n\t\t\t\teditor,\n\t\t\t\t{ justify: direction ?? undefined },\n\t\t\t\t{ match: node => isTableCellElement(node), at: cellPath },\n\t\t\t)\n\t\t})\n\t}\n\n\tpublic static toggleTableRowHeaderScope(editor: Editor, element: TableElement, rowIndex: number, scope: TableRowElement['headerScope']) {\n\t\tconst rowCount = element.children.length\n\t\tif (rowIndex !== 0 || rowCount < 1) {\n\t\t\treturn\n\t\t}\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tconst firstRow = element.children[0] as TableRowElement\n\n\t\tTransforms.setNodes(\n\t\t\teditor,\n\t\t\t{ headerScope: firstRow.headerScope === scope ? undefined : scope },\n\t\t\t{ match: node => isTableRowElement(node), at: [...tablePath, 0] },\n\t\t)\n\t}\n\n\tpublic static toggleTableColumnHeaderScope(editor: Editor, element: TableElement, columnIndex: number, scope: TableCellElement['headerScope']) {\n\t\tlet currentStatusScore = 0\n\t\tconst rowCount = element.children.length\n\n\t\tforEachCellInColumn(editor, element, columnIndex, ([cell]) => {\n\t\t\tcurrentStatusScore += cell.headerScope === scope ? 1 : -1\n\t\t})\n\n\t\t// If none have it or the majority does but not all.\n\t\tconst shouldSetScope =\n\t\t\t-currentStatusScore === rowCount || (currentStatusScore > 0 && currentStatusScore !== rowCount)\n\n\t\tforEachCellInColumn(editor, element, columnIndex, ([, cellPath]) => {\n\t\t\tTransforms.setNodes(\n\t\t\t\teditor,\n\t\t\t\t{ headerScope: shouldSetScope ? scope : undefined },\n\t\t\t\t{ match: node => isTableCellElement(node), at: cellPath },\n\t\t\t)\n\t\t})\n\t}\n\n\tpublic static deleteTableRow(editor: Editor, element: TableElement, index: number) {\n\t\tconst tablePath = ReactEditor.findPath(editor, element)\n\t\tTransforms.removeNodes(editor, {\n\t\t\tat: [...tablePath, index],\n\t\t})\n\t}\n}\n\nconst forEachCellInColumn = (\n\teditor: Editor,\n\telement: TableElement,\n\tcolumnIndex: number,\n\tcallback: (cellEntry: NodeEntry<TableCellElement>) => void,\n) => {\n\tconst tablePath = ReactEditor.findPath(editor, element)\n\tconst rowCount = getTableElementRowCount(element)\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\t\tcallback(Editor.node(editor, [...tablePath, rowIndex, columnIndex]) as NodeEntry<TableCellElement>)\n\t\t}\n\t})\n}\nconst copyTableCell = (tableCellElement: TableCellElement): TableCellElement => ({\n\t...ContemberEditor.elementToSpecifics(tableCellElement),\n\ttype: tableCellElementType,\n\tchildren: [{ text: '' }],\n})\n\n"],"names":["index","ReactEditor","Editor","Transforms","getTableElementColumnCount","createEmptyTableRowElement","ContemberEditor","tableRowElementType","getTableElementRowCount","createEmptyTableCellElement","isTableCellElement","isTableRowElement","tableCellElementType"],"mappings":";;;;;;;;AAYO,MAAM,mBAAmB;AAAA,EAC/B,OAAc,kBAAkB,QAAgB,SAAuBA,QAAe;AACrF,UAAM,YAAYC,WAAA,YAAY,SAAS,QAAQ,OAAO;AAChD,UAAA,WAAW,QAAQ,SAAS;AAE3BC,iBAAA,mBAAmB,QAAQ,MAAM;AACvC,eAAS,WAAW,GAAG,WAAW,UAAU,YAAY;AACvDC,cAAA,WAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI,CAAC,GAAG,WAAW,UAAUH,MAAK;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,IACF,CACA;AAAA,EAAA;AAAA,EAGF,OAAc,YAAY,QAAgB,SAAuBA,SAAgB;AAChF,UAAM,YAAYC,WAAA,YAAY,SAAS,QAAQ,OAAO;AACh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ableElementRowCount } from "./TableElement.js";
|
|
4
4
|
import { createEmptyTableRowElement, tableRowElementType, isTableRowElement } from "./TableRowElement.js";
|
|
5
5
|
import { ContemberEditor } from "../../../editor/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { tableCellElementType, createEmptyTableCellElement, isTableCellElement } from "./TableCellElement.js";
|
|
7
7
|
class TableModifications {
|
|
8
8
|
static deleteTableColumn(editor, element, index) {
|
|
9
9
|
const tablePath = ReactEditor.findPath(editor, element);
|