@contember/react-slate-editor-base 2.0.0-alpha.32 → 2.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/development/src/components/RichTextEditor.js.map +1 -1
- package/dist/development/src/components/triggers/EditorElementTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorElementTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorGenericTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorGenericTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorMarkTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorMarkTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/EditorWrapNodeTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/EditorWrapNodeTrigger.js.map +1 -1
- package/dist/development/src/editor/createEditor.cjs.map +1 -1
- package/dist/development/src/editor/createEditor.js.map +1 -1
- package/dist/development/src/editor/createEditorWithEssentials.cjs.map +1 -1
- package/dist/development/src/editor/createEditorWithEssentials.js.map +1 -1
- package/dist/development/src/editor/index.cjs.map +1 -1
- package/dist/development/src/editor/methods/addMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/addMarks.js.map +1 -1
- package/dist/development/src/editor/methods/canToggleMark.cjs.map +1 -1
- package/dist/development/src/editor/methods/canToggleMark.js.map +1 -1
- package/dist/development/src/editor/methods/closest.cjs.map +1 -1
- package/dist/development/src/editor/methods/closest.js.map +1 -1
- package/dist/development/src/editor/methods/closestBlockEntry.cjs.map +1 -1
- package/dist/development/src/editor/methods/ejectElement.cjs.map +1 -1
- package/dist/development/src/editor/methods/ejectElement.js.map +1 -1
- package/dist/development/src/editor/methods/getElementDataAttributes.cjs.map +1 -1
- package/dist/development/src/editor/methods/getElementDataAttributes.js.map +1 -1
- package/dist/development/src/editor/methods/getPreviousSibling.cjs.map +1 -1
- package/dist/development/src/editor/methods/getPreviousSibling.js.map +1 -1
- package/dist/development/src/editor/methods/hasMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/hasMarks.js.map +1 -1
- package/dist/development/src/editor/methods/hasParentOfType.cjs.map +1 -1
- package/dist/development/src/editor/methods/hasParentOfType.js.map +1 -1
- package/dist/development/src/editor/methods/isElementType.cjs.map +1 -1
- package/dist/development/src/editor/methods/isElementType.js.map +1 -1
- package/dist/development/src/editor/methods/permissivelyDeserializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/permissivelyDeserializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/removeMarks.cjs.map +1 -1
- package/dist/development/src/editor/methods/removeMarks.js.map +1 -1
- package/dist/development/src/editor/methods/serializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/serializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/strictlyDeserializeNodes.cjs.map +1 -1
- package/dist/development/src/editor/methods/strictlyDeserializeNodes.js.map +1 -1
- package/dist/development/src/editor/methods/toLatestFormat.cjs.map +1 -1
- package/dist/development/src/editor/methods/toLatestFormat.js.map +1 -1
- package/dist/development/src/internal/components/DefaultElement.cjs.map +1 -1
- package/dist/development/src/internal/components/DefaultElement.js.map +1 -1
- package/dist/development/src/internal/hooks/useRichTextFieldNodes.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useRichTextFieldNodes.js.map +1 -1
- package/dist/development/src/internal/utils/EditorPasteUtils.cjs.map +1 -1
- package/dist/development/src/internal/utils/EditorPasteUtils.js.map +1 -1
- package/dist/development/src/internal/utils/parseUrl.cjs.map +1 -1
- package/dist/development/src/internal/utils/parseUrl.js.map +1 -1
- package/dist/development/src/plugins/attributes/alignment/alignButton.cjs.map +1 -1
- package/dist/development/src/plugins/attributes/alignment/alignButton.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/HtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/HtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/createMarkHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/createMarkHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/withPaste.cjs.map +1 -1
- package/dist/development/src/plugins/behaviour/paste/withPaste.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorElement.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorModifications.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/AnchorModifications.js.map +1 -1
- package/dist/development/src/plugins/element/anchors/withAnchors.cjs.map +1 -1
- package/dist/development/src/plugins/element/anchors/withAnchors.js.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingElement.js.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/HeadingHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/headings/withHeadings.cjs.map +1 -1
- package/dist/development/src/plugins/element/headings/withHeadings.js.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/HorizontalRuleElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/HorizontalRuleElement.js.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/withHorizontalRules.cjs.map +1 -1
- package/dist/development/src/plugins/element/horizonalRules/withHorizontalRules.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/lists/ListItemElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/ListItemElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/OrderedListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/UnorderedListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/dedentListItem.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/dedentListItem.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/indentListItem.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/indentListItem.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/normalizeListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/normalizeListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/toggleListElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/transforms/toggleListElement.js.map +1 -1
- package/dist/development/src/plugins/element/lists/withLists.cjs.map +1 -1
- package/dist/development/src/plugins/element/lists/withLists.js.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/ParagraphElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/ParagraphElement.js.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/withParagraphs.cjs.map +1 -1
- package/dist/development/src/plugins/element/paragraphs/withParagraphs.js.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/ScrollTargetElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/ScrollTargetElement.js.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/withScrollTargets.cjs.map +1 -1
- package/dist/development/src/plugins/element/scrollTargets/withScrollTargets.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableCellElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableCellElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElementSelection.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableElementSelection.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.js +1 -1
- package/dist/development/src/plugins/element/tables/TableModifications.js.map +1 -1
- package/dist/development/src/plugins/element/tables/TableRowElement.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/TableRowElement.js.map +1 -1
- package/dist/development/src/plugins/element/tables/gaugeTableColumnCount.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/gaugeTableColumnCount.js.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/development/src/plugins/text/bold/withBold.cjs.map +1 -1
- package/dist/development/src/plugins/text/bold/withBold.js.map +1 -1
- package/dist/development/src/plugins/text/code/withCode.cjs.map +1 -1
- package/dist/development/src/plugins/text/highlight/withHighlight.cjs.map +1 -1
- package/dist/development/src/plugins/text/italic/withItalic.cjs.map +1 -1
- package/dist/development/src/plugins/text/italic/withItalic.js.map +1 -1
- package/dist/development/src/plugins/text/newline/withNewline.cjs.map +1 -1
- package/dist/development/src/plugins/text/newline/withNewline.js.map +1 -1
- package/dist/development/src/plugins/text/strikeThrough/withStrikeThrough.cjs.map +1 -1
- package/dist/development/src/plugins/text/strikeThrough/withStrikeThrough.js.map +1 -1
- package/dist/development/src/plugins/text/underline/withUnderline.cjs.map +1 -1
- package/dist/development/src/plugins/text/underline/withUnderline.js.map +1 -1
- package/dist/production/src/components/RichTextEditor.cjs.map +1 -1
- package/dist/production/src/components/RichTextEditor.js.map +1 -1
- package/dist/production/src/components/triggers/EditorElementTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorElementTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorGenericTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorGenericTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorMarkTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorMarkTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/EditorWrapNodeTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/EditorWrapNodeTrigger.js.map +1 -1
- package/dist/production/src/editor/createEditor.cjs.map +1 -1
- package/dist/production/src/editor/createEditor.js.map +1 -1
- package/dist/production/src/editor/createEditorWithEssentials.cjs.map +1 -1
- package/dist/production/src/editor/createEditorWithEssentials.js.map +1 -1
- package/dist/production/src/editor/index.cjs.map +1 -1
- package/dist/production/src/editor/methods/addMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/addMarks.js.map +1 -1
- package/dist/production/src/editor/methods/canToggleMark.cjs.map +1 -1
- package/dist/production/src/editor/methods/canToggleMark.js.map +1 -1
- package/dist/production/src/editor/methods/closest.cjs.map +1 -1
- package/dist/production/src/editor/methods/closest.js.map +1 -1
- package/dist/production/src/editor/methods/closestBlockEntry.cjs.map +1 -1
- package/dist/production/src/editor/methods/ejectElement.cjs.map +1 -1
- package/dist/production/src/editor/methods/ejectElement.js.map +1 -1
- package/dist/production/src/editor/methods/getElementDataAttributes.cjs.map +1 -1
- package/dist/production/src/editor/methods/getElementDataAttributes.js.map +1 -1
- package/dist/production/src/editor/methods/getPreviousSibling.cjs.map +1 -1
- package/dist/production/src/editor/methods/getPreviousSibling.js.map +1 -1
- package/dist/production/src/editor/methods/hasMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/hasMarks.js.map +1 -1
- package/dist/production/src/editor/methods/hasParentOfType.cjs.map +1 -1
- package/dist/production/src/editor/methods/hasParentOfType.js.map +1 -1
- package/dist/production/src/editor/methods/isElementType.cjs.map +1 -1
- package/dist/production/src/editor/methods/isElementType.js.map +1 -1
- package/dist/production/src/editor/methods/permissivelyDeserializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/permissivelyDeserializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/removeMarks.cjs.map +1 -1
- package/dist/production/src/editor/methods/removeMarks.js.map +1 -1
- package/dist/production/src/editor/methods/serializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/serializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/strictlyDeserializeNodes.cjs.map +1 -1
- package/dist/production/src/editor/methods/strictlyDeserializeNodes.js.map +1 -1
- package/dist/production/src/editor/methods/toLatestFormat.cjs.map +1 -1
- package/dist/production/src/editor/methods/toLatestFormat.js.map +1 -1
- package/dist/production/src/internal/components/DefaultElement.cjs.map +1 -1
- package/dist/production/src/internal/components/DefaultElement.js.map +1 -1
- package/dist/production/src/internal/hooks/useRichTextFieldNodes.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useRichTextFieldNodes.js.map +1 -1
- package/dist/production/src/internal/utils/EditorPasteUtils.cjs.map +1 -1
- package/dist/production/src/internal/utils/EditorPasteUtils.js.map +1 -1
- package/dist/production/src/internal/utils/parseUrl.cjs.map +1 -1
- package/dist/production/src/internal/utils/parseUrl.js.map +1 -1
- package/dist/production/src/plugins/attributes/alignment/alignButton.cjs.map +1 -1
- package/dist/production/src/plugins/attributes/alignment/alignButton.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/HtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/HtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/createMarkHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/createMarkHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/withPaste.cjs.map +1 -1
- package/dist/production/src/plugins/behaviour/paste/withPaste.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorElement.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorModifications.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/AnchorModifications.js.map +1 -1
- package/dist/production/src/plugins/element/anchors/withAnchors.cjs.map +1 -1
- package/dist/production/src/plugins/element/anchors/withAnchors.js.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingElement.js.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/HeadingHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/headings/withHeadings.cjs.map +1 -1
- package/dist/production/src/plugins/element/headings/withHeadings.js.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/HorizontalRuleElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/HorizontalRuleElement.js.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/withHorizontalRules.cjs.map +1 -1
- package/dist/production/src/plugins/element/horizonalRules/withHorizontalRules.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/lists/ListItemElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/ListItemElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/OrderedListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/UnorderedListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/dedentListItem.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/dedentListItem.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/indentListItem.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/indentListItem.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/normalizeListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/normalizeListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/toggleListElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/transforms/toggleListElement.js.map +1 -1
- package/dist/production/src/plugins/element/lists/withLists.cjs.map +1 -1
- package/dist/production/src/plugins/element/lists/withLists.js.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/ParagraphElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/ParagraphElement.js.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/withParagraphs.cjs.map +1 -1
- package/dist/production/src/plugins/element/paragraphs/withParagraphs.js.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/ScrollTargetElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/ScrollTargetElement.js.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/withScrollTargets.cjs.map +1 -1
- package/dist/production/src/plugins/element/scrollTargets/withScrollTargets.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableCellElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableCellElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElementSelection.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableElementSelection.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.js +1 -1
- package/dist/production/src/plugins/element/tables/TableModifications.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableRowElement.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/TableRowElement.js.map +1 -1
- package/dist/production/src/plugins/element/tables/gaugeTableColumnCount.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/gaugeTableColumnCount.js.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/production/src/plugins/text/bold/withBold.cjs.map +1 -1
- package/dist/production/src/plugins/text/bold/withBold.js.map +1 -1
- package/dist/production/src/plugins/text/code/withCode.cjs.map +1 -1
- package/dist/production/src/plugins/text/highlight/withHighlight.cjs.map +1 -1
- package/dist/production/src/plugins/text/italic/withItalic.cjs.map +1 -1
- package/dist/production/src/plugins/text/italic/withItalic.js.map +1 -1
- package/dist/production/src/plugins/text/newline/withNewline.cjs.map +1 -1
- package/dist/production/src/plugins/text/newline/withNewline.js.map +1 -1
- package/dist/production/src/plugins/text/strikeThrough/withStrikeThrough.cjs.map +1 -1
- package/dist/production/src/plugins/text/strikeThrough/withStrikeThrough.js.map +1 -1
- package/dist/production/src/plugins/text/underline/withUnderline.cjs.map +1 -1
- package/dist/production/src/plugins/text/underline/withUnderline.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListElement.ts"],"sourcesContent":["import { Editor, Element, Element as SlateElement, Node, Path as SlatePath } from 'slate'\nimport { isUnorderedListElement, UnorderedListElement } from './UnorderedListElement'\nimport { isOrderedListElement, OrderedListElement } from './OrderedListElement'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement } from './ListItemElement'\n\nexport const isListElement = <T extends UnorderedListElement | OrderedListElement>(\n\telement: Node,\n\tsuchThat?: Partial<T>,\n): element is T => isOrderedListElement(element, suchThat as Partial<OrderedListElement>) || isUnorderedListElement(element, suchThat as Partial<UnorderedListElement>)\n\nexport const getParentListElement = (editor: Editor): Element | undefined => {\n\tconst closestNonDefaultEntry = ContemberEditor.closest(editor, {\n\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && !editor.isDefaultElement(node),\n\t})\n\tif (!closestNonDefaultEntry) {\n\t\treturn undefined\n\t}\n\tconst [closestNonDefaultElement, closestNonDefaultPath] = closestNonDefaultEntry\n\tif (isListItemElement(closestNonDefaultElement)) {\n\t\treturn Editor.node(editor, SlatePath.parent(closestNonDefaultPath))[0] as SlateElement\n\t} else if (isListElement(closestNonDefaultElement)) {\n\t\treturn closestNonDefaultElement\n\t}\n\treturn undefined\n}\n"],"names":["isOrderedListElement","isUnorderedListElement","ContemberEditor","SlateElement","Editor","isListItemElement","SlatePath"],"mappings":";;;;;;;AAMa,MAAA,gBAAgB,CAC5B,SACA,aACkBA,mBAAA,qBAAqB,SAAS,QAAuC,KAAKC,
|
|
1
|
+
{"version":3,"file":"ListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListElement.ts"],"sourcesContent":["import { Editor, Element, Element as SlateElement, Node, Path as SlatePath } from 'slate'\nimport { isUnorderedListElement, UnorderedListElement } from './UnorderedListElement'\nimport { isOrderedListElement, OrderedListElement } from './OrderedListElement'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement } from './ListItemElement'\n\nexport const isListElement = <T extends UnorderedListElement | OrderedListElement>(\n\telement: Node,\n\tsuchThat?: Partial<T>,\n): element is T => isOrderedListElement(element, suchThat as Partial<OrderedListElement>) || isUnorderedListElement(element, suchThat as Partial<UnorderedListElement>)\n\nexport const getParentListElement = (editor: Editor): Element | undefined => {\n\tconst closestNonDefaultEntry = ContemberEditor.closest(editor, {\n\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && !editor.isDefaultElement(node),\n\t})\n\tif (!closestNonDefaultEntry) {\n\t\treturn undefined\n\t}\n\tconst [closestNonDefaultElement, closestNonDefaultPath] = closestNonDefaultEntry\n\tif (isListItemElement(closestNonDefaultElement)) {\n\t\treturn Editor.node(editor, SlatePath.parent(closestNonDefaultPath))[0] as SlateElement\n\t} else if (isListElement(closestNonDefaultElement)) {\n\t\treturn closestNonDefaultElement\n\t}\n\treturn undefined\n}\n"],"names":["isOrderedListElement","isUnorderedListElement","ContemberEditor","SlateElement","Editor","isListItemElement","SlatePath"],"mappings":";;;;;;;AAMa,MAAA,gBAAgB,CAC5B,SACA,aACkBA,mBAAA,qBAAqB,SAAS,QAAuC,KAAKC,4CAAuB,SAAS,QAAyC;AAEzJ,MAAA,uBAAuB,CAAC,WAAwC;AACtE,QAAA,yBAAyBC,MAAAA,gBAAgB,QAAQ,QAAQ;AAAA,IAC9D,OAAO,CAAA,SAAQC,MAAa,QAAA,UAAU,IAAI,KAAKC,MAAAA,OAAO,QAAQ,QAAQ,IAAI,KAAK,CAAC,OAAO,iBAAiB,IAAI;AAAA,EAAA,CAC5G;AACD,MAAI,CAAC,wBAAwB;AACrB,WAAA;AAAA,EAAA;AAEF,QAAA,CAAC,0BAA0B,qBAAqB,IAAI;AACtD,MAAAC,gBAAAA,kBAAkB,wBAAwB,GAAG;AACzC,WAAAD,MAAA,OAAO,KAAK,QAAQE,MAAAA,KAAU,OAAO,qBAAqB,CAAC,EAAE,CAAC;AAAA,EAAA,WAC3D,cAAc,wBAAwB,GAAG;AAC5C,WAAA;AAAA,EAAA;AAED,SAAA;AACR;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListElement.ts"],"sourcesContent":["import { Editor, Element, Element as SlateElement, Node, Path as SlatePath } from 'slate'\nimport { isUnorderedListElement, UnorderedListElement } from './UnorderedListElement'\nimport { isOrderedListElement, OrderedListElement } from './OrderedListElement'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement } from './ListItemElement'\n\nexport const isListElement = <T extends UnorderedListElement | OrderedListElement>(\n\telement: Node,\n\tsuchThat?: Partial<T>,\n): element is T => isOrderedListElement(element, suchThat as Partial<OrderedListElement>) || isUnorderedListElement(element, suchThat as Partial<UnorderedListElement>)\n\nexport const getParentListElement = (editor: Editor): Element | undefined => {\n\tconst closestNonDefaultEntry = ContemberEditor.closest(editor, {\n\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && !editor.isDefaultElement(node),\n\t})\n\tif (!closestNonDefaultEntry) {\n\t\treturn undefined\n\t}\n\tconst [closestNonDefaultElement, closestNonDefaultPath] = closestNonDefaultEntry\n\tif (isListItemElement(closestNonDefaultElement)) {\n\t\treturn Editor.node(editor, SlatePath.parent(closestNonDefaultPath))[0] as SlateElement\n\t} else if (isListElement(closestNonDefaultElement)) {\n\t\treturn closestNonDefaultElement\n\t}\n\treturn undefined\n}\n"],"names":["SlateElement","SlatePath"],"mappings":";;;;;AAMa,MAAA,gBAAgB,CAC5B,SACA,aACkB,qBAAqB,SAAS,QAAuC,KAAK,uBAAuB,SAAS,QAAyC;AAEzJ,MAAA,uBAAuB,CAAC,WAAwC;AACtE,QAAA,yBAAyB,gBAAgB,QAAQ,QAAQ;AAAA,IAC9D,OAAO,CAAA,SAAQA,QAAa,UAAU,IAAI,KAAK,OAAO,QAAQ,QAAQ,IAAI,KAAK,CAAC,OAAO,iBAAiB,IAAI;AAAA,EAAA,CAC5G;AACD,MAAI,CAAC,wBAAwB;AACrB,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"ListElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListElement.ts"],"sourcesContent":["import { Editor, Element, Element as SlateElement, Node, Path as SlatePath } from 'slate'\nimport { isUnorderedListElement, UnorderedListElement } from './UnorderedListElement'\nimport { isOrderedListElement, OrderedListElement } from './OrderedListElement'\nimport { ContemberEditor } from '../../../editor'\nimport { isListItemElement } from './ListItemElement'\n\nexport const isListElement = <T extends UnorderedListElement | OrderedListElement>(\n\telement: Node,\n\tsuchThat?: Partial<T>,\n): element is T => isOrderedListElement(element, suchThat as Partial<OrderedListElement>) || isUnorderedListElement(element, suchThat as Partial<UnorderedListElement>)\n\nexport const getParentListElement = (editor: Editor): Element | undefined => {\n\tconst closestNonDefaultEntry = ContemberEditor.closest(editor, {\n\t\tmatch: node => SlateElement.isElement(node) && Editor.isBlock(editor, node) && !editor.isDefaultElement(node),\n\t})\n\tif (!closestNonDefaultEntry) {\n\t\treturn undefined\n\t}\n\tconst [closestNonDefaultElement, closestNonDefaultPath] = closestNonDefaultEntry\n\tif (isListItemElement(closestNonDefaultElement)) {\n\t\treturn Editor.node(editor, SlatePath.parent(closestNonDefaultPath))[0] as SlateElement\n\t} else if (isListElement(closestNonDefaultElement)) {\n\t\treturn closestNonDefaultElement\n\t}\n\treturn undefined\n}\n"],"names":["SlateElement","SlatePath"],"mappings":";;;;;AAMa,MAAA,gBAAgB,CAC5B,SACA,aACkB,qBAAqB,SAAS,QAAuC,KAAK,uBAAuB,SAAS,QAAyC;AAEzJ,MAAA,uBAAuB,CAAC,WAAwC;AACtE,QAAA,yBAAyB,gBAAgB,QAAQ,QAAQ;AAAA,IAC9D,OAAO,CAAA,SAAQA,QAAa,UAAU,IAAI,KAAK,OAAO,QAAQ,QAAQ,IAAI,KAAK,CAAC,OAAO,iBAAiB,IAAI;AAAA,EAAA,CAC5G;AACD,MAAI,CAAC,wBAAwB;AACrB,WAAA;AAAA,EAAA;AAEF,QAAA,CAAC,0BAA0B,qBAAqB,IAAI;AACtD,MAAA,kBAAkB,wBAAwB,GAAG;AACzC,WAAA,OAAO,KAAK,QAAQC,KAAU,OAAO,qBAAqB,CAAC,EAAE,CAAC;AAAA,EAAA,WAC3D,cAAc,wBAAwB,GAAG;AAC5C,WAAA;AAAA,EAAA;AAED,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListHtmlDeserializer.ts"],"sourcesContent":["import { unorderedListElementType } from './UnorderedListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { listItemElementType } from './ListItemElement'\nimport { Element as SlateElement } from 'slate'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { NodesWithType } from '../../behaviour/paste/HtmlDeserializer'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport interface ListElementProperties {\n\tordered: boolean\n\tproperties: Record<string, unknown>\n}\n\nexport interface ListHtmlDeserializerOptions {\n\tgetListElementProperties?: (text: string) => ListElementProperties\n}\n\nconst defaultGetListElementProperties = (text: string): ListElementProperties => {\n\tconst firstChar = text[0]\n\treturn {\n\t\tordered: firstChar === 'o' ? false : firstChar.match(/^\\w$/) !== null,\n\t\tproperties: {},\n\t}\n}\n\nexport const listHtmlDeserializerFactory = ({ getListElementProperties = defaultGetListElementProperties }: ListHtmlDeserializerOptions = {}): HtmlDeserializerPlugin => ({\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'UL') {\n\t\t\treturn [{ type: unorderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'OL') {\n\t\t\treturn [{ type: orderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'LI') {\n\t\t\treturn [{ type: listItemElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\treturn null\n\t},\n\tprocessNodeListPaste: ({ nodeList, cumulativeTextAttrs, deserializer }) => {\n\t\tconst result: NodesWithType[] = []\n\t\tlet group: Node[] = []\n\t\tlet groupWasList = false\n\t\tlet isOrdered: boolean = false\n\t\tlet currentListProperties: Record<string, unknown> = {}\n\t\tlet includesList = false\n\t\tlet lastListId: string | null = null\n\n\t\tconst processGroup = (): NodesWithType => {\n\t\t\tif (groupWasList) {\n\t\t\t\treturn {\n\t\t\t\t\telements: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: isOrdered ? orderedListElementType : unorderedListElementType,\n\t\t\t\t\t\t\t...currentListProperties,\n\t\t\t\t\t\t\tchildren: group.map(item => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: listItemElementType,\n\t\t\t\t\t\t\t\t\tchildren: deserializer.deserializeBlocks(\n\t\t\t\t\t\t\t\t\t\tEditorPasteUtils.wordPasteListItemContent(item.childNodes),\n\t\t\t\t\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} as SlateElement,\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn deserializer.processNodeListPaste(group, cumulativeTextAttrs)\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < nodeList.length; i++) {\n\t\t\tconst curr = nodeList[i]\n\t\t\tconst isWhiteSpace = curr.nodeType === Node.TEXT_NODE && curr.textContent?.match(/^\\s*$/) !== null\n\t\t\tif (groupWasList && isWhiteSpace) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet isList = false\n\t\t\tlet listId: string | null = null\n\t\t\tif (curr instanceof HTMLElement && curr.nodeName === 'P') {\n\t\t\t\tconst match = curr.getAttribute('style')?.match(/mso-list:(\\w+ level\\d+ \\w+)/) ?? null\n\t\t\t\tif (match !== null) {\n\t\t\t\t\tisList = true\n\t\t\t\t\tlistId = match[1]\n\n\t\t\t\t\tif (!groupWasList || lastListId === listId) {\n\t\t\t\t\t\tconst textContent = (curr as HTMLElement).textContent!\n\t\t\t\t\t\tconst specifics: ListElementProperties = getListElementProperties(textContent)\n\t\t\t\t\t\tisOrdered = specifics.ordered\n\t\t\t\t\t\tcurrentListProperties = specifics.properties\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isList !== groupWasList || listId !== lastListId) {\n\t\t\t\tincludesList = true\n\t\t\t\tif (group.length > 0) {\n\t\t\t\t\tresult.push(processGroup())\n\t\t\t\t\tgroup = []\n\t\t\t\t}\n\t\t\t}\n\t\t\tgroupWasList = isList\n\t\t\tlastListId = listId\n\t\t\tgroup.push(curr)\n\t\t}\n\n\t\tif (includesList) {\n\t\t\tresult.push(processGroup())\n\t\t\treturn EditorPasteUtils.flattenNodesWithType(result, deserializer.createDefaultElement)\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":["unorderedListElementType","orderedListElementType","listItemElementType","EditorPasteUtils"],"mappings":";;;;;;AAiBA,MAAM,kCAAkC,CAAC,SAAwC;AAC1E,QAAA,YAAY,KAAK,CAAC;AACjB,SAAA;AAAA,IACN,SAAS,cAAc,MAAM,QAAQ,UAAU,MAAM,MAAM,MAAM;AAAA,IACjE,YAAY,
|
|
1
|
+
{"version":3,"file":"ListHtmlDeserializer.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListHtmlDeserializer.ts"],"sourcesContent":["import { unorderedListElementType } from './UnorderedListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { listItemElementType } from './ListItemElement'\nimport { Element as SlateElement } from 'slate'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { NodesWithType } from '../../behaviour/paste/HtmlDeserializer'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport interface ListElementProperties {\n\tordered: boolean\n\tproperties: Record<string, unknown>\n}\n\nexport interface ListHtmlDeserializerOptions {\n\tgetListElementProperties?: (text: string) => ListElementProperties\n}\n\nconst defaultGetListElementProperties = (text: string): ListElementProperties => {\n\tconst firstChar = text[0]\n\treturn {\n\t\tordered: firstChar === 'o' ? false : firstChar.match(/^\\w$/) !== null,\n\t\tproperties: {},\n\t}\n}\n\nexport const listHtmlDeserializerFactory = ({ getListElementProperties = defaultGetListElementProperties }: ListHtmlDeserializerOptions = {}): HtmlDeserializerPlugin => ({\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'UL') {\n\t\t\treturn [{ type: unorderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'OL') {\n\t\t\treturn [{ type: orderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'LI') {\n\t\t\treturn [{ type: listItemElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\treturn null\n\t},\n\tprocessNodeListPaste: ({ nodeList, cumulativeTextAttrs, deserializer }) => {\n\t\tconst result: NodesWithType[] = []\n\t\tlet group: Node[] = []\n\t\tlet groupWasList = false\n\t\tlet isOrdered: boolean = false\n\t\tlet currentListProperties: Record<string, unknown> = {}\n\t\tlet includesList = false\n\t\tlet lastListId: string | null = null\n\n\t\tconst processGroup = (): NodesWithType => {\n\t\t\tif (groupWasList) {\n\t\t\t\treturn {\n\t\t\t\t\telements: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: isOrdered ? orderedListElementType : unorderedListElementType,\n\t\t\t\t\t\t\t...currentListProperties,\n\t\t\t\t\t\t\tchildren: group.map(item => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: listItemElementType,\n\t\t\t\t\t\t\t\t\tchildren: deserializer.deserializeBlocks(\n\t\t\t\t\t\t\t\t\t\tEditorPasteUtils.wordPasteListItemContent(item.childNodes),\n\t\t\t\t\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} as SlateElement,\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn deserializer.processNodeListPaste(group, cumulativeTextAttrs)\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < nodeList.length; i++) {\n\t\t\tconst curr = nodeList[i]\n\t\t\tconst isWhiteSpace = curr.nodeType === Node.TEXT_NODE && curr.textContent?.match(/^\\s*$/) !== null\n\t\t\tif (groupWasList && isWhiteSpace) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet isList = false\n\t\t\tlet listId: string | null = null\n\t\t\tif (curr instanceof HTMLElement && curr.nodeName === 'P') {\n\t\t\t\tconst match = curr.getAttribute('style')?.match(/mso-list:(\\w+ level\\d+ \\w+)/) ?? null\n\t\t\t\tif (match !== null) {\n\t\t\t\t\tisList = true\n\t\t\t\t\tlistId = match[1]\n\n\t\t\t\t\tif (!groupWasList || lastListId === listId) {\n\t\t\t\t\t\tconst textContent = (curr as HTMLElement).textContent!\n\t\t\t\t\t\tconst specifics: ListElementProperties = getListElementProperties(textContent)\n\t\t\t\t\t\tisOrdered = specifics.ordered\n\t\t\t\t\t\tcurrentListProperties = specifics.properties\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isList !== groupWasList || listId !== lastListId) {\n\t\t\t\tincludesList = true\n\t\t\t\tif (group.length > 0) {\n\t\t\t\t\tresult.push(processGroup())\n\t\t\t\t\tgroup = []\n\t\t\t\t}\n\t\t\t}\n\t\t\tgroupWasList = isList\n\t\t\tlastListId = listId\n\t\t\tgroup.push(curr)\n\t\t}\n\n\t\tif (includesList) {\n\t\t\tresult.push(processGroup())\n\t\t\treturn EditorPasteUtils.flattenNodesWithType(result, deserializer.createDefaultElement)\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":["unorderedListElementType","orderedListElementType","listItemElementType","EditorPasteUtils"],"mappings":";;;;;;AAiBA,MAAM,kCAAkC,CAAC,SAAwC;AAC1E,QAAA,YAAY,KAAK,CAAC;AACjB,SAAA;AAAA,IACN,SAAS,cAAc,MAAM,QAAQ,UAAU,MAAM,MAAM,MAAM;AAAA,IACjE,YAAY,CAAA;AAAA,EACb;AACD;AAEO,MAAM,8BAA8B,CAAC,EAAE,2BAA2B,gCAAgC,IAAiC,CAAA,OAAgC;AAAA,EACzK,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC1D,QAAA,QAAQ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AAC9F,UAAI,gBAAgB,cAAc;AACjC;AAAA,MAAA;AAED,UAAI,SAAS;AACb,UAAI,SAAwB;AAC5B,UAAI,gBAAgB,eAAe,KAAK,aAAa,KAAK;AACzD,cAAM,QAAQ,KAAK,aAAa,OAAO,GAAG,MAAM,6BAA6B,KAAK;AAClF,YAAI,UAAU,MAAM;AACV,mBAAA;AACT,mBAAS,MAAM,CAAC;AAEZ,cAAA,CAAC,gBAAgB,eAAe,QAAQ;AAC3C,kBAAM,cAAe,KAAqB;AACpC,kBAAA,YAAmC,yBAAyB,WAAW;AAC7E,wBAAY,UAAU;AACtB,oCAAwB,UAAU;AAAA,UAAA;AAAA,QACnC;AAAA,MACD;AAGG,UAAA,WAAW,gBAAgB,WAAW,YAAY;AACtC,uBAAA;AACX,YAAA,MAAM,SAAS,GAAG;AACd,iBAAA,KAAK,cAAc;AAC1B,kBAAQ,CAAC;AAAA,QAAA;AAAA,MACV;AAEc,qBAAA;AACF,mBAAA;AACb,YAAM,KAAK,IAAI;AAAA,IAAA;AAGhB,QAAI,cAAc;AACV,aAAA,KAAK,cAAc;AAC1B,aAAOA,iBAAiB,iBAAA,qBAAqB,QAAQ,aAAa,oBAAoB;AAAA,IAAA;AAEhF,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListHtmlDeserializer.ts"],"sourcesContent":["import { unorderedListElementType } from './UnorderedListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { listItemElementType } from './ListItemElement'\nimport { Element as SlateElement } from 'slate'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { NodesWithType } from '../../behaviour/paste/HtmlDeserializer'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport interface ListElementProperties {\n\tordered: boolean\n\tproperties: Record<string, unknown>\n}\n\nexport interface ListHtmlDeserializerOptions {\n\tgetListElementProperties?: (text: string) => ListElementProperties\n}\n\nconst defaultGetListElementProperties = (text: string): ListElementProperties => {\n\tconst firstChar = text[0]\n\treturn {\n\t\tordered: firstChar === 'o' ? false : firstChar.match(/^\\w$/) !== null,\n\t\tproperties: {},\n\t}\n}\n\nexport const listHtmlDeserializerFactory = ({ getListElementProperties = defaultGetListElementProperties }: ListHtmlDeserializerOptions = {}): HtmlDeserializerPlugin => ({\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'UL') {\n\t\t\treturn [{ type: unorderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'OL') {\n\t\t\treturn [{ type: orderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'LI') {\n\t\t\treturn [{ type: listItemElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\treturn null\n\t},\n\tprocessNodeListPaste: ({ nodeList, cumulativeTextAttrs, deserializer }) => {\n\t\tconst result: NodesWithType[] = []\n\t\tlet group: Node[] = []\n\t\tlet groupWasList = false\n\t\tlet isOrdered: boolean = false\n\t\tlet currentListProperties: Record<string, unknown> = {}\n\t\tlet includesList = false\n\t\tlet lastListId: string | null = null\n\n\t\tconst processGroup = (): NodesWithType => {\n\t\t\tif (groupWasList) {\n\t\t\t\treturn {\n\t\t\t\t\telements: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: isOrdered ? orderedListElementType : unorderedListElementType,\n\t\t\t\t\t\t\t...currentListProperties,\n\t\t\t\t\t\t\tchildren: group.map(item => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: listItemElementType,\n\t\t\t\t\t\t\t\t\tchildren: deserializer.deserializeBlocks(\n\t\t\t\t\t\t\t\t\t\tEditorPasteUtils.wordPasteListItemContent(item.childNodes),\n\t\t\t\t\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} as SlateElement,\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn deserializer.processNodeListPaste(group, cumulativeTextAttrs)\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < nodeList.length; i++) {\n\t\t\tconst curr = nodeList[i]\n\t\t\tconst isWhiteSpace = curr.nodeType === Node.TEXT_NODE && curr.textContent?.match(/^\\s*$/) !== null\n\t\t\tif (groupWasList && isWhiteSpace) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet isList = false\n\t\t\tlet listId: string | null = null\n\t\t\tif (curr instanceof HTMLElement && curr.nodeName === 'P') {\n\t\t\t\tconst match = curr.getAttribute('style')?.match(/mso-list:(\\w+ level\\d+ \\w+)/) ?? null\n\t\t\t\tif (match !== null) {\n\t\t\t\t\tisList = true\n\t\t\t\t\tlistId = match[1]\n\n\t\t\t\t\tif (!groupWasList || lastListId === listId) {\n\t\t\t\t\t\tconst textContent = (curr as HTMLElement).textContent!\n\t\t\t\t\t\tconst specifics: ListElementProperties = getListElementProperties(textContent)\n\t\t\t\t\t\tisOrdered = specifics.ordered\n\t\t\t\t\t\tcurrentListProperties = specifics.properties\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isList !== groupWasList || listId !== lastListId) {\n\t\t\t\tincludesList = true\n\t\t\t\tif (group.length > 0) {\n\t\t\t\t\tresult.push(processGroup())\n\t\t\t\t\tgroup = []\n\t\t\t\t}\n\t\t\t}\n\t\t\tgroupWasList = isList\n\t\t\tlastListId = listId\n\t\t\tgroup.push(curr)\n\t\t}\n\n\t\tif (includesList) {\n\t\t\tresult.push(processGroup())\n\t\t\treturn EditorPasteUtils.flattenNodesWithType(result, deserializer.createDefaultElement)\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":";;;;AAiBA,MAAM,kCAAkC,CAAC,SAAwC;AAC1E,QAAA,YAAY,KAAK,CAAC;AACjB,SAAA;AAAA,IACN,SAAS,cAAc,MAAM,QAAQ,UAAU,MAAM,MAAM,MAAM;AAAA,IACjE,YAAY,
|
|
1
|
+
{"version":3,"file":"ListHtmlDeserializer.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListHtmlDeserializer.ts"],"sourcesContent":["import { unorderedListElementType } from './UnorderedListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { listItemElementType } from './ListItemElement'\nimport { Element as SlateElement } from 'slate'\nimport { HtmlDeserializerPlugin } from '../../../types'\nimport { NodesWithType } from '../../behaviour/paste/HtmlDeserializer'\nimport { EditorPasteUtils } from '../../../internal/utils/EditorPasteUtils'\n\nexport interface ListElementProperties {\n\tordered: boolean\n\tproperties: Record<string, unknown>\n}\n\nexport interface ListHtmlDeserializerOptions {\n\tgetListElementProperties?: (text: string) => ListElementProperties\n}\n\nconst defaultGetListElementProperties = (text: string): ListElementProperties => {\n\tconst firstChar = text[0]\n\treturn {\n\t\tordered: firstChar === 'o' ? false : firstChar.match(/^\\w$/) !== null,\n\t\tproperties: {},\n\t}\n}\n\nexport const listHtmlDeserializerFactory = ({ getListElementProperties = defaultGetListElementProperties }: ListHtmlDeserializerOptions = {}): HtmlDeserializerPlugin => ({\n\tprocessBlockPaste: ({ element, next, cumulativeTextAttrs }) => {\n\t\tif (element.tagName === 'UL') {\n\t\t\treturn [{ type: unorderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'OL') {\n\t\t\treturn [{ type: orderedListElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\tif (element.tagName === 'LI') {\n\t\t\treturn [{ type: listItemElementType, children: next(element.childNodes, cumulativeTextAttrs) }]\n\t\t}\n\t\treturn null\n\t},\n\tprocessNodeListPaste: ({ nodeList, cumulativeTextAttrs, deserializer }) => {\n\t\tconst result: NodesWithType[] = []\n\t\tlet group: Node[] = []\n\t\tlet groupWasList = false\n\t\tlet isOrdered: boolean = false\n\t\tlet currentListProperties: Record<string, unknown> = {}\n\t\tlet includesList = false\n\t\tlet lastListId: string | null = null\n\n\t\tconst processGroup = (): NodesWithType => {\n\t\t\tif (groupWasList) {\n\t\t\t\treturn {\n\t\t\t\t\telements: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: isOrdered ? orderedListElementType : unorderedListElementType,\n\t\t\t\t\t\t\t...currentListProperties,\n\t\t\t\t\t\t\tchildren: group.map(item => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: listItemElementType,\n\t\t\t\t\t\t\t\t\tchildren: deserializer.deserializeBlocks(\n\t\t\t\t\t\t\t\t\t\tEditorPasteUtils.wordPasteListItemContent(item.childNodes),\n\t\t\t\t\t\t\t\t\t\tcumulativeTextAttrs,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} as SlateElement,\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn deserializer.processNodeListPaste(group, cumulativeTextAttrs)\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < nodeList.length; i++) {\n\t\t\tconst curr = nodeList[i]\n\t\t\tconst isWhiteSpace = curr.nodeType === Node.TEXT_NODE && curr.textContent?.match(/^\\s*$/) !== null\n\t\t\tif (groupWasList && isWhiteSpace) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet isList = false\n\t\t\tlet listId: string | null = null\n\t\t\tif (curr instanceof HTMLElement && curr.nodeName === 'P') {\n\t\t\t\tconst match = curr.getAttribute('style')?.match(/mso-list:(\\w+ level\\d+ \\w+)/) ?? null\n\t\t\t\tif (match !== null) {\n\t\t\t\t\tisList = true\n\t\t\t\t\tlistId = match[1]\n\n\t\t\t\t\tif (!groupWasList || lastListId === listId) {\n\t\t\t\t\t\tconst textContent = (curr as HTMLElement).textContent!\n\t\t\t\t\t\tconst specifics: ListElementProperties = getListElementProperties(textContent)\n\t\t\t\t\t\tisOrdered = specifics.ordered\n\t\t\t\t\t\tcurrentListProperties = specifics.properties\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isList !== groupWasList || listId !== lastListId) {\n\t\t\t\tincludesList = true\n\t\t\t\tif (group.length > 0) {\n\t\t\t\t\tresult.push(processGroup())\n\t\t\t\t\tgroup = []\n\t\t\t\t}\n\t\t\t}\n\t\t\tgroupWasList = isList\n\t\t\tlastListId = listId\n\t\t\tgroup.push(curr)\n\t\t}\n\n\t\tif (includesList) {\n\t\t\tresult.push(processGroup())\n\t\t\treturn EditorPasteUtils.flattenNodesWithType(result, deserializer.createDefaultElement)\n\t\t}\n\t\treturn null\n\t},\n})\n"],"names":[],"mappings":";;;;AAiBA,MAAM,kCAAkC,CAAC,SAAwC;AAC1E,QAAA,YAAY,KAAK,CAAC;AACjB,SAAA;AAAA,IACN,SAAS,cAAc,MAAM,QAAQ,UAAU,MAAM,MAAM,MAAM;AAAA,IACjE,YAAY,CAAA;AAAA,EACb;AACD;AAEO,MAAM,8BAA8B,CAAC,EAAE,2BAA2B,gCAAgC,IAAiC,CAAA,OAAgC;AAAA,EACzK,mBAAmB,CAAC,EAAE,SAAS,MAAM,0BAA0B;AAC1D,QAAA,QAAQ,YAAY,MAAM;AACtB,aAAA,CAAC,EAAE,MAAM,0BAA0B,UAAU,KAAK,QAAQ,YAAY,mBAAmB,GAAG;AAAA,IAAA;AAEhG,QAAA,QAAQ,YAAY,MAAM;AACtB,aAAA,CAAC,EAAE,MAAM,wBAAwB,UAAU,KAAK,QAAQ,YAAY,mBAAmB,GAAG;AAAA,IAAA;AAE9F,QAAA,QAAQ,YAAY,MAAM;AACtB,aAAA,CAAC,EAAE,MAAM,qBAAqB,UAAU,KAAK,QAAQ,YAAY,mBAAmB,GAAG;AAAA,IAAA;AAExF,WAAA;AAAA,EACR;AAAA,EACA,sB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WAAW,gBAAgB,WAAW,YAAY;AACtC,uBAAA;AACX,YAAA,MAAM,SAAS,GAAG;AACd,iBAAA,KAAK,cAAc;AAC1B,kBAAQ,CAAC;AAAA,QAAA;AAAA,MACV;AAEc,qBAAA;AACF,mBAAA;AACb,YAAM,KAAK,IAAI;AAAA,IAAA;AAGhB,QAAI,cAAc;AACV,aAAA,KAAK,cAAc;AAC1B,aAAO,iBAAiB,qBAAqB,QAAQ,aAAa,oBAAoB;AAAA,IAAA;AAEhF,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListItemElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListElement } from './ListElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const listItemElementType = 'listItem' as const\n\nexport interface ListItemElement extends SlateElement {\n\ttype: typeof listItemElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isListItemElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ListItemElement>,\n): element is ListItemElement => ContemberEditor.isElementType(element, listItemElementType, suchThat)\n\n\nexport const listItemElementPlugin = ({ render }: { render: ElementRenderer<ListItemElement> }): EditorElementPlugin<ListItemElement> => ({\n\ttype: listItemElementType,\n\trender,\n\tcanContainAnyBlocks: true,\n\tnormalizeNode: ({ editor, path, element, preventDefault }) => {\n\t\tconst parentEntry = Editor.above(editor, { at: path })\n\t\tif (parentEntry === undefined || !isListElement(parentEntry[0])) {\n\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\tconst defaultElement = editor.createDefaultElement([{ text: '' }])\n\t\t\t\tTransforms.wrapNodes(editor, defaultElement, {\n\t\t\t\t\tat: path,\n\t\t\t\t})\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\treturn preventDefault()\n\t\t}\n\t\tif (element.children.every(it => isListItemElement(it))) {\n\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\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\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tconst firstChild = element.children[0]\n\t\tif (SlateElement.isElement(firstChild) && isListElement(firstChild)) {\n\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\tat: [...path, 0],\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["ContemberEditor","Editor","isListElement","Transforms","SlateElement"],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAOtB,MAAA,oBAAoB,CAChC,SACA,aACgCA,
|
|
1
|
+
{"version":3,"file":"ListItemElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListItemElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListElement } from './ListElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const listItemElementType = 'listItem' as const\n\nexport interface ListItemElement extends SlateElement {\n\ttype: typeof listItemElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isListItemElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ListItemElement>,\n): element is ListItemElement => ContemberEditor.isElementType(element, listItemElementType, suchThat)\n\n\nexport const listItemElementPlugin = ({ render }: { render: ElementRenderer<ListItemElement> }): EditorElementPlugin<ListItemElement> => ({\n\ttype: listItemElementType,\n\trender,\n\tcanContainAnyBlocks: true,\n\tnormalizeNode: ({ editor, path, element, preventDefault }) => {\n\t\tconst parentEntry = Editor.above(editor, { at: path })\n\t\tif (parentEntry === undefined || !isListElement(parentEntry[0])) {\n\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\tconst defaultElement = editor.createDefaultElement([{ text: '' }])\n\t\t\t\tTransforms.wrapNodes(editor, defaultElement, {\n\t\t\t\t\tat: path,\n\t\t\t\t})\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\treturn preventDefault()\n\t\t}\n\t\tif (element.children.every(it => isListItemElement(it))) {\n\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\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\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tconst firstChild = element.children[0]\n\t\tif (SlateElement.isElement(firstChild) && isListElement(firstChild)) {\n\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\tat: [...path, 0],\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["ContemberEditor","Editor","isListElement","Transforms","SlateElement"],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAOtB,MAAA,oBAAoB,CAChC,SACA,aACgCA,sBAAgB,cAAc,SAAS,qBAAqB,QAAQ;AAG9F,MAAM,wBAAwB,CAAC,EAAE,cAAkG;AAAA,EACzI,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,eAAe,CAAC,EAAE,QAAQ,MAAM,SAAS,qBAAqB;A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"version":3,"file":"ListItemElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListItemElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListElement } from './ListElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const listItemElementType = 'listItem' as const\n\nexport interface ListItemElement extends SlateElement {\n\ttype: typeof listItemElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isListItemElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ListItemElement>,\n): element is ListItemElement => ContemberEditor.isElementType(element, listItemElementType, suchThat)\n\n\nexport const listItemElementPlugin = ({ render }: { render: ElementRenderer<ListItemElement> }): EditorElementPlugin<ListItemElement> => ({\n\ttype: listItemElementType,\n\trender,\n\tcanContainAnyBlocks: true,\n\tnormalizeNode: ({ editor, path, element, preventDefault }) => {\n\t\tconst parentEntry = Editor.above(editor, { at: path })\n\t\tif (parentEntry === undefined || !isListElement(parentEntry[0])) {\n\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\tconst defaultElement = editor.createDefaultElement([{ text: '' }])\n\t\t\t\tTransforms.wrapNodes(editor, defaultElement, {\n\t\t\t\t\tat: path,\n\t\t\t\t})\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\treturn preventDefault()\n\t\t}\n\t\tif (element.children.every(it => isListItemElement(it))) {\n\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\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\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tconst firstChild = element.children[0]\n\t\tif (SlateElement.isElement(firstChild) && isListElement(firstChild)) {\n\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\tat: [...path, 0],\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement"],"mappings":";;;AAKO,MAAM,sBAAsB;AAOtB,MAAA,oBAAoB,CAChC,SACA,aACgC,gBAAgB,cAAc,SAAS,qBAAqB,QAAQ;AAG9F,MAAM,wBAAwB,CAAC,EAAE,cAAkG;AAAA,EACzI,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,eAAe,CAAC,EAAE,QAAQ,MAAM,SAAS,qBAAqB;AAC7D,UAAM,cAAc,OAAO,MAAM,QAAQ,EAAE,IAAI,MAAM;AACrD,QAAI,gBAAgB,UAAa,CAAC,cAAc,YAAY,CAAC,CAAC,GAAG;AACzD,aAAA,mBAAmB,QAAQ,MAAM;AACjC,cAAA,iBAAiB,OAAO,qBAAqB,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ListItemElement.js","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/ListItemElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Editor, Element as SlateElement, Node as SlateNode, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { isListElement } from './ListElement'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const listItemElementType = 'listItem' as const\n\nexport interface ListItemElement extends SlateElement {\n\ttype: typeof listItemElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isListItemElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<ListItemElement>,\n): element is ListItemElement => ContemberEditor.isElementType(element, listItemElementType, suchThat)\n\n\nexport const listItemElementPlugin = ({ render }: { render: ElementRenderer<ListItemElement> }): EditorElementPlugin<ListItemElement> => ({\n\ttype: listItemElementType,\n\trender,\n\tcanContainAnyBlocks: true,\n\tnormalizeNode: ({ editor, path, element, preventDefault }) => {\n\t\tconst parentEntry = Editor.above(editor, { at: path })\n\t\tif (parentEntry === undefined || !isListElement(parentEntry[0])) {\n\t\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\t\tconst defaultElement = editor.createDefaultElement([{ text: '' }])\n\t\t\t\tTransforms.wrapNodes(editor, defaultElement, {\n\t\t\t\t\tat: path,\n\t\t\t\t})\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\treturn preventDefault()\n\t\t}\n\t\tif (element.children.every(it => isListItemElement(it))) {\n\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\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\treturn preventDefault()\n\t\t\t}\n\t\t}\n\t\tconst firstChild = element.children[0]\n\t\tif (SlateElement.isElement(firstChild) && isListElement(firstChild)) {\n\t\t\tTransforms.insertNodes(editor, editor.createDefaultElement([{ text: '' }]), {\n\t\t\t\tat: [...path, 0],\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t},\n})\n"],"names":["SlateElement"],"mappings":";;;AAKO,MAAM,sBAAsB;AAOtB,MAAA,oBAAoB,CAChC,SACA,aACgC,gBAAgB,cAAc,SAAS,qBAAqB,QAAQ;AAG9F,MAAM,wBAAwB,CAAC,EAAE,cAAkG;AAAA,EACzI,MAAM;AAAA,EACN;AAAA,EACA,qBAAqB;AAAA,EACrB,eAAe,CAAC,EAAE,QAAQ,MAAM,SAAS,qBAAqB;AAC7D,UAAM,cAAc,OAAO,MAAM,QAAQ,EAAE,IAAI,MAAM;AACrD,QAAI,gBAAgB,UAAa,CAAC,cAAc,YAAY,CAAC,CAAC,GAAG;AACzD,aAAA,mBAAmB,QAAQ,MAAM;AACjC,cAAA,iBAAiB,OAAO,qBAAqB,CAAC,EAAE,MAAM,GAAA,CAAI,CAAC;AACtD,mBAAA,UAAU,QAAQ,gBAAgB;AAAA,UAC5C,IAAI;AAAA,QAAA,CACJ;AACD,mBAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI,CAAC,GAAG,MAAM,CAAC;AAAA,QAAA,CACf;AAAA,MAAA,CACD;AACD,aAAO,eAAe;AAAA,IAAA;AAEvB,QAAI,QAAQ,SAAS,MAAM,QAAM,kBAAkB,EAAE,CAAC,GAAG;AACxD,iBAAW,YAAY,QAAQ;AAAA,QAC9B,IAAI;AAAA,MAAA,CACJ;AACD,aAAO,eAAe;AAAA,IAAA;AAEnB,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;AACD,eAAO,eAAe;AAAA,MAAA;AAAA,IACvB;AAEK,UAAA,aAAa,QAAQ,SAAS,CAAC;AACrC,QAAIA,QAAa,UAAU,UAAU,KAAK,cAAc,UAAU,GAAG;AACzD,iBAAA,YAAY,QAAQ,OAAO,qBAAqB,CAAC,EAAE,MAAM,GAAI,CAAA,CAAC,GAAG;AAAA,QAC3E,IAAI,CAAC,GAAG,MAAM,CAAC;AAAA,MAAA,CACf;AACD,aAAO,eAAe;AAAA,IAAA;AAAA,EACvB;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/OrderedListElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element as SlateElement, Node as SlateNode } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { getParentListElement } from './ListElement'\nimport { unorderedListElementType } from './UnorderedListElement'\nimport { normalizeListElement, toggleListElement } from './transforms'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const orderedListElementType = 'orderedList' as const\n\nexport interface OrderedListElement extends SlateElement {\n\ttype: typeof orderedListElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isOrderedListElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<OrderedListElement>,\n): element is OrderedListElement => ContemberEditor.isElementType(element, orderedListElementType, suchThat)\n\nexport const orderedListElementPlugin = ({ render }: { render: ElementRenderer<OrderedListElement> }): EditorElementPlugin<OrderedListElement> => ({\n\ttype: orderedListElementType,\n\trender,\n\tisActive: ({ editor, suchThat }) => {\n\t\tconst list = getParentListElement(editor)\n\t\treturn list ? isOrderedListElement(list, suchThat) : false\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\ttoggleListElement(editor, orderedListElementType, suchThat, unorderedListElementType)\n\t},\n\tnormalizeNode: normalizeListElement,\n})\n"],"names":["ContemberEditor","getParentListElement","toggleListElement","unorderedListElementType","normalizeListElement"],"mappings":";;;;;;;AAOO,MAAM,yBAAyB;AAOzB,MAAA,uBAAuB,CACnC,SACA,aACmCA,
|
|
1
|
+
{"version":3,"file":"OrderedListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/OrderedListElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element as SlateElement, Node as SlateNode } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { getParentListElement } from './ListElement'\nimport { unorderedListElementType } from './UnorderedListElement'\nimport { normalizeListElement, toggleListElement } from './transforms'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const orderedListElementType = 'orderedList' as const\n\nexport interface OrderedListElement extends SlateElement {\n\ttype: typeof orderedListElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isOrderedListElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<OrderedListElement>,\n): element is OrderedListElement => ContemberEditor.isElementType(element, orderedListElementType, suchThat)\n\nexport const orderedListElementPlugin = ({ render }: { render: ElementRenderer<OrderedListElement> }): EditorElementPlugin<OrderedListElement> => ({\n\ttype: orderedListElementType,\n\trender,\n\tisActive: ({ editor, suchThat }) => {\n\t\tconst list = getParentListElement(editor)\n\t\treturn list ? isOrderedListElement(list, suchThat) : false\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\ttoggleListElement(editor, orderedListElementType, suchThat, unorderedListElementType)\n\t},\n\tnormalizeNode: normalizeListElement,\n})\n"],"names":["ContemberEditor","getParentListElement","toggleListElement","unorderedListElementType","normalizeListElement"],"mappings":";;;;;;;AAOO,MAAM,yBAAyB;AAOzB,MAAA,uBAAuB,CACnC,SACA,aACmCA,sBAAgB,cAAc,SAAS,wBAAwB,QAAQ;AAEpG,MAAM,2BAA2B,CAAC,EAAE,cAAwG;AAAA,EAClJ,MAAM;AAAA,EACN;AAAA,EACA,UAAU,CAAC,EAAE,QAAQ,eAAe;AAC7B,UAAA,OAAOC,iCAAqB,MAAM;AACxC,WAAO,OAAO,qBAAqB,MAAM,QAAQ,IAAI;AAAA,EACtD;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,eAAe;AACtBC,sBAAAA,kBAAA,QAAQ,wBAAwB,UAAUC,qBAAAA,wBAAwB;AAAA,EACrF;AAAA,EACA,eAAeC,qBAAAA;AAChB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnorderedListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/UnorderedListElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element as SlateElement, Node as SlateNode } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { getParentListElement } from './ListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { normalizeListElement, toggleListElement } from './transforms'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const unorderedListElementType = 'unorderedList' as const\n\nexport interface UnorderedListElement extends SlateElement {\n\ttype: typeof unorderedListElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isUnorderedListElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<UnorderedListElement>,\n): element is UnorderedListElement => ContemberEditor.isElementType(element, unorderedListElementType, suchThat)\n\nexport const unorderedListElementPlugin = ({ render }: { render: ElementRenderer<UnorderedListElement> }): EditorElementPlugin<UnorderedListElement> => ({\n\ttype: unorderedListElementType,\n\trender,\n\tisActive: ({ editor, suchThat }) => {\n\t\tconst list = getParentListElement(editor)\n\t\treturn list ? isUnorderedListElement(list, suchThat) : false\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\ttoggleListElement(editor, unorderedListElementType, suchThat, orderedListElementType)\n\t},\n\tnormalizeNode: normalizeListElement,\n})\n"],"names":["ContemberEditor","getParentListElement","toggleListElement","orderedListElementType","normalizeListElement"],"mappings":";;;;;;;AAOO,MAAM,2BAA2B;AAO3B,MAAA,yBAAyB,CACrC,SACA,aACqCA,
|
|
1
|
+
{"version":3,"file":"UnorderedListElement.cjs","sources":["../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/UnorderedListElement.ts"],"sourcesContent":["import { Editor as SlateEditor, Element as SlateElement, Node as SlateNode } from 'slate'\nimport { ContemberEditor } from '../../../editor'\nimport { getParentListElement } from './ListElement'\nimport { orderedListElementType } from './OrderedListElement'\nimport { normalizeListElement, toggleListElement } from './transforms'\nimport { EditorElementPlugin, ElementRenderer } from '../../../types'\n\nexport const unorderedListElementType = 'unorderedList' as const\n\nexport interface UnorderedListElement extends SlateElement {\n\ttype: typeof unorderedListElementType\n\tchildren: SlateEditor['children']\n}\n\nexport const isUnorderedListElement = (\n\telement: SlateNode,\n\tsuchThat?: Partial<UnorderedListElement>,\n): element is UnorderedListElement => ContemberEditor.isElementType(element, unorderedListElementType, suchThat)\n\nexport const unorderedListElementPlugin = ({ render }: { render: ElementRenderer<UnorderedListElement> }): EditorElementPlugin<UnorderedListElement> => ({\n\ttype: unorderedListElementType,\n\trender,\n\tisActive: ({ editor, suchThat }) => {\n\t\tconst list = getParentListElement(editor)\n\t\treturn list ? isUnorderedListElement(list, suchThat) : false\n\t},\n\ttoggleElement: ({ editor, suchThat }) => {\n\t\ttoggleListElement(editor, unorderedListElementType, suchThat, orderedListElementType)\n\t},\n\tnormalizeNode: normalizeListElement,\n})\n"],"names":["ContemberEditor","getParentListElement","toggleListElement","orderedListElementType","normalizeListElement"],"mappings":";;;;;;;AAOO,MAAM,2BAA2B;AAO3B,MAAA,yBAAyB,CACrC,SACA,aACqCA,sBAAgB,cAAc,SAAS,0BAA0B,QAAQ;AAExG,MAAM,6BAA6B,CAAC,EAAE,cAA4G;AAAA,EACxJ,MAAM;AAAA,EACN;AAAA,EACA,UAAU,CAAC,EAAE,QAAQ,eAAe;AAC7B,UAAA,OAAOC,iCAAqB,MAAM;AACxC,WAAO,OAAO,uBAAuB,MAAM,QAAQ,IAAI;AAAA,EACxD;AAAA,EACA,eAAe,CAAC,EAAE,QAAQ,eAAe;AACtBC,sBAAAA,kBAAA,QAAQ,0BAA0B,UAAUC,mBAAAA,sBAAsB;AAAA,EACrF;AAAA,EACA,eAAeC,qBAAAA;AAChB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedentListItem.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/dedentListItem.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport { indentListItem } from './indentListItem'\nimport { isListElement } from '../ListElement'\nimport { isListItemElement } from '../ListItemElement'\n\nexport const dedentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst parentListPath = SlatePath.parent(listItemPath)\n\tconst parentListElement = SlateNode.get(editor, parentListPath) as SlateElement\n\tconst parentListChildrenCount = parentListElement.children.length\n\tconst subsequentListItemCount = parentListChildrenCount - listItemPath[listItemPath.length - 1] - 1\n\n\tif (!isListElement(parentListElement) || parentListPath.length <= 1) {\n\t\treturn false\n\t}\n\tconst parentListItemPath = SlatePath.parent(parentListPath)\n\tconst parentListItemElement = SlateNode.get(editor, parentListItemPath)\n\n\tif (!isListItemElement(parentListItemElement)) {\n\t\treturn false\n\t}\n\n\tconst grandParentListPath = SlatePath.parent(parentListItemPath)\n\tconst grandParentListElement = SlateNode.get(editor, grandParentListPath)\n\n\tif (!isListElement(grandParentListElement)) {\n\t\treturn false\n\t}\n\tconst parentListElementSpecifics = ContemberEditor.elementToSpecifics(parentListElement)\n\tconst parentAndGrandParentAreCompatible = ContemberEditor.isElementType(\n\t\tgrandParentListElement,\n\t\tparentListElement.type,\n\t\tparentListElementSpecifics as any,\n\t)\n\n\t// TODO we need to handle following siblings!!!\n\n\tif (parentAndGrandParentAreCompatible) {\n\t\tconst newListItemPath = SlatePath.next(parentListItemPath)\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tif (subsequentListItemCount) {\n\t\t\t\tconst nextSiblingPath = SlatePath.next(listItemPath)\n\t\t\t\tfor (let i = 0; i < subsequentListItemCount; i++) {\n\t\t\t\t\tconst nextListItem = SlateNode.get(editor, nextSiblingPath) as ListItemElement\n\t\t\t\t\tindentListItem(editor, nextListItem, nextSiblingPath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tif (parentListChildrenCount === 1) {\n\t\t\t\t// We've just moved the last listItem away\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: parentListPath,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\treturn true\n\t} else {\n\t\t// TODO this is recoverable: we can just append the list\n\t}\n\n\treturn false // TODO stub\n}\n"],"names":["SlatePath","SlateNode","isListElement","isListItemElement","ContemberEditor","Editor","indentListItem","Transforms"],"mappings":";;;;;;;AAOO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACP,QAAA,iBAAiBA,MAAAA,KAAU,OAAO,YAAY;AACpD,QAAM,oBAAoBC,MAAA,KAAU,IAAI,QAAQ,cAAc;AACxD,QAAA,0BAA0B,kBAAkB,SAAS;AAC3D,QAAM,0BAA0B,0BAA0B,aAAa,aAAa,SAAS,CAAC,IAAI;AAElG,MAAI,CAACC,YAAc,cAAA,iBAAiB,KAAK,eAAe,UAAU,GAAG;AAC7D,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"dedentListItem.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/dedentListItem.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport { indentListItem } from './indentListItem'\nimport { isListElement } from '../ListElement'\nimport { isListItemElement } from '../ListItemElement'\n\nexport const dedentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst parentListPath = SlatePath.parent(listItemPath)\n\tconst parentListElement = SlateNode.get(editor, parentListPath) as SlateElement\n\tconst parentListChildrenCount = parentListElement.children.length\n\tconst subsequentListItemCount = parentListChildrenCount - listItemPath[listItemPath.length - 1] - 1\n\n\tif (!isListElement(parentListElement) || parentListPath.length <= 1) {\n\t\treturn false\n\t}\n\tconst parentListItemPath = SlatePath.parent(parentListPath)\n\tconst parentListItemElement = SlateNode.get(editor, parentListItemPath)\n\n\tif (!isListItemElement(parentListItemElement)) {\n\t\treturn false\n\t}\n\n\tconst grandParentListPath = SlatePath.parent(parentListItemPath)\n\tconst grandParentListElement = SlateNode.get(editor, grandParentListPath)\n\n\tif (!isListElement(grandParentListElement)) {\n\t\treturn false\n\t}\n\tconst parentListElementSpecifics = ContemberEditor.elementToSpecifics(parentListElement)\n\tconst parentAndGrandParentAreCompatible = ContemberEditor.isElementType(\n\t\tgrandParentListElement,\n\t\tparentListElement.type,\n\t\tparentListElementSpecifics as any,\n\t)\n\n\t// TODO we need to handle following siblings!!!\n\n\tif (parentAndGrandParentAreCompatible) {\n\t\tconst newListItemPath = SlatePath.next(parentListItemPath)\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tif (subsequentListItemCount) {\n\t\t\t\tconst nextSiblingPath = SlatePath.next(listItemPath)\n\t\t\t\tfor (let i = 0; i < subsequentListItemCount; i++) {\n\t\t\t\t\tconst nextListItem = SlateNode.get(editor, nextSiblingPath) as ListItemElement\n\t\t\t\t\tindentListItem(editor, nextListItem, nextSiblingPath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tif (parentListChildrenCount === 1) {\n\t\t\t\t// We've just moved the last listItem away\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: parentListPath,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\treturn true\n\t} else {\n\t\t// TODO this is recoverable: we can just append the list\n\t}\n\n\treturn false // TODO stub\n}\n"],"names":["SlatePath","SlateNode","isListElement","isListItemElement","ContemberEditor","Editor","indentListItem","Transforms"],"mappings":";;;;;;;AAOO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACP,QAAA,iBAAiBA,MAAAA,KAAU,OAAO,YAAY;AACpD,QAAM,oBAAoBC,MAAA,KAAU,IAAI,QAAQ,cAAc;AACxD,QAAA,0BAA0B,kBAAkB,SAAS;AAC3D,QAAM,0BAA0B,0BAA0B,aAAa,aAAa,SAAS,CAAC,IAAI;AAElG,MAAI,CAACC,YAAc,cAAA,iBAAiB,KAAK,eAAe,UAAU,GAAG;AAC7D,WAAA;AAAA,EAAA;AAEF,QAAA,qBAAqBF,MAAAA,KAAU,OAAO,cAAc;AAC1D,QAAM,wBAAwBC,MAAA,KAAU,IAAI,QAAQ,kBAAkB;AAElE,MAAA,CAACE,gBAAAA,kBAAkB,qBAAqB,GAAG;AACvC,WAAA;AAAA,EAAA;AAGF,QAAA,sBAAsBH,MAAAA,KAAU,OAAO,kBAAkB;AAC/D,QAAM,yBAAyBC,MAAA,KAAU,IAAI,QAAQ,mBAAmB;AAEpE,MAAA,CAACC,YAAAA,cAAc,sBAAsB,GAAG;AACpC,WAAA;AAAA,EAAA;AAEF,QAAA,6BAA6BE,MAAAA,gBAAgB,mBAAmB,iBAAiB;AACvF,QAAM,oCAAoCA,MAAAA,gBAAgB;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,EACD;AAIA,MAAI,mCAAmC;AAChC,UAAA,kBAAkBJ,MAAAA,KAAU,KAAK,kBAAkB;AAClDK,iBAAA,mBAAmB,QAAQ,MAAM;AACvC,UAAI,yBAAyB;AACtB,cAAA,kBAAkBL,MAAAA,KAAU,KAAK,YAAY;AACnD,iBAAS,IAAI,GAAG,IAAI,yBAAyB,KAAK;AACjD,gBAAM,eAAeC,MAAA,KAAU,IAAI,QAAQ,eAAe;AAC3CK,wCAAA,QAAQ,cAAc,eAAe;AAAA,QAAA;AAAA,MACrD;AAEDC,YAAA,WAAW,UAAU,QAAQ;AAAA,QAC5B,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA,CACJ;AACD,UAAI,4BAA4B,GAAG;AAElCA,cAAA,WAAW,YAAY,QAAQ;AAAA,UAC9B,IAAI;AAAA,QAAA,CACJ;AAAA,MAAA;AAAA,IACF,CACA;AACM,WAAA;AAAA,EAAA;AAKD,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedentListItem.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/dedentListItem.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport { indentListItem } from './indentListItem'\nimport { isListElement } from '../ListElement'\nimport { isListItemElement } from '../ListItemElement'\n\nexport const dedentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst parentListPath = SlatePath.parent(listItemPath)\n\tconst parentListElement = SlateNode.get(editor, parentListPath) as SlateElement\n\tconst parentListChildrenCount = parentListElement.children.length\n\tconst subsequentListItemCount = parentListChildrenCount - listItemPath[listItemPath.length - 1] - 1\n\n\tif (!isListElement(parentListElement) || parentListPath.length <= 1) {\n\t\treturn false\n\t}\n\tconst parentListItemPath = SlatePath.parent(parentListPath)\n\tconst parentListItemElement = SlateNode.get(editor, parentListItemPath)\n\n\tif (!isListItemElement(parentListItemElement)) {\n\t\treturn false\n\t}\n\n\tconst grandParentListPath = SlatePath.parent(parentListItemPath)\n\tconst grandParentListElement = SlateNode.get(editor, grandParentListPath)\n\n\tif (!isListElement(grandParentListElement)) {\n\t\treturn false\n\t}\n\tconst parentListElementSpecifics = ContemberEditor.elementToSpecifics(parentListElement)\n\tconst parentAndGrandParentAreCompatible = ContemberEditor.isElementType(\n\t\tgrandParentListElement,\n\t\tparentListElement.type,\n\t\tparentListElementSpecifics as any,\n\t)\n\n\t// TODO we need to handle following siblings!!!\n\n\tif (parentAndGrandParentAreCompatible) {\n\t\tconst newListItemPath = SlatePath.next(parentListItemPath)\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tif (subsequentListItemCount) {\n\t\t\t\tconst nextSiblingPath = SlatePath.next(listItemPath)\n\t\t\t\tfor (let i = 0; i < subsequentListItemCount; i++) {\n\t\t\t\t\tconst nextListItem = SlateNode.get(editor, nextSiblingPath) as ListItemElement\n\t\t\t\t\tindentListItem(editor, nextListItem, nextSiblingPath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tif (parentListChildrenCount === 1) {\n\t\t\t\t// We've just moved the last listItem away\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: parentListPath,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\treturn true\n\t} else {\n\t\t// TODO this is recoverable: we can just append the list\n\t}\n\n\treturn false // TODO stub\n}\n"],"names":["SlatePath","SlateNode"],"mappings":";;;;;AAOO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACP,QAAA,iBAAiBA,KAAU,OAAO,YAAY;AACpD,QAAM,oBAAoBC,KAAU,IAAI,QAAQ,cAAc;AACxD,QAAA,0BAA0B,kBAAkB,SAAS;AAC3D,QAAM,0BAA0B,0BAA0B,aAAa,aAAa,SAAS,CAAC,IAAI;AAElG,MAAI,CAAC,cAAc,iBAAiB,KAAK,eAAe,UAAU,GAAG;AAC7D,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"dedentListItem.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/dedentListItem.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport { indentListItem } from './indentListItem'\nimport { isListElement } from '../ListElement'\nimport { isListItemElement } from '../ListItemElement'\n\nexport const dedentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst parentListPath = SlatePath.parent(listItemPath)\n\tconst parentListElement = SlateNode.get(editor, parentListPath) as SlateElement\n\tconst parentListChildrenCount = parentListElement.children.length\n\tconst subsequentListItemCount = parentListChildrenCount - listItemPath[listItemPath.length - 1] - 1\n\n\tif (!isListElement(parentListElement) || parentListPath.length <= 1) {\n\t\treturn false\n\t}\n\tconst parentListItemPath = SlatePath.parent(parentListPath)\n\tconst parentListItemElement = SlateNode.get(editor, parentListItemPath)\n\n\tif (!isListItemElement(parentListItemElement)) {\n\t\treturn false\n\t}\n\n\tconst grandParentListPath = SlatePath.parent(parentListItemPath)\n\tconst grandParentListElement = SlateNode.get(editor, grandParentListPath)\n\n\tif (!isListElement(grandParentListElement)) {\n\t\treturn false\n\t}\n\tconst parentListElementSpecifics = ContemberEditor.elementToSpecifics(parentListElement)\n\tconst parentAndGrandParentAreCompatible = ContemberEditor.isElementType(\n\t\tgrandParentListElement,\n\t\tparentListElement.type,\n\t\tparentListElementSpecifics as any,\n\t)\n\n\t// TODO we need to handle following siblings!!!\n\n\tif (parentAndGrandParentAreCompatible) {\n\t\tconst newListItemPath = SlatePath.next(parentListItemPath)\n\t\tEditor.withoutNormalizing(editor, () => {\n\t\t\tif (subsequentListItemCount) {\n\t\t\t\tconst nextSiblingPath = SlatePath.next(listItemPath)\n\t\t\t\tfor (let i = 0; i < subsequentListItemCount; i++) {\n\t\t\t\t\tconst nextListItem = SlateNode.get(editor, nextSiblingPath) as ListItemElement\n\t\t\t\t\tindentListItem(editor, nextListItem, nextSiblingPath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tif (parentListChildrenCount === 1) {\n\t\t\t\t// We've just moved the last listItem away\n\t\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\t\tat: parentListPath,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\treturn true\n\t} else {\n\t\t// TODO this is recoverable: we can just append the list\n\t}\n\n\treturn false // TODO stub\n}\n"],"names":["SlatePath","SlateNode"],"mappings":";;;;;AAOO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACP,QAAA,iBAAiBA,KAAU,OAAO,YAAY;AACpD,QAAM,oBAAoBC,KAAU,IAAI,QAAQ,cAAc;AACxD,QAAA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ate-editor-base/src/plugins/element/lists/transforms/indentListItem.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tNodeEntry,\n\tPath as SlatePath,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport type { OrderedListElement } from '../OrderedListElement'\nimport type { UnorderedListElement } from '../UnorderedListElement'\n\nexport const indentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst previousListEntry = ContemberEditor.getPreviousSibling<Editor, ListItemElement>(\n\t\teditor,\n\t\tlistItem,\n\t\tlistItemPath,\n\t)\n\tif (previousListEntry === undefined) {\n\t\treturn false\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [parentListElement] = Editor.parent(editor, listItemPath) as NodeEntry<\n\t\t\tOrderedListElement | UnorderedListElement\n\t\t>\n\t\tlet [previousListItem, previousListItemPath] = previousListEntry\n\n\t\tconst lastPreviousListItemChild = previousListItem.children[previousListItem.children.length - 1]\n\t\tconst previousEndsWithCompatibleList =\n\t\t\tSlateElement.isElement(lastPreviousListItemChild) &&\n\t\t\tContemberEditor.isElementType(\n\t\t\t\tlastPreviousListItemChild,\n\t\t\t\tparentListElement.type,\n\t\t\t\tContemberEditor.elementToSpecifics(parentListElement) as any,\n\t\t\t)\n\n\t\tif (previousEndsWithCompatibleList) {\n\t\t\tconst newListItemPath = [\n\t\t\t\t...previousListItemPath,\n\t\t\t\tpreviousListItem.children.length - 1,\n\t\t\t\t(lastPreviousListItemChild as UnorderedListElement | OrderedListElement).children.length,\n\t\t\t]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t} else {\n\t\t\tconst previousContainsInlines = Editor.hasInlines(editor, previousListItem)\n\t\t\tif (previousContainsInlines) {\n\t\t\t\tconst [previousStart, previousEnd] = Editor.edges(editor, previousListItemPath)\n\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\tat: {\n\t\t\t\t\t\tanchor: previousStart,\n\t\t\t\t\t\tfocus: previousEnd,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Getting a new previousListItem because the children may have changed due to the branch above.\n\t\t\tpreviousListItem = SlateNode.get(editor, previousListItemPath) as ListItemElement\n\t\t\t// We're appending at the end: children.length is just lastOne + 1\n\t\t\tconst newListItemPath = [...previousListItemPath, previousListItem.children.length]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { ...parentListElement, children: [] }, { at: newListItemPath })\n\t\t}\n\t})\n\n\treturn true\n}\n"],"names":["ContemberEditor","Editor","SlateElement","Transforms","Text","SlateNode"],"mappings":";;;;AAcO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACb,QAAM,oBAAoBA,MAAAA,gBAAgB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"indentListItem.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/indentListItem.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tNodeEntry,\n\tPath as SlatePath,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport type { OrderedListElement } from '../OrderedListElement'\nimport type { UnorderedListElement } from '../UnorderedListElement'\n\nexport const indentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst previousListEntry = ContemberEditor.getPreviousSibling<Editor, ListItemElement>(\n\t\teditor,\n\t\tlistItem,\n\t\tlistItemPath,\n\t)\n\tif (previousListEntry === undefined) {\n\t\treturn false\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [parentListElement] = Editor.parent(editor, listItemPath) as NodeEntry<\n\t\t\tOrderedListElement | UnorderedListElement\n\t\t>\n\t\tlet [previousListItem, previousListItemPath] = previousListEntry\n\n\t\tconst lastPreviousListItemChild = previousListItem.children[previousListItem.children.length - 1]\n\t\tconst previousEndsWithCompatibleList =\n\t\t\tSlateElement.isElement(lastPreviousListItemChild) &&\n\t\t\tContemberEditor.isElementType(\n\t\t\t\tlastPreviousListItemChild,\n\t\t\t\tparentListElement.type,\n\t\t\t\tContemberEditor.elementToSpecifics(parentListElement) as any,\n\t\t\t)\n\n\t\tif (previousEndsWithCompatibleList) {\n\t\t\tconst newListItemPath = [\n\t\t\t\t...previousListItemPath,\n\t\t\t\tpreviousListItem.children.length - 1,\n\t\t\t\t(lastPreviousListItemChild as UnorderedListElement | OrderedListElement).children.length,\n\t\t\t]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t} else {\n\t\t\tconst previousContainsInlines = Editor.hasInlines(editor, previousListItem)\n\t\t\tif (previousContainsInlines) {\n\t\t\t\tconst [previousStart, previousEnd] = Editor.edges(editor, previousListItemPath)\n\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\tat: {\n\t\t\t\t\t\tanchor: previousStart,\n\t\t\t\t\t\tfocus: previousEnd,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Getting a new previousListItem because the children may have changed due to the branch above.\n\t\t\tpreviousListItem = SlateNode.get(editor, previousListItemPath) as ListItemElement\n\t\t\t// We're appending at the end: children.length is just lastOne + 1\n\t\t\tconst newListItemPath = [...previousListItemPath, previousListItem.children.length]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { ...parentListElement, children: [] }, { at: newListItemPath })\n\t\t}\n\t})\n\n\treturn true\n}\n"],"names":["ContemberEditor","Editor","SlateElement","Transforms","Text","SlateNode"],"mappings":";;;;AAcO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACb,QAAM,oBAAoBA,MAAAA,gBAAgB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAI,sBAAsB,QAAW;AAC7B,WAAA;AAAA,EAAA;AAGDC,eAAA,mBAAmB,QAAQ,MAAM;AACvC,UAAM,CAAC,iBAAiB,IAAIA,MAAAA,OAAO,OAAO,QAAQ,YAAY;AAG1D,QAAA,CAAC,kBAAkB,oBAAoB,IAAI;AAE/C,UAAM,4BAA4B,iBAAiB,SAAS,iBAAiB,SAAS,SAAS,CAAC;AAChG,UAAM,iCACLC,MAAAA,QAAa,UAAU,yBAAyB,KAChDF,MAAgB,gBAAA;AAAA,MACf;AAAA,MACA,kBAAkB;AAAA,MAClBA,MAAA,gBAAgB,mBAAmB,iBAAiB;AAAA,IACrD;AAED,QAAI,gCAAgC;AACnC,YAAM,kBAAkB;AAAA,QACvB,GAAG;AAAA,QACH,iBAAiB,SAAS,SAAS;AAAA,QAClC,0BAAwE,SAAS;AAAA,MACnF;AAEAG,YAAA,WAAW,UAAU,QAAQ;AAAA,QAC5B,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA,CACJ;AAAA,IAAA,OACK;AACN,YAAM,0BAA0BF,MAAA,OAAO,WAAW,QAAQ,gBAAgB;AAC1E,UAAI,yBAAyB;AAC5B,cAAM,CAAC,eAAe,WAAW,IAAIA,MAAO,OAAA,MAAM,QAAQ,oBAAoB;AAC9EE,cAAA,WAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,UAC7D,OAAO,CAAA,SAAQC,WAAK,OAAO,IAAI,KAAMF,cAAa,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI;AAAA,UACzF,IAAI;AAAA,YACH,QAAQ;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR,CACA;AAAA,MAAA;AAGiB,yBAAAG,MAAA,KAAU,IAAI,QAAQ,oBAAoB;AAE7D,YAAM,kBAAkB,CAAC,GAAG,sBAAsB,iBAAiB,SAAS,MAAM;AAElFF,YAAA,WAAW,UAAU,QAAQ;AAAA,QAC5B,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA,CACJ;AACDA,YAAAA,WAAW,UAAU,QAAQ,EAAE,GAAG,mBAAmB,UAAU,CAAA,KAAM,EAAE,IAAI,iBAAiB;AAAA,IAAA;AAAA,EAC7F,CACA;AAEM,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indentListItem.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/indentListItem.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tNodeEntry,\n\tPath as SlatePath,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport type { OrderedListElement } from '../OrderedListElement'\nimport type { UnorderedListElement } from '../UnorderedListElement'\n\nexport const indentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst previousListEntry = ContemberEditor.getPreviousSibling<Editor, ListItemElement>(\n\t\teditor,\n\t\tlistItem,\n\t\tlistItemPath,\n\t)\n\tif (previousListEntry === undefined) {\n\t\treturn false\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [parentListElement] = Editor.parent(editor, listItemPath) as NodeEntry<\n\t\t\tOrderedListElement | UnorderedListElement\n\t\t>\n\t\tlet [previousListItem, previousListItemPath] = previousListEntry\n\n\t\tconst lastPreviousListItemChild = previousListItem.children[previousListItem.children.length - 1]\n\t\tconst previousEndsWithCompatibleList =\n\t\t\tSlateElement.isElement(lastPreviousListItemChild) &&\n\t\t\tContemberEditor.isElementType(\n\t\t\t\tlastPreviousListItemChild,\n\t\t\t\tparentListElement.type,\n\t\t\t\tContemberEditor.elementToSpecifics(parentListElement) as any,\n\t\t\t)\n\n\t\tif (previousEndsWithCompatibleList) {\n\t\t\tconst newListItemPath = [\n\t\t\t\t...previousListItemPath,\n\t\t\t\tpreviousListItem.children.length - 1,\n\t\t\t\t(lastPreviousListItemChild as UnorderedListElement | OrderedListElement).children.length,\n\t\t\t]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t} else {\n\t\t\tconst previousContainsInlines = Editor.hasInlines(editor, previousListItem)\n\t\t\tif (previousContainsInlines) {\n\t\t\t\tconst [previousStart, previousEnd] = Editor.edges(editor, previousListItemPath)\n\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\tat: {\n\t\t\t\t\t\tanchor: previousStart,\n\t\t\t\t\t\tfocus: previousEnd,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Getting a new previousListItem because the children may have changed due to the branch above.\n\t\t\tpreviousListItem = SlateNode.get(editor, previousListItemPath) as ListItemElement\n\t\t\t// We're appending at the end: children.length is just lastOne + 1\n\t\t\tconst newListItemPath = [...previousListItemPath, previousListItem.children.length]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { ...parentListElement, children: [] }, { at: newListItemPath })\n\t\t}\n\t})\n\n\treturn true\n}\n"],"names":["SlateElement","SlateNode"],"mappings":";;AAcO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACb,QAAM,oBAAoB,gBAAgB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,
|
|
1
|
+
{"version":3,"file":"indentListItem.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/indentListItem.ts"],"sourcesContent":["import {\n\tEditor,\n\tElement as SlateElement,\n\tNode as SlateNode,\n\tNodeEntry,\n\tPath as SlatePath,\n\tText,\n\tTransforms,\n} from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport type { ListItemElement } from '../ListItemElement'\nimport type { OrderedListElement } from '../OrderedListElement'\nimport type { UnorderedListElement } from '../UnorderedListElement'\n\nexport const indentListItem = (\n\teditor: Editor,\n\tlistItem: ListItemElement,\n\tlistItemPath: SlatePath,\n): boolean => {\n\tconst previousListEntry = ContemberEditor.getPreviousSibling<Editor, ListItemElement>(\n\t\teditor,\n\t\tlistItem,\n\t\tlistItemPath,\n\t)\n\tif (previousListEntry === undefined) {\n\t\treturn false\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [parentListElement] = Editor.parent(editor, listItemPath) as NodeEntry<\n\t\t\tOrderedListElement | UnorderedListElement\n\t\t>\n\t\tlet [previousListItem, previousListItemPath] = previousListEntry\n\n\t\tconst lastPreviousListItemChild = previousListItem.children[previousListItem.children.length - 1]\n\t\tconst previousEndsWithCompatibleList =\n\t\t\tSlateElement.isElement(lastPreviousListItemChild) &&\n\t\t\tContemberEditor.isElementType(\n\t\t\t\tlastPreviousListItemChild,\n\t\t\t\tparentListElement.type,\n\t\t\t\tContemberEditor.elementToSpecifics(parentListElement) as any,\n\t\t\t)\n\n\t\tif (previousEndsWithCompatibleList) {\n\t\t\tconst newListItemPath = [\n\t\t\t\t...previousListItemPath,\n\t\t\t\tpreviousListItem.children.length - 1,\n\t\t\t\t(lastPreviousListItemChild as UnorderedListElement | OrderedListElement).children.length,\n\t\t\t]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t} else {\n\t\t\tconst previousContainsInlines = Editor.hasInlines(editor, previousListItem)\n\t\t\tif (previousContainsInlines) {\n\t\t\t\tconst [previousStart, previousEnd] = Editor.edges(editor, previousListItemPath)\n\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\tmatch: node => Text.isText(node) || (SlateElement.isElement(node) && editor.isInline(node)),\n\t\t\t\t\tat: {\n\t\t\t\t\t\tanchor: previousStart,\n\t\t\t\t\t\tfocus: previousEnd,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Getting a new previousListItem because the children may have changed due to the branch above.\n\t\t\tpreviousListItem = SlateNode.get(editor, previousListItemPath) as ListItemElement\n\t\t\t// We're appending at the end: children.length is just lastOne + 1\n\t\t\tconst newListItemPath = [...previousListItemPath, previousListItem.children.length]\n\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tat: listItemPath,\n\t\t\t\tto: newListItemPath,\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { ...parentListElement, children: [] }, { at: newListItemPath })\n\t\t}\n\t})\n\n\treturn true\n}\n"],"names":["SlateElement","SlateNode"],"mappings":";;AAcO,MAAM,iBAAiB,CAC7B,QACA,UACA,iBACa;AACb,QAAM,oBAAoB,gBAAgB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAI,sBAAsB,QAAW;AAC7B,WAAA;AAAA,EAAA;AAGD,SAAA,mBAAmB,QAAQ,MAAM;AACvC,UAAM,CAAC,iBAAiB,IAAI,OAAO,OAAO,QAAQ,YAAY;AAG1D,QAAA,CAAC,kBAAkB,oBAAoB,IAAI;AAE/C,UAAM,4BAA4B,iBAAiB,SAAS,iBAAiB,SAAS,SAAS,CAAC;AAChG,UAAM,iCACLA,QAAa,UAAU,yBAAyB,KAChD,gBAAgB;AAAA,MACf;AAAA,MACA,kBAAkB;AAAA,MAClB,gBAAgB,mBAAmB,iBAAiB;AAAA,IACrD;AAED,QAAI,gCAAgC;AACnC,YAAM,kBAAkB;AAAA,QACvB,GAAG;AAAA,QACH,iBAAiB,SAAS,SAAS;AAAA,QAClC,0BAAwE,SAAS;AAAA,MACnF;AAEA,iBAAW,UAAU,QAAQ;AAAA,QAC5B,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA,CACJ;AAAA,IAAA,OACK;AACN,YAAM,0BAA0B,OAAO,WAAW,QAAQ,gBAAgB;AAC1E,UAAI,yBAAyB;AAC5B,cAAM,CAAC,eAAe,WAAW,IAAI,OAAO,MAAM,QAAQ,oBAAoB;AAC9E,mBAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,UAC7D,OAAO,CAAA,SAAQ,KAAK,OAAO,IAAI,KAAMA,QAAa,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI;AAAA,UACzF,IAAI;AAAA,YACH,QAAQ;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR,CACA;AAAA,MAAA;AAGiB,yBAAAC,KAAU,IAAI,QAAQ,oBAAoB;AAE7D,YAAM,kBAAkB,CAAC,GAAG,sBAAsB,iBAAiB,SAAS,MAAM;AAElF,iBAAW,UAAU,QAAQ;AAAA,QAC5B,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA,CACJ;AACD,iBAAW,UAAU,QAAQ,EAAE,GAAG,mBAAmB,UAAU,CAAA,KAAM,EAAE,IAAI,iBAAiB;AAAA,IAAA;AAAA,EAC7F,CACA;AAEM,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeListElement.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/normalizeListElement.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { listItemElementType } from '../ListItemElement'\nimport { ContemberEditor } from '../../../../editor'\n\nexport const normalizeListElement = ({ editor, path, preventDefault }: { editor: Editor; path: SlatePath; preventDefault: () => void }) => {\n\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\tif (SlateElement.isElement(child)) {\n\t\t\tif (child.type !== listItemElementType) {\n\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\tTransforms.setNodes(editor, { type: listItemElementType }, { at: childPath })\n\t\t\t}\n\t\t} else {\n\t\t\t// If a list contains non-element nodes, just remove it.\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t}\n}\n"],"names":["SlateNode","SlateElement","listItemElementType","ContemberEditor","Transforms"],"mappings":";;;;;AAIO,MAAM,uBAAuB,CAAC,EAAE,QAAQ,MAAM,qBAAsF;AAC/H,aAAA,CAAC,OAAO,SAAS,KAAKA,WAAU,SAAS,QAAQ,IAAI,GAAG;AAC9D,QAAAC,MAAA,QAAa,UAAU,KAAK,GAAG;AAC9B,UAAA,MAAM,SAASC,qCAAqB;AACvBC,
|
|
1
|
+
{"version":3,"file":"normalizeListElement.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/normalizeListElement.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { listItemElementType } from '../ListItemElement'\nimport { ContemberEditor } from '../../../../editor'\n\nexport const normalizeListElement = ({ editor, path, preventDefault }: { editor: Editor; path: SlatePath; preventDefault: () => void }) => {\n\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\tif (SlateElement.isElement(child)) {\n\t\t\tif (child.type !== listItemElementType) {\n\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\tTransforms.setNodes(editor, { type: listItemElementType }, { at: childPath })\n\t\t\t}\n\t\t} else {\n\t\t\t// If a list contains non-element nodes, just remove it.\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t}\n}\n"],"names":["SlateNode","SlateElement","listItemElementType","ContemberEditor","Transforms"],"mappings":";;;;;AAIO,MAAM,uBAAuB,CAAC,EAAE,QAAQ,MAAM,qBAAsF;AAC/H,aAAA,CAAC,OAAO,SAAS,KAAKA,WAAU,SAAS,QAAQ,IAAI,GAAG;AAC9D,QAAAC,MAAA,QAAa,UAAU,KAAK,GAAG;AAC9B,UAAA,MAAM,SAASC,qCAAqB;AACvBC,8BAAA,aAAa,QAAQ,SAAS;AACnCC,yBAAA,SAAS,QAAQ,EAAE,MAAMF,gBAAAA,uBAAuB,EAAE,IAAI,WAAW;AAAA,MAAA;AAAA,IAC7E,OACM;AAENE,YAAA,WAAW,YAAY,QAAQ;AAAA,QAC9B,IAAI;AAAA,MAAA,CACJ;AACD,aAAO,eAAe;AAAA,IAAA;AAAA,EACvB;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeListElement.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/normalizeListElement.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { listItemElementType } from '../ListItemElement'\nimport { ContemberEditor } from '../../../../editor'\n\nexport const normalizeListElement = ({ editor, path, preventDefault }: { editor: Editor; path: SlatePath; preventDefault: () => void }) => {\n\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\tif (SlateElement.isElement(child)) {\n\t\t\tif (child.type !== listItemElementType) {\n\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\tTransforms.setNodes(editor, { type: listItemElementType }, { at: childPath })\n\t\t\t}\n\t\t} else {\n\t\t\t// If a list contains non-element nodes, just remove it.\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t}\n}\n"],"names":["SlateNode","SlateElement"],"mappings":";;;AAIO,MAAM,uBAAuB,CAAC,EAAE,QAAQ,MAAM,qBAAsF;AAC/H,aAAA,CAAC,OAAO,SAAS,KAAKA,KAAU,SAAS,QAAQ,IAAI,GAAG;AAC9D,QAAAC,QAAa,UAAU,KAAK,GAAG;AAC9B,UAAA,MAAM,SAAS,qBAAqB;AACvB,wBAAA,aAAa,QAAQ,SAAS;AACnC,mBAAA,SAAS,QAAQ,EAAE,MAAM,uBAAuB,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"normalizeListElement.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/normalizeListElement.ts"],"sourcesContent":["import { Editor, Element as SlateElement, Node as SlateNode, Path as SlatePath, Transforms } from 'slate'\nimport { listItemElementType } from '../ListItemElement'\nimport { ContemberEditor } from '../../../../editor'\n\nexport const normalizeListElement = ({ editor, path, preventDefault }: { editor: Editor; path: SlatePath; preventDefault: () => void }) => {\n\tfor (const [child, childPath] of SlateNode.children(editor, path)) {\n\t\tif (SlateElement.isElement(child)) {\n\t\t\tif (child.type !== listItemElementType) {\n\t\t\t\tContemberEditor.ejectElement(editor, childPath)\n\t\t\t\tTransforms.setNodes(editor, { type: listItemElementType }, { at: childPath })\n\t\t\t}\n\t\t} else {\n\t\t\t// If a list contains non-element nodes, just remove it.\n\t\t\tTransforms.removeNodes(editor, {\n\t\t\t\tat: path,\n\t\t\t})\n\t\t\treturn preventDefault()\n\t\t}\n\t}\n}\n"],"names":["SlateNode","SlateElement"],"mappings":";;;AAIO,MAAM,uBAAuB,CAAC,EAAE,QAAQ,MAAM,qBAAsF;AAC/H,aAAA,CAAC,OAAO,SAAS,KAAKA,KAAU,SAAS,QAAQ,IAAI,GAAG;AAC9D,QAAAC,QAAa,UAAU,KAAK,GAAG;AAC9B,UAAA,MAAM,SAAS,qBAAqB;AACvB,wBAAA,aAAa,QAAQ,SAAS;AACnC,mBAAA,SAAS,QAAQ,EAAE,MAAM,uBAAuB,EAAE,IAAI,WAAW;AAAA,MAAA;AAAA,IAC7E,OACM;AAEN,iBAAW,YAAY,QAAQ;AAAA,QAC9B,IAAI;AAAA,MAAA,CACJ;AACD,aAAO,eAAe;AAAA,IAAA;AAAA,EACvB;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleListElement.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/toggleListElement.ts"],"sourcesContent":["import { OrderedListElement, orderedListElementType } from '../OrderedListElement'\nimport { UnorderedListElement, unorderedListElementType } from '../UnorderedListElement'\nimport { Editor, Element as SlateElement, NodeEntry, Text, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport { listItemElementType } from '../ListItemElement'\nimport { isListElement } from '../ListElement'\n\nexport const toggleListElement = <T extends OrderedListElement | UnorderedListElement>(\n\teditor: Editor,\n\telementType: T['type'],\n\tsuchThat: Partial<T> | undefined,\n\totherKindOfList: typeof orderedListElementType | typeof unorderedListElementType,\n) => {\n\tif (editor.isElementActive(elementType, suchThat)) {\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && node.type === elementType,\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [closestList, closestListPath] = closestListEntry\n\n\t\t\t// It's important that we iterate backwards because otherwise we'd mangle the paths.\n\t\t\t// We unwrap elements which may have more than one child.\n\t\t\tfor (let i = closestList.children.length - 1; i >= 0; i--) {\n\t\t\t\tconst currentItemPath = [...closestListPath, i]\n\t\t\t\tif (Editor.hasInlines(editor, closestList.children[i] as SlateElement)) {\n\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\tat: currentItemPath,\n\t\t\t\t\t})\n\t\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\t\tat: [...currentItemPath, 0],\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tTransforms.unwrapNodes(editor, { at: currentItemPath })\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.unwrapNodes(editor, { at: closestListPath })\n\t\t})\n\t}\n\tif (editor.isElementActive(elementType) || editor.isElementActive(otherKindOfList)) {\n\t\t// We're in a list but a different one. Note the lack of 'suchThat'\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => isListElement(node),\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [, closestListPath] = closestListEntry\n\t\t\tContemberEditor.ejectElement(editor, closestListPath)\n\t\t\tTransforms.setNodes(editor, { ...suchThat, type: elementType }, { at: closestListPath })\n\t\t})\n\t}\n\n\tconst selection = editor.selection\n\n\tif (!selection) {\n\t\treturn\n\t}\n\n\tconst closestViableParentEntry = ContemberEditor.closestViableBlockContainerEntry(editor)\n\n\tif (!closestViableParentEntry) {\n\t\treturn\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [targetParent, targetParentPath] = closestViableParentEntry\n\n\t\tif (SlateElement.isElement(targetParent) && Editor.hasInlines(editor, targetParent)) {\n\t\t\t// We're deliberately widening the selection to include all the inlines.\n\t\t\tconst listItemPath = [...targetParentPath, 0]\n\n\t\t\t// Not using wrapNodes because it appears to exhibit rather unpredictable treatment of text nodes.\n\t\t\tTransforms.insertNodes(editor, { type: listItemElementType, children: [] }, { at: listItemPath })\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tto: [...listItemPath, 0],\n\t\t\t\tmatch: node => Text.isText(node) || SlateElement.isElement(node) && Editor.isInline(editor, node),\n\t\t\t\tat: {\n\t\t\t\t\tanchor: Editor.start(editor, [...targetParentPath, 1]),\n\t\t\t\t\tfocus: Editor.end(editor, [...targetParentPath, targetParent.children.length]),\n\t\t\t\t},\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { type: elementType, children: [] }, { at: listItemPath })\n\t\t} else {\n\t\t\tconst [selectionStart, selectionEnd] = Editor.edges(editor, selection)\n\t\t\tconst relativeStartIndex = selectionStart.path[targetParentPath.length]\n\t\t\tconst relativeEndIndex = selectionEnd.path[targetParentPath.length]\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.wrapNodes(editor, { type: listItemElementType, children: [] }, { at: [...targetParentPath, i] })\n\t\t\t}\n\n\t\t\tconst emptyList: UnorderedListElement | OrderedListElement = {\n\t\t\t\t...suchThat,\n\t\t\t\ttype: elementType as (UnorderedListElement | OrderedListElement)['type'],\n\t\t\t\tchildren: [],\n\t\t\t}\n\t\t\tconst listPath = [...targetParentPath, relativeStartIndex]\n\t\t\tTransforms.insertNodes(editor, emptyList, { at: listPath })\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\t\tto: [...listPath, i - relativeStartIndex],\n\t\t\t\t\t// The path doesn't depend on i because we keep moving the siblings away.\n\t\t\t\t\tat: [...targetParentPath, relativeStartIndex + 1],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n}\n"],"names":["ContemberEditor","SlateElement","Editor","Transforms","isListElement","listItemElementType","Text"],"mappings":";;;;;;AAOO,MAAM,oBAAoB,CAChC,QACA,aACA,UACA,oBACI;AACJ,MAAI,OAAO,gBAAgB,aAAa,QAAQ,GAAG;AAC5C,UAAA,mBAAmBA,MAAAA,gBAAgB,QAAQ,QAAQ;AAAA,MACxD,OAAO,CAAQ,SAAAC,
|
|
1
|
+
{"version":3,"file":"toggleListElement.cjs","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/toggleListElement.ts"],"sourcesContent":["import { OrderedListElement, orderedListElementType } from '../OrderedListElement'\nimport { UnorderedListElement, unorderedListElementType } from '../UnorderedListElement'\nimport { Editor, Element as SlateElement, NodeEntry, Text, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport { listItemElementType } from '../ListItemElement'\nimport { isListElement } from '../ListElement'\n\nexport const toggleListElement = <T extends OrderedListElement | UnorderedListElement>(\n\teditor: Editor,\n\telementType: T['type'],\n\tsuchThat: Partial<T> | undefined,\n\totherKindOfList: typeof orderedListElementType | typeof unorderedListElementType,\n) => {\n\tif (editor.isElementActive(elementType, suchThat)) {\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && node.type === elementType,\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [closestList, closestListPath] = closestListEntry\n\n\t\t\t// It's important that we iterate backwards because otherwise we'd mangle the paths.\n\t\t\t// We unwrap elements which may have more than one child.\n\t\t\tfor (let i = closestList.children.length - 1; i >= 0; i--) {\n\t\t\t\tconst currentItemPath = [...closestListPath, i]\n\t\t\t\tif (Editor.hasInlines(editor, closestList.children[i] as SlateElement)) {\n\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\tat: currentItemPath,\n\t\t\t\t\t})\n\t\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\t\tat: [...currentItemPath, 0],\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tTransforms.unwrapNodes(editor, { at: currentItemPath })\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.unwrapNodes(editor, { at: closestListPath })\n\t\t})\n\t}\n\tif (editor.isElementActive(elementType) || editor.isElementActive(otherKindOfList)) {\n\t\t// We're in a list but a different one. Note the lack of 'suchThat'\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => isListElement(node),\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [, closestListPath] = closestListEntry\n\t\t\tContemberEditor.ejectElement(editor, closestListPath)\n\t\t\tTransforms.setNodes(editor, { ...suchThat, type: elementType }, { at: closestListPath })\n\t\t})\n\t}\n\n\tconst selection = editor.selection\n\n\tif (!selection) {\n\t\treturn\n\t}\n\n\tconst closestViableParentEntry = ContemberEditor.closestViableBlockContainerEntry(editor)\n\n\tif (!closestViableParentEntry) {\n\t\treturn\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [targetParent, targetParentPath] = closestViableParentEntry\n\n\t\tif (SlateElement.isElement(targetParent) && Editor.hasInlines(editor, targetParent)) {\n\t\t\t// We're deliberately widening the selection to include all the inlines.\n\t\t\tconst listItemPath = [...targetParentPath, 0]\n\n\t\t\t// Not using wrapNodes because it appears to exhibit rather unpredictable treatment of text nodes.\n\t\t\tTransforms.insertNodes(editor, { type: listItemElementType, children: [] }, { at: listItemPath })\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tto: [...listItemPath, 0],\n\t\t\t\tmatch: node => Text.isText(node) || SlateElement.isElement(node) && Editor.isInline(editor, node),\n\t\t\t\tat: {\n\t\t\t\t\tanchor: Editor.start(editor, [...targetParentPath, 1]),\n\t\t\t\t\tfocus: Editor.end(editor, [...targetParentPath, targetParent.children.length]),\n\t\t\t\t},\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { type: elementType, children: [] }, { at: listItemPath })\n\t\t} else {\n\t\t\tconst [selectionStart, selectionEnd] = Editor.edges(editor, selection)\n\t\t\tconst relativeStartIndex = selectionStart.path[targetParentPath.length]\n\t\t\tconst relativeEndIndex = selectionEnd.path[targetParentPath.length]\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.wrapNodes(editor, { type: listItemElementType, children: [] }, { at: [...targetParentPath, i] })\n\t\t\t}\n\n\t\t\tconst emptyList: UnorderedListElement | OrderedListElement = {\n\t\t\t\t...suchThat,\n\t\t\t\ttype: elementType as (UnorderedListElement | OrderedListElement)['type'],\n\t\t\t\tchildren: [],\n\t\t\t}\n\t\t\tconst listPath = [...targetParentPath, relativeStartIndex]\n\t\t\tTransforms.insertNodes(editor, emptyList, { at: listPath })\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\t\tto: [...listPath, i - relativeStartIndex],\n\t\t\t\t\t// The path doesn't depend on i because we keep moving the siblings away.\n\t\t\t\t\tat: [...targetParentPath, relativeStartIndex + 1],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n}\n"],"names":["ContemberEditor","SlateElement","Editor","Transforms","isListElement","listItemElementType","Text"],"mappings":";;;;;;AAOO,MAAM,oBAAoB,CAChC,QACA,aACA,UACA,oBACI;AACJ,MAAI,OAAO,gBAAgB,aAAa,QAAQ,GAAG;AAC5C,UAAA,mBAAmBA,MAAAA,gBAAgB,QAAQ,QAAQ;AAAA,MACxD,OAAO,CAAQ,SAAAC,MAAA,QAAa,UAAU,IAAI,KAAK,KAAK,SAAS;AAAA,IAAA,CAC7D;AACD,QAAI,CAAC,kBAAkB;AACtB;AAAA,IAAA;AAEM,WAAAC,MAAA,OAAO,mBAAmB,QAAQ,MAAM;AACxC,YAAA,CAAC,aAAa,eAAe,IAAI;AAIvC,eAAS,IAAI,YAAY,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;AAC1D,cAAM,kBAAkB,CAAC,GAAG,iBAAiB,CAAC;AAC9C,YAAIA,MAAAA,OAAO,WAAW,QAAQ,YAAY,SAAS,CAAC,CAAiB,GAAG;AACvEC,gBAAA,WAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,YAC7D,IAAI;AAAA,UAAA,CACJ;AACDA,gBAAA,WAAW,YAAY,QAAQ;AAAA,YAC9B,IA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ACF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleListElement.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/toggleListElement.ts"],"sourcesContent":["import { OrderedListElement, orderedListElementType } from '../OrderedListElement'\nimport { UnorderedListElement, unorderedListElementType } from '../UnorderedListElement'\nimport { Editor, Element as SlateElement, NodeEntry, Text, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport { listItemElementType } from '../ListItemElement'\nimport { isListElement } from '../ListElement'\n\nexport const toggleListElement = <T extends OrderedListElement | UnorderedListElement>(\n\teditor: Editor,\n\telementType: T['type'],\n\tsuchThat: Partial<T> | undefined,\n\totherKindOfList: typeof orderedListElementType | typeof unorderedListElementType,\n) => {\n\tif (editor.isElementActive(elementType, suchThat)) {\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && node.type === elementType,\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [closestList, closestListPath] = closestListEntry\n\n\t\t\t// It's important that we iterate backwards because otherwise we'd mangle the paths.\n\t\t\t// We unwrap elements which may have more than one child.\n\t\t\tfor (let i = closestList.children.length - 1; i >= 0; i--) {\n\t\t\t\tconst currentItemPath = [...closestListPath, i]\n\t\t\t\tif (Editor.hasInlines(editor, closestList.children[i] as SlateElement)) {\n\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\tat: currentItemPath,\n\t\t\t\t\t})\n\t\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\t\tat: [...currentItemPath, 0],\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tTransforms.unwrapNodes(editor, { at: currentItemPath })\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.unwrapNodes(editor, { at: closestListPath })\n\t\t})\n\t}\n\tif (editor.isElementActive(elementType) || editor.isElementActive(otherKindOfList)) {\n\t\t// We're in a list but a different one. Note the lack of 'suchThat'\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => isListElement(node),\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [, closestListPath] = closestListEntry\n\t\t\tContemberEditor.ejectElement(editor, closestListPath)\n\t\t\tTransforms.setNodes(editor, { ...suchThat, type: elementType }, { at: closestListPath })\n\t\t})\n\t}\n\n\tconst selection = editor.selection\n\n\tif (!selection) {\n\t\treturn\n\t}\n\n\tconst closestViableParentEntry = ContemberEditor.closestViableBlockContainerEntry(editor)\n\n\tif (!closestViableParentEntry) {\n\t\treturn\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [targetParent, targetParentPath] = closestViableParentEntry\n\n\t\tif (SlateElement.isElement(targetParent) && Editor.hasInlines(editor, targetParent)) {\n\t\t\t// We're deliberately widening the selection to include all the inlines.\n\t\t\tconst listItemPath = [...targetParentPath, 0]\n\n\t\t\t// Not using wrapNodes because it appears to exhibit rather unpredictable treatment of text nodes.\n\t\t\tTransforms.insertNodes(editor, { type: listItemElementType, children: [] }, { at: listItemPath })\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tto: [...listItemPath, 0],\n\t\t\t\tmatch: node => Text.isText(node) || SlateElement.isElement(node) && Editor.isInline(editor, node),\n\t\t\t\tat: {\n\t\t\t\t\tanchor: Editor.start(editor, [...targetParentPath, 1]),\n\t\t\t\t\tfocus: Editor.end(editor, [...targetParentPath, targetParent.children.length]),\n\t\t\t\t},\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { type: elementType, children: [] }, { at: listItemPath })\n\t\t} else {\n\t\t\tconst [selectionStart, selectionEnd] = Editor.edges(editor, selection)\n\t\t\tconst relativeStartIndex = selectionStart.path[targetParentPath.length]\n\t\t\tconst relativeEndIndex = selectionEnd.path[targetParentPath.length]\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.wrapNodes(editor, { type: listItemElementType, children: [] }, { at: [...targetParentPath, i] })\n\t\t\t}\n\n\t\t\tconst emptyList: UnorderedListElement | OrderedListElement = {\n\t\t\t\t...suchThat,\n\t\t\t\ttype: elementType as (UnorderedListElement | OrderedListElement)['type'],\n\t\t\t\tchildren: [],\n\t\t\t}\n\t\t\tconst listPath = [...targetParentPath, relativeStartIndex]\n\t\t\tTransforms.insertNodes(editor, emptyList, { at: listPath })\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\t\tto: [...listPath, i - relativeStartIndex],\n\t\t\t\t\t// The path doesn't depend on i because we keep moving the siblings away.\n\t\t\t\t\tat: [...targetParentPath, relativeStartIndex + 1],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n}\n"],"names":["SlateElement"],"mappings":";;;;AAOO,MAAM,oBAAoB,CAChC,QACA,aACA,UACA,oBACI;AACJ,MAAI,OAAO,gBAAgB,aAAa,QAAQ,GAAG;AAC5C,UAAA,mBAAmB,gBAAgB,QAAQ,QAAQ;AAAA,MACxD,OAAO,CAAQ,SAAAA,QAAa,UAAU,IAAI,KAAK,KAAK,SAAS;AAAA,IAAA,CAC7D;AACD,QAAI,CAAC,kBAAkB;AACtB;AAAA,
|
|
1
|
+
{"version":3,"file":"toggleListElement.js","sources":["../../../../../../../../packages/react-slate-editor-base/src/plugins/element/lists/transforms/toggleListElement.ts"],"sourcesContent":["import { OrderedListElement, orderedListElementType } from '../OrderedListElement'\nimport { UnorderedListElement, unorderedListElementType } from '../UnorderedListElement'\nimport { Editor, Element as SlateElement, NodeEntry, Text, Transforms } from 'slate'\nimport { ContemberEditor } from '../../../../editor'\nimport { listItemElementType } from '../ListItemElement'\nimport { isListElement } from '../ListElement'\n\nexport const toggleListElement = <T extends OrderedListElement | UnorderedListElement>(\n\teditor: Editor,\n\telementType: T['type'],\n\tsuchThat: Partial<T> | undefined,\n\totherKindOfList: typeof orderedListElementType | typeof unorderedListElementType,\n) => {\n\tif (editor.isElementActive(elementType, suchThat)) {\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => SlateElement.isElement(node) && node.type === elementType,\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [closestList, closestListPath] = closestListEntry\n\n\t\t\t// It's important that we iterate backwards because otherwise we'd mangle the paths.\n\t\t\t// We unwrap elements which may have more than one child.\n\t\t\tfor (let i = closestList.children.length - 1; i >= 0; i--) {\n\t\t\t\tconst currentItemPath = [...closestListPath, i]\n\t\t\t\tif (Editor.hasInlines(editor, closestList.children[i] as SlateElement)) {\n\t\t\t\t\tTransforms.wrapNodes(editor, editor.createDefaultElement([]), {\n\t\t\t\t\t\tat: currentItemPath,\n\t\t\t\t\t})\n\t\t\t\t\tTransforms.unwrapNodes(editor, {\n\t\t\t\t\t\tat: [...currentItemPath, 0],\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tTransforms.unwrapNodes(editor, { at: currentItemPath })\n\t\t\t\t}\n\t\t\t}\n\t\t\tTransforms.unwrapNodes(editor, { at: closestListPath })\n\t\t})\n\t}\n\tif (editor.isElementActive(elementType) || editor.isElementActive(otherKindOfList)) {\n\t\t// We're in a list but a different one. Note the lack of 'suchThat'\n\t\tconst closestListEntry = ContemberEditor.closest(editor, {\n\t\t\tmatch: node => isListElement(node),\n\t\t}) as NodeEntry<UnorderedListElement | OrderedListElement>\n\t\tif (!closestListEntry) {\n\t\t\treturn\n\t\t}\n\t\treturn Editor.withoutNormalizing(editor, () => {\n\t\t\tconst [, closestListPath] = closestListEntry\n\t\t\tContemberEditor.ejectElement(editor, closestListPath)\n\t\t\tTransforms.setNodes(editor, { ...suchThat, type: elementType }, { at: closestListPath })\n\t\t})\n\t}\n\n\tconst selection = editor.selection\n\n\tif (!selection) {\n\t\treturn\n\t}\n\n\tconst closestViableParentEntry = ContemberEditor.closestViableBlockContainerEntry(editor)\n\n\tif (!closestViableParentEntry) {\n\t\treturn\n\t}\n\n\tEditor.withoutNormalizing(editor, () => {\n\t\tconst [targetParent, targetParentPath] = closestViableParentEntry\n\n\t\tif (SlateElement.isElement(targetParent) && Editor.hasInlines(editor, targetParent)) {\n\t\t\t// We're deliberately widening the selection to include all the inlines.\n\t\t\tconst listItemPath = [...targetParentPath, 0]\n\n\t\t\t// Not using wrapNodes because it appears to exhibit rather unpredictable treatment of text nodes.\n\t\t\tTransforms.insertNodes(editor, { type: listItemElementType, children: [] }, { at: listItemPath })\n\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\tto: [...listItemPath, 0],\n\t\t\t\tmatch: node => Text.isText(node) || SlateElement.isElement(node) && Editor.isInline(editor, node),\n\t\t\t\tat: {\n\t\t\t\t\tanchor: Editor.start(editor, [...targetParentPath, 1]),\n\t\t\t\t\tfocus: Editor.end(editor, [...targetParentPath, targetParent.children.length]),\n\t\t\t\t},\n\t\t\t})\n\t\t\tTransforms.wrapNodes(editor, { type: elementType, children: [] }, { at: listItemPath })\n\t\t} else {\n\t\t\tconst [selectionStart, selectionEnd] = Editor.edges(editor, selection)\n\t\t\tconst relativeStartIndex = selectionStart.path[targetParentPath.length]\n\t\t\tconst relativeEndIndex = selectionEnd.path[targetParentPath.length]\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.wrapNodes(editor, { type: listItemElementType, children: [] }, { at: [...targetParentPath, i] })\n\t\t\t}\n\n\t\t\tconst emptyList: UnorderedListElement | OrderedListElement = {\n\t\t\t\t...suchThat,\n\t\t\t\ttype: elementType as (UnorderedListElement | OrderedListElement)['type'],\n\t\t\t\tchildren: [],\n\t\t\t}\n\t\t\tconst listPath = [...targetParentPath, relativeStartIndex]\n\t\t\tTransforms.insertNodes(editor, emptyList, { at: listPath })\n\n\t\t\tfor (let i = relativeStartIndex; i <= relativeEndIndex; i++) {\n\t\t\t\tTransforms.moveNodes(editor, {\n\t\t\t\t\tto: [...listPath, i - relativeStartIndex],\n\t\t\t\t\t// The path doesn't depend on i because we keep moving the siblings away.\n\t\t\t\t\tat: [...targetParentPath, relativeStartIndex + 1],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n}\n"],"names":["SlateElement"],"mappings":";;;;AAOO,MAAM,oBAAoB,CAChC,QACA,aACA,UACA,oBACI;AACJ,MAAI,OAAO,gBAAgB,aAAa,QAAQ,GAAG;AAC5C,UAAA,mBAAmB,gBAAgB,QAAQ,QAAQ;AAAA,MACxD,OAAO,CAAQ,SAAAA,QAAa,UAAU,IAAI,KAAK,KAAK,SAAS;AAAA,IAAA,CAC7D;AACD,QAAI,CAAC,kBAAkB;AACtB;AAAA,IAAA;AAEM,WAAA,OAAO,mBAAmB,QAAQ,MAAM;AACxC,YAAA,CAAC,aAAa,eAAe,IAAI;AAIvC,eAAS,IAAI,YAAY,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;AAC1D,cAAM,kBAAkB,CAAC,GAAG,iBAAiB,CAAC;AAC9C,YAAI,OAAO,WAAW,QAAQ,YAAY,SAAS,CAAC,CAAiB,GAAG;AACvE,qBAAW,UAAU,QAAQ,OAAO,qBAAqB,CAAE,CAAA,GAAG;AAAA,YAC7D,IAAI;AAAA,UAAA,CACJ;AACD,qBAAW,YAAY,QAAQ;AAAA,YAC9B,IAAI,CAAC,GAAG,iBAAiB,CAAC;AAAA,UAAA,CAC1B;AAAA,QAAA,OACK;AACN,qBAAW,YAAY,QAAQ,EAAE,IAAI,iBAAiB;AAAA,QAAA;AAAA,MACvD;AAED,iBAAW,YAAY,QAAQ,EAAE,IAAI,iBAAiB;AAAA,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AAA,QAAA;AAAA,MAC9E,CACA;AACD,iBAAW,UAAU,QAAQ,EAAE,MAAM,aAAa,UAAU,GAAM,GAAA,EAAE,IAAI,aAAA,CAAc;AAAA,IAAA,OAChF;AACN,YAAM,CAAC,gBAAgB,YAAY,IAAI,OAAO,MAAM,QAAQ,SAAS;AACrE,YAAM,qBAAqB,eAAe,KAAK,iBAAiB,MAAM;AACtE,YAAM,mBAAmB,aAAa,KAAK,iBAAiB,MAAM;AAElE,eAAS,IAAI,oBAAoB,KAAK,kBAAkB,KAAK;AAC5D,mBAAW,UAAU,QAAQ,EAAE,MAAM,qBAAqB,UAAU,GAAM,GAAA,EAAE,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG;AAAA,MAAA;AAG3G,YAAM,YAAuD;AAAA,QAC5D,GAAG;AAAA,QACH,MAAM;AAAA,QACN,UAAU,CAAA;AAAA,MACX;AACA,YAAM,WAAW,CAAC,GAAG,kBAAkB,kBAAkB;AACzD,iBAAW,YAAY,QAAQ,WAAW,EAAE,IAAI,UAAU;AAE1D,eAAS,IAAI,oBAAoB,KAAK,kBAAkB,KAAK;AAC5D,mBAAW,UAAU,QAAQ;AAAA,UAC5B,IAAI,CAAC,GAAG,UAAU,IAAI,kBAAkB;AAAA;AAAA,UAExC,IAAI,CAAC,GAAG,kBAAkB,qBAAqB,CAAC;AAAA,QAAA,CAChD;AAAA,MAAA;AAAA,IACF;AAAA,EACD,CACA;AACF;"}
|
|
@@ -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,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,4BAA6B,CAAA;AAEpE,SAAO,OAAgC,QAAQ;AAAA,IAC9C,aAAa,MAAM;AACZ,YAAA,EAAE,UAAc,IAAA;AAEtB,UAAI,CAAC,aAAa,CAACC,MAAW,MAAA,YAAY,SAAS,GAAG;AACrD,eAAO,YAAY;AAAA,MACpB;AACM,YAAA,oBAAoBC,MAAAA,gBAAgB,kBAAkB,MAAM;AAClE,UAAI,sBAAsB,QAAW;AACpC,eAAO,YAAY;AAAA,MACpB;AACM,YAAA,CAAC,cAAc,gBAAgB,IAAI;AAErC,UAAA;AACA,UAAA;AAEA,UAAA,CAACC,gBAAAA,kBAAkB,YAAY,GAAG;AACjC,YAAA,iBAAiB,SAAS,GAAG;AAEhC,iBAAO,YAAY;AAAA,QACpB;AAEyB,iCAAAC,MAAA,KAAU,OAAO,gBAAgB;AAC1D,cAAM,kBAAkBC,MAAA,KAAU,IAAI,QAA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A,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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;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,cAAA;AAAA,YACR,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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gBAAM,eAAe;AACd,iBAAA,WAAW,WAAW,QAAQ;AAAA,YACpC,QAAQ;AAAA,YACR,IAAI,UAAU;AAAA,YACd,OAAO,CAAA,SAAQA,QAAa,UAAU,IAAI,KAAK,OAAO,QAAQ,QAAQ,IAAI,KAAK,OAAO,iBAAiB,IAAI;AAAA,UAAA,CAC3G;AAAA,QAAA,WACS,kBAAkB,mBAAmB,GAAG;AAIlD,gBAAM,CAAC,eAAe,WAAW,IAAI,OAAO,MAAM,QAAQ,gBAAgB;AAC1E,gBAAM,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,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,gBAAgB,yBAAyB,EAAE,QAAQ,kBAAmB,CAAA,CAAC;AAC9E,SAAO,gBAAgB,2BAA2B,EAAE,QAAQ,oBAAqB,CAAA,CAAC;AAE3E,SAAA,iBAAiB,eAAe,6BAA6B;AAEpE,SAAO,OAAgC,QAAQ;AAAA,IAC9C,aAAa,MAAM;AACZ,YAAA,EAAE,cAAc;AAEtB,UAAI,CAAC,aAAa,CAACA,MAAW,YAAY,SAAS,GAAG;AACrD,eAAO,YAAY;AAAA,MAAA;AAEd,YAAA,oBAAoB,gBAAgB,kBAAkB,MAAM;AAClE,UAAI,sBAAsB,QAAW;AACpC,eAAO,YAAY;AAAA,MAAA;AAEd,YAAA,CAAC,cAAc,gBAAgB,IAAI;AAErC,UAAA;AACA,UAAA;AAEA,UAAA,CAAC,kBAAkB,YAAY,GAAG;AACjC,YAAA,iBAAiB,SAAS,GAAG;AAEhC,iBAAO,YAAY;AAAA,QAAA;AAGK,iCAAAC,KAAU,OAAO,gBAAgB;AAC1D,cAAM,kBAAkBC,KAAU,IAAI,QAAQ,sBAAsB;AAEhE,YAAA,CAAC,kBAAkB,eAAe,GAAG;AAExC,iBAAO,YAAY;AAAA,QAAA;AAEC,6BAAA;AAAA,MAAA,OACf;AACe,6BAAA;AACI,iC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Content":["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,IA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