@squiz/formatted-text-editor 0.0.0-rbv2-20240530041851
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/.eslintrc.json +41 -0
- package/CHANGELOG.md +155 -0
- package/README.md +74 -0
- package/build.js +21 -0
- package/coverage/clover.xml +1544 -0
- package/coverage/coverage-final.json +74 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +911 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor/Editor.tsx.html +436 -0
- package/coverage/lcov-report/src/Editor/EditorContext.ts.html +145 -0
- package/coverage/lcov-report/src/Editor/index.html +131 -0
- package/coverage/lcov-report/src/EditorToolbar/FloatingToolbar.tsx.html +271 -0
- package/coverage/lcov-report/src/EditorToolbar/Toolbar.tsx.html +265 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Bold/BoldButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Bold/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.tsx.html +229 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/ClearFormatting/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.tsx.html +187 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/HorizontalLine/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Image/Form/ImageForm.tsx.html +688 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Image/Form/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Image/ImageButton.tsx.html +301 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Image/ImageModal.tsx.html +181 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Image/index.html +131 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Italic/ItalicButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Italic/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/Form/LinkForm.tsx.html +508 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/Form/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/LinkButton.tsx.html +286 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/LinkModal.tsx.html +196 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/RemoveLinkButton.tsx.html +211 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Link/index.html +146 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/ListButtons.tsx.html +127 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.tsx.html +175 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/OrderedList/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.tsx.html +175 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/UnorderedList/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Lists/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Redo/RedoButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Redo/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Table/TableButton.tsx.html +181 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Table/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/CenterAlign/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/JustifyAlign/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/LeftAlign/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/RightAlign/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/TextAlignButtons.tsx.html +148 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextAlign/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.tsx.html +181 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/CodeBlock/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.tsx.html +241 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Heading/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.tsx.html +160 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Paragraph/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.tsx.html +181 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/Preformatted/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/TextTypeDropdown.tsx.html +247 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/TextType/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Underline/UnderlineButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Underline/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Undo/UndoButton.tsx.html +178 -0
- package/coverage/lcov-report/src/EditorToolbar/Tools/Undo/index.html +116 -0
- package/coverage/lcov-report/src/EditorToolbar/index.html +146 -0
- package/coverage/lcov-report/src/EditorToolbar/index.ts.html +91 -0
- package/coverage/lcov-report/src/Extensions/ClearFormattingExtension/ClearFormattingExtension.ts.html +256 -0
- package/coverage/lcov-report/src/Extensions/ClearFormattingExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/CodeBlockExtension/CodeBlockExtension.ts.html +187 -0
- package/coverage/lcov-report/src/Extensions/CodeBlockExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/CommandsExtension/CommandsExtension.ts.html +247 -0
- package/coverage/lcov-report/src/Extensions/CommandsExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/Extensions.ts.html +349 -0
- package/coverage/lcov-report/src/Extensions/FetchUrlExtension/FetchUrlExtension.ts.html +289 -0
- package/coverage/lcov-report/src/Extensions/FetchUrlExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/ImageExtension/AssetImageExtension.ts.html +412 -0
- package/coverage/lcov-report/src/Extensions/ImageExtension/ImageExtension.ts.html +142 -0
- package/coverage/lcov-report/src/Extensions/ImageExtension/index.html +131 -0
- package/coverage/lcov-report/src/Extensions/LinkExtension/AssetLinkExtension.ts.html +466 -0
- package/coverage/lcov-report/src/Extensions/LinkExtension/LinkExtension.ts.html +400 -0
- package/coverage/lcov-report/src/Extensions/LinkExtension/common.ts.html +115 -0
- package/coverage/lcov-report/src/Extensions/LinkExtension/index.html +146 -0
- package/coverage/lcov-report/src/Extensions/PreformattedExtension/PreformattedExtension.ts.html +340 -0
- package/coverage/lcov-report/src/Extensions/PreformattedExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/UnsuportedExtension/UnsupportedNodeExtension.tsx.html +325 -0
- package/coverage/lcov-report/src/Extensions/UnsuportedExtension/index.html +116 -0
- package/coverage/lcov-report/src/Extensions/index.html +116 -0
- package/coverage/lcov-report/src/hooks/index.html +161 -0
- package/coverage/lcov-report/src/hooks/index.ts.html +91 -0
- package/coverage/lcov-report/src/hooks/useExpandedSelection.ts.html +217 -0
- package/coverage/lcov-report/src/hooks/useExtensionNames.ts.html +130 -0
- package/coverage/lcov-report/src/hooks/useFocus.ts.html +268 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +112 -0
- package/coverage/lcov-report/src/ui/Button/Button.tsx.html +190 -0
- package/coverage/lcov-report/src/ui/Button/index.html +116 -0
- package/coverage/lcov-report/src/ui/CollapseBox/CollapseBox.tsx.html +193 -0
- package/coverage/lcov-report/src/ui/CollapseBox/index.html +116 -0
- package/coverage/lcov-report/src/ui/Fields/Checkbox/Checkbox.tsx.html +232 -0
- package/coverage/lcov-report/src/ui/Fields/Checkbox/index.html +116 -0
- package/coverage/lcov-report/src/ui/Fields/Input/Input.tsx.html +160 -0
- package/coverage/lcov-report/src/ui/Fields/Input/index.html +116 -0
- package/coverage/lcov-report/src/ui/Fields/InputContainer/InputContainer.tsx.html +172 -0
- package/coverage/lcov-report/src/ui/Fields/InputContainer/index.html +116 -0
- package/coverage/lcov-report/src/ui/Fields/MatrixAsset/MatrixAsset.tsx.html +256 -0
- package/coverage/lcov-report/src/ui/Fields/MatrixAsset/index.html +116 -0
- package/coverage/lcov-report/src/ui/Fields/Select/Select.tsx.html +283 -0
- package/coverage/lcov-report/src/ui/Fields/Select/index.html +116 -0
- package/coverage/lcov-report/src/ui/Modal/FormModal.tsx.html +136 -0
- package/coverage/lcov-report/src/ui/Modal/Modal.tsx.html +397 -0
- package/coverage/lcov-report/src/ui/Modal/index.html +131 -0
- package/coverage/lcov-report/src/ui/Tabs/Tabs.tsx.html +208 -0
- package/coverage/lcov-report/src/ui/Tabs/index.html +116 -0
- package/coverage/lcov-report/src/ui/ToolbarDropdown/ToolbarDropdown.tsx.html +211 -0
- package/coverage/lcov-report/src/ui/ToolbarDropdown/index.html +116 -0
- package/coverage/lcov-report/src/ui/ToolbarDropdownButton/ToolbarDropdownButton.tsx.html +184 -0
- package/coverage/lcov-report/src/ui/ToolbarDropdownButton/index.html +116 -0
- package/coverage/lcov-report/src/utils/converters/htmlToSquizNode/htmlToSquizNode.ts.html +166 -0
- package/coverage/lcov-report/src/utils/converters/htmlToSquizNode/index.html +116 -0
- package/coverage/lcov-report/src/utils/converters/mocks/index.html +116 -0
- package/coverage/lcov-report/src/utils/converters/mocks/squizNodeJson.mock.ts.html +895 -0
- package/coverage/lcov-report/src/utils/converters/remirrorNodeToSquizNode/index.html +116 -0
- package/coverage/lcov-report/src/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.ts.html +976 -0
- package/coverage/lcov-report/src/utils/converters/squizNodeToRemirrorNode/index.html +116 -0
- package/coverage/lcov-report/src/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.ts.html +748 -0
- package/coverage/lcov-report/src/utils/createToolbarPositioner.ts.html +469 -0
- package/coverage/lcov-report/src/utils/getCursorRect.ts.html +100 -0
- package/coverage/lcov-report/src/utils/getMarkNamesByGroup.ts.html +106 -0
- package/coverage/lcov-report/src/utils/getNodeNamesByGroup.ts.html +106 -0
- package/coverage/lcov-report/src/utils/getShortcutSymbol.ts.html +97 -0
- package/coverage/lcov-report/src/utils/index.html +206 -0
- package/coverage/lcov-report/src/utils/undefinedIfEmpty.ts.html +94 -0
- package/coverage/lcov-report/src/utils/validation.ts.html +133 -0
- package/coverage/lcov.info +2737 -0
- package/cypress/e2e/bold.spec.cy.ts +18 -0
- package/cypress/global.d.ts +9 -0
- package/cypress/support/commands.ts +130 -0
- package/cypress/support/e2e.ts +20 -0
- package/cypress/tsconfig.json +8 -0
- package/cypress.config.ts +7 -0
- package/demo/App.tsx +107 -0
- package/demo/AppContext.tsx +70 -0
- package/demo/index.html +13 -0
- package/demo/index.scss +33 -0
- package/demo/main.tsx +12 -0
- package/demo/public/favicon-dxp.svg +3 -0
- package/demo/resources.json +204 -0
- package/demo/sources.json +27 -0
- package/demo/vite-env.d.ts +1 -0
- package/file-transformer.js +1 -0
- package/jest.bootstrap.ts +3 -0
- package/jest.config.ts +27 -0
- package/lib/Editor/Editor.d.ts +16 -0
- package/lib/Editor/Editor.js +85 -0
- package/lib/Editor/EditorContext.d.ts +10 -0
- package/lib/Editor/EditorContext.js +16 -0
- package/lib/EditorToolbar/FloatingToolbar.d.ts +2 -0
- package/lib/EditorToolbar/FloatingToolbar.js +76 -0
- package/lib/EditorToolbar/Toolbar.d.ts +7 -0
- package/lib/EditorToolbar/Toolbar.js +47 -0
- package/lib/EditorToolbar/Tools/Bold/BoldButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Bold/BoldButton.js +23 -0
- package/lib/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.js +57 -0
- package/lib/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.js +25 -0
- package/lib/EditorToolbar/Tools/Image/Form/ImageForm.d.ts +18 -0
- package/lib/EditorToolbar/Tools/Image/Form/ImageForm.js +143 -0
- package/lib/EditorToolbar/Tools/Image/ImageButton.d.ts +6 -0
- package/lib/EditorToolbar/Tools/Image/ImageButton.js +76 -0
- package/lib/EditorToolbar/Tools/Image/ImageModal.d.ts +9 -0
- package/lib/EditorToolbar/Tools/Image/ImageModal.js +24 -0
- package/lib/EditorToolbar/Tools/Italic/ItalicButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Italic/ItalicButton.js +23 -0
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.d.ts +19 -0
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.js +63 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.d.ts +6 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.js +71 -0
- package/lib/EditorToolbar/Tools/Link/LinkModal.d.ts +9 -0
- package/lib/EditorToolbar/Tools/Link/LinkModal.js +27 -0
- package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.d.ts +4 -0
- package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.js +54 -0
- package/lib/EditorToolbar/Tools/Lists/ListButtons.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Lists/ListButtons.js +14 -0
- package/lib/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.js +22 -0
- package/lib/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.js +22 -0
- package/lib/EditorToolbar/Tools/Redo/RedoButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Redo/RedoButton.js +22 -0
- package/lib/EditorToolbar/Tools/Table/TableButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Table/TableButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextAlign/TextAlignButtons.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextAlign/TextAlignButtons.js +21 -0
- package/lib/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.d.ts +6 -0
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.js +37 -0
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.js +21 -0
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.js +22 -0
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.d.ts +3 -0
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.js +46 -0
- package/lib/EditorToolbar/Tools/Underline/UnderlineButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Underline/UnderlineButton.js +23 -0
- package/lib/EditorToolbar/Tools/Undo/UndoButton.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Undo/UndoButton.js +22 -0
- package/lib/EditorToolbar/index.d.ts +2 -0
- package/lib/EditorToolbar/index.js +18 -0
- package/lib/Extensions/ClearFormattingExtension/ClearFormattingExtension.d.ts +5 -0
- package/lib/Extensions/ClearFormattingExtension/ClearFormattingExtension.js +63 -0
- package/lib/Extensions/CodeBlockExtension/CodeBlockExtension.d.ts +5 -0
- package/lib/Extensions/CodeBlockExtension/CodeBlockExtension.js +30 -0
- package/lib/Extensions/CommandsExtension/CommandsExtension.d.ts +20 -0
- package/lib/Extensions/CommandsExtension/CommandsExtension.js +52 -0
- package/lib/Extensions/Extensions.d.ts +17 -0
- package/lib/Extensions/Extensions.js +73 -0
- package/lib/Extensions/FetchUrlExtension/FetchUrlExtension.d.ts +12 -0
- package/lib/Extensions/FetchUrlExtension/FetchUrlExtension.js +63 -0
- package/lib/Extensions/ImageExtension/AssetImageExtension.d.ts +17 -0
- package/lib/Extensions/ImageExtension/AssetImageExtension.js +91 -0
- package/lib/Extensions/ImageExtension/ImageExtension.d.ts +7 -0
- package/lib/Extensions/ImageExtension/ImageExtension.js +18 -0
- package/lib/Extensions/LinkExtension/AssetLinkExtension.d.ts +27 -0
- package/lib/Extensions/LinkExtension/AssetLinkExtension.js +101 -0
- package/lib/Extensions/LinkExtension/LinkExtension.d.ts +23 -0
- package/lib/Extensions/LinkExtension/LinkExtension.js +87 -0
- package/lib/Extensions/LinkExtension/common.d.ts +7 -0
- package/lib/Extensions/LinkExtension/common.js +14 -0
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.d.ts +12 -0
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.js +76 -0
- package/lib/Extensions/UnsuportedExtension/UnsupportedNodeExtension.d.ts +10 -0
- package/lib/Extensions/UnsuportedExtension/UnsupportedNodeExtension.js +76 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +18 -0
- package/lib/hooks/useExpandedSelection.d.ts +23 -0
- package/lib/hooks/useExpandedSelection.js +37 -0
- package/lib/hooks/useExtensionNames.d.ts +1 -0
- package/lib/hooks/useExtensionNames.js +16 -0
- package/lib/hooks/useFocus.d.ts +8 -0
- package/lib/hooks/useFocus.js +43 -0
- package/lib/index.css +1525 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +16 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.js +2 -0
- package/lib/ui/Button/Button.d.ts +12 -0
- package/lib/ui/Button/Button.js +13 -0
- package/lib/ui/CollapseBox/CollapseBox.d.ts +7 -0
- package/lib/ui/CollapseBox/CollapseBox.js +48 -0
- package/lib/ui/Fields/Checkbox/Checkbox.d.ts +9 -0
- package/lib/ui/Fields/Checkbox/Checkbox.js +47 -0
- package/lib/ui/Fields/Input/Input.d.ts +3 -0
- package/lib/ui/Fields/Input/Input.js +33 -0
- package/lib/ui/Fields/InputContainer/InputContainer.d.ts +9 -0
- package/lib/ui/Fields/InputContainer/InputContainer.js +16 -0
- package/lib/ui/Fields/MatrixAsset/MatrixAsset.d.ts +19 -0
- package/lib/ui/Fields/MatrixAsset/MatrixAsset.js +30 -0
- package/lib/ui/Modal/FormModal.d.ts +5 -0
- package/lib/ui/Modal/FormModal.js +39 -0
- package/lib/ui/Modal/Modal.d.ts +11 -0
- package/lib/ui/Modal/Modal.js +79 -0
- package/lib/ui/Tabs/Tabs.d.ts +11 -0
- package/lib/ui/Tabs/Tabs.js +46 -0
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.d.ts +7 -0
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.js +48 -0
- package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.d.ts +11 -0
- package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.js +15 -0
- package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.d.ts +5 -0
- package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.js +23 -0
- package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.props.d.ts +3 -0
- package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.props.js +2 -0
- package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.d.ts +11 -0
- package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.js +229 -0
- package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.d.ts +9 -0
- package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.js +205 -0
- package/lib/utils/createToolbarPositioner.d.ts +18 -0
- package/lib/utils/createToolbarPositioner.js +96 -0
- package/lib/utils/getCursorRect.d.ts +2 -0
- package/lib/utils/getCursorRect.js +7 -0
- package/lib/utils/getMarkNamesByGroup.d.ts +2 -0
- package/lib/utils/getMarkNamesByGroup.js +9 -0
- package/lib/utils/getNodeNamesByGroup.d.ts +2 -0
- package/lib/utils/getNodeNamesByGroup.js +9 -0
- package/lib/utils/getShortcutSymbol.d.ts +1 -0
- package/lib/utils/getShortcutSymbol.js +8 -0
- package/lib/utils/undefinedIfEmpty.d.ts +1 -0
- package/lib/utils/undefinedIfEmpty.js +7 -0
- package/lib/utils/validation.d.ts +3 -0
- package/lib/utils/validation.js +16 -0
- package/package.json +83 -0
- package/postcss.config.js +12 -0
- package/src/Editor/Editor.spec.tsx +465 -0
- package/src/Editor/Editor.tsx +117 -0
- package/src/Editor/EditorContext.spec.tsx +25 -0
- package/src/Editor/EditorContext.ts +20 -0
- package/src/Editor/_editor.scss +430 -0
- package/src/EditorToolbar/FloatingToolbar.spec.tsx +49 -0
- package/src/EditorToolbar/FloatingToolbar.tsx +62 -0
- package/src/EditorToolbar/Toolbar.tsx +60 -0
- package/src/EditorToolbar/Tools/Bold/BoldButton.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Bold/BoldButton.tsx +31 -0
- package/src/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.spec.tsx +34 -0
- package/src/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.tsx +48 -0
- package/src/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.spec.tsx +23 -0
- package/src/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.tsx +34 -0
- package/src/EditorToolbar/Tools/Image/Form/ImageForm.spec.tsx +117 -0
- package/src/EditorToolbar/Tools/Image/Form/ImageForm.tsx +201 -0
- package/src/EditorToolbar/Tools/Image/ImageButton.spec.tsx +385 -0
- package/src/EditorToolbar/Tools/Image/ImageButton.tsx +72 -0
- package/src/EditorToolbar/Tools/Image/ImageModal.spec.tsx +123 -0
- package/src/EditorToolbar/Tools/Image/ImageModal.tsx +32 -0
- package/src/EditorToolbar/Tools/Italic/ItalicButton.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Italic/ItalicButton.tsx +31 -0
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.spec.tsx +79 -0
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.tsx +141 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.spec.tsx +402 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.tsx +67 -0
- package/src/EditorToolbar/Tools/Link/LinkModal.tsx +37 -0
- package/src/EditorToolbar/Tools/Link/RemoveLinkButton.spec.tsx +143 -0
- package/src/EditorToolbar/Tools/Link/RemoveLinkButton.tsx +42 -0
- package/src/EditorToolbar/Tools/Lists/ListButtons.tsx +14 -0
- package/src/EditorToolbar/Tools/Lists/OrderedList/OrderListButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.tsx +30 -0
- package/src/EditorToolbar/Tools/Lists/UnorderedList/UnorderedList.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.tsx +30 -0
- package/src/EditorToolbar/Tools/Redo/RedoButton.spec.tsx +59 -0
- package/src/EditorToolbar/Tools/Redo/RedoButton.tsx +31 -0
- package/src/EditorToolbar/Tools/Table/TableButton.spec.tsx +25 -0
- package/src/EditorToolbar/Tools/Table/TableButton.tsx +32 -0
- package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/TextAlignButtons.tsx +21 -0
- package/src/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.spec.tsx +47 -0
- package/src/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.tsx +32 -0
- package/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.spec.tsx +56 -0
- package/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.tsx +52 -0
- package/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.spec.tsx +30 -0
- package/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.tsx +25 -0
- package/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.spec.tsx +47 -0
- package/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.tsx +32 -0
- package/src/EditorToolbar/Tools/TextType/TextTypeDropdown.spec.tsx +51 -0
- package/src/EditorToolbar/Tools/TextType/TextTypeDropdown.tsx +54 -0
- package/src/EditorToolbar/Tools/Underline/Underline.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Underline/UnderlineButton.tsx +31 -0
- package/src/EditorToolbar/Tools/Undo/UndoButton.spec.tsx +70 -0
- package/src/EditorToolbar/Tools/Undo/UndoButton.tsx +31 -0
- package/src/EditorToolbar/_floating-toolbar.scss +9 -0
- package/src/EditorToolbar/_toolbar.scss +37 -0
- package/src/EditorToolbar/index.ts +2 -0
- package/src/Extensions/ClearFormattingExtension/ClearFormattingExtension.ts +57 -0
- package/src/Extensions/CodeBlockExtension/CodeBlockExtension.ts +34 -0
- package/src/Extensions/CommandsExtension/CommandsExtension.ts +54 -0
- package/src/Extensions/Extensions.ts +88 -0
- package/src/Extensions/FetchUrlExtension/FetchUrlExtension.ts +68 -0
- package/src/Extensions/ImageExtension/AssetImageExtension.spec.ts +77 -0
- package/src/Extensions/ImageExtension/AssetImageExtension.ts +109 -0
- package/src/Extensions/ImageExtension/ImageExtension.ts +19 -0
- package/src/Extensions/LinkExtension/AssetLinkExtension.spec.ts +106 -0
- package/src/Extensions/LinkExtension/AssetLinkExtension.ts +127 -0
- package/src/Extensions/LinkExtension/LinkExtension.spec.ts +68 -0
- package/src/Extensions/LinkExtension/LinkExtension.ts +105 -0
- package/src/Extensions/LinkExtension/common.ts +10 -0
- package/src/Extensions/PreformattedExtension/PreformattedExtension.spec.ts +43 -0
- package/src/Extensions/PreformattedExtension/PreformattedExtension.ts +85 -0
- package/src/Extensions/UnsuportedExtension/UnsupportedNodeExtension.spec.ts +137 -0
- package/src/Extensions/UnsuportedExtension/UnsupportedNodeExtension.tsx +80 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useExpandedSelection.ts +44 -0
- package/src/hooks/useExtensionNames.ts +15 -0
- package/src/hooks/useFocus.ts +61 -0
- package/src/index.scss +24 -0
- package/src/index.ts +9 -0
- package/src/types.ts +10 -0
- package/src/ui/Button/Button.spec.tsx +44 -0
- package/src/ui/Button/Button.tsx +35 -0
- package/src/ui/Button/_button.scss +37 -0
- package/src/ui/CollapseBox/CollapseBox.spec.tsx +49 -0
- package/src/ui/CollapseBox/CollapseBox.tsx +36 -0
- package/src/ui/CollapseBox/_collapseBox.scss +23 -0
- package/src/ui/Fields/Checkbox/Checkbox.spec.tsx +50 -0
- package/src/ui/Fields/Checkbox/Checkbox.tsx +49 -0
- package/src/ui/Fields/Checkbox/_checkbox.scss +26 -0
- package/src/ui/Fields/Input/Input.spec.tsx +49 -0
- package/src/ui/Fields/Input/Input.tsx +25 -0
- package/src/ui/Fields/InputContainer/InputContainer.spec.tsx +18 -0
- package/src/ui/Fields/InputContainer/InputContainer.tsx +29 -0
- package/src/ui/Fields/MatrixAsset/MatrixAsset.spec.tsx +121 -0
- package/src/ui/Fields/MatrixAsset/MatrixAsset.tsx +57 -0
- package/src/ui/Fields/Select/Select.spec.tsx +30 -0
- package/src/ui/Fields/Select/Select.tsx +66 -0
- package/src/ui/Modal/FormModal.spec.tsx +21 -0
- package/src/ui/Modal/FormModal.tsx +17 -0
- package/src/ui/Modal/Modal.spec.tsx +136 -0
- package/src/ui/Modal/Modal.tsx +104 -0
- package/src/ui/Modal/_modal.scss +24 -0
- package/src/ui/Tabs/Tabs.spec.tsx +44 -0
- package/src/ui/Tabs/Tabs.tsx +41 -0
- package/src/ui/ToolbarDropdown/ToolbarDropdown.spec.tsx +80 -0
- package/src/ui/ToolbarDropdown/ToolbarDropdown.tsx +42 -0
- package/src/ui/ToolbarDropdown/_toolbar-dropdown.scss +32 -0
- package/src/ui/ToolbarDropdownButton/ToolbarDropdownButton.spec.tsx +48 -0
- package/src/ui/ToolbarDropdownButton/ToolbarDropdownButton.tsx +33 -0
- package/src/ui/ToolbarDropdownButton/_toolbar-dropdown-button.scss +25 -0
- package/src/ui/_forms.scss +32 -0
- package/src/ui/_typography.scss +95 -0
- package/src/utils/converters/htmlToSquizNode/htmlToSquizNode.props.ts +3 -0
- package/src/utils/converters/htmlToSquizNode/htmlToSquizNode.spec.ts +179 -0
- package/src/utils/converters/htmlToSquizNode/htmlToSquizNode.ts +27 -0
- package/src/utils/converters/mocks/squizNodeJson.mock.ts +270 -0
- package/src/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.spec.ts +1058 -0
- package/src/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.ts +297 -0
- package/src/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.spec.ts +878 -0
- package/src/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.ts +221 -0
- package/src/utils/createToolbarPositioner.ts +128 -0
- package/src/utils/getCursorRect.ts +5 -0
- package/src/utils/getMarkNamesByGroup.spec.ts +20 -0
- package/src/utils/getMarkNamesByGroup.ts +7 -0
- package/src/utils/getNodeNamesByGroup.spec.ts +37 -0
- package/src/utils/getNodeNamesByGroup.ts +7 -0
- package/src/utils/getShortcutSymbol.spec.ts +27 -0
- package/src/utils/getShortcutSymbol.ts +4 -0
- package/src/utils/undefinedIfEmpty.spec.ts +12 -0
- package/src/utils/undefinedIfEmpty.ts +3 -0
- package/src/utils/validation.spec.ts +22 -0
- package/src/utils/validation.ts +16 -0
- package/tailwind.config.cjs +87 -0
- package/tests/index.ts +4 -0
- package/tests/mockResourceBrowserContext.tsx +99 -0
- package/tests/renderWithContext.tsx +75 -0
- package/tests/renderWithEditor.tsx +123 -0
- package/tests/select.ts +16 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +27 -0
@@ -0,0 +1,878 @@
|
|
1
|
+
import { FORMATTED_TEXT_MODELS as FormattedTextModels } from '@squiz/dx-json-schema-lib';
|
2
|
+
import { RemirrorJSON } from '@remirror/core';
|
3
|
+
import { squizNodeToRemirrorNode } from './squizNodeToRemirrorNode';
|
4
|
+
import {
|
5
|
+
mockSquizNodeJson,
|
6
|
+
mockSquizNodeTextJson,
|
7
|
+
sharedNodeExamples,
|
8
|
+
squizOnlyNodeExamples,
|
9
|
+
} from '../mocks/squizNodeJson.mock';
|
10
|
+
|
11
|
+
type FormattedText = FormattedTextModels.v1.FormattedText;
|
12
|
+
|
13
|
+
describe('squizNodeToRemirrorNode', () => {
|
14
|
+
it('should convert complex Squiz component JSON to Remirror JSON', () => {
|
15
|
+
expect(squizNodeToRemirrorNode(mockSquizNodeJson)).toEqual({
|
16
|
+
type: 'doc',
|
17
|
+
content: [
|
18
|
+
{
|
19
|
+
type: 'paragraph',
|
20
|
+
attrs: {
|
21
|
+
nodeIndent: null,
|
22
|
+
nodeTextAlignment: null,
|
23
|
+
nodeLineHeight: null,
|
24
|
+
style: '',
|
25
|
+
},
|
26
|
+
content: [
|
27
|
+
{
|
28
|
+
type: 'text',
|
29
|
+
text: 'Hello ',
|
30
|
+
},
|
31
|
+
{
|
32
|
+
type: 'text',
|
33
|
+
marks: [
|
34
|
+
{
|
35
|
+
type: 'link',
|
36
|
+
attrs: {
|
37
|
+
href: 'https://www.google.com',
|
38
|
+
target: null,
|
39
|
+
auto: false,
|
40
|
+
title: null,
|
41
|
+
},
|
42
|
+
},
|
43
|
+
{
|
44
|
+
type: 'bold',
|
45
|
+
},
|
46
|
+
],
|
47
|
+
text: 'Mr Bean',
|
48
|
+
},
|
49
|
+
{
|
50
|
+
type: 'text',
|
51
|
+
text: ', nice to ',
|
52
|
+
},
|
53
|
+
{
|
54
|
+
type: 'text',
|
55
|
+
marks: [
|
56
|
+
{
|
57
|
+
type: 'link',
|
58
|
+
attrs: {
|
59
|
+
href: 'https://www.google.com',
|
60
|
+
target: null,
|
61
|
+
auto: false,
|
62
|
+
title: null,
|
63
|
+
},
|
64
|
+
},
|
65
|
+
],
|
66
|
+
text: 'meet you',
|
67
|
+
},
|
68
|
+
{
|
69
|
+
type: 'text',
|
70
|
+
text: '.',
|
71
|
+
},
|
72
|
+
{
|
73
|
+
type: 'image',
|
74
|
+
attrs: {
|
75
|
+
alt: 'Test',
|
76
|
+
height: '150',
|
77
|
+
width: '200',
|
78
|
+
src: 'https://media2.giphy.com/media/3o6ozsIxg5legYvggo/giphy.gif',
|
79
|
+
title: '',
|
80
|
+
},
|
81
|
+
},
|
82
|
+
],
|
83
|
+
},
|
84
|
+
],
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
it('should convert top level text component JSON to Remirror JSON', () => {
|
89
|
+
expect(squizNodeToRemirrorNode(mockSquizNodeTextJson)).toEqual({
|
90
|
+
content: [
|
91
|
+
{
|
92
|
+
type: 'paragraph',
|
93
|
+
content: [
|
94
|
+
{
|
95
|
+
type: 'text',
|
96
|
+
text: 'Hello world!',
|
97
|
+
},
|
98
|
+
{
|
99
|
+
type: 'text',
|
100
|
+
text: 'Another one...',
|
101
|
+
},
|
102
|
+
],
|
103
|
+
},
|
104
|
+
],
|
105
|
+
type: 'doc',
|
106
|
+
});
|
107
|
+
});
|
108
|
+
|
109
|
+
it('should handle empty Squiz component JSON', () => {
|
110
|
+
expect(squizNodeToRemirrorNode([])).toEqual({ content: [], type: 'doc' });
|
111
|
+
expect(
|
112
|
+
squizNodeToRemirrorNode([
|
113
|
+
{
|
114
|
+
children: [],
|
115
|
+
type: 'tag',
|
116
|
+
tag: 'p',
|
117
|
+
},
|
118
|
+
]),
|
119
|
+
).toEqual({
|
120
|
+
content: [
|
121
|
+
{
|
122
|
+
attrs: { nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
123
|
+
type: 'paragraph',
|
124
|
+
},
|
125
|
+
],
|
126
|
+
type: 'doc',
|
127
|
+
});
|
128
|
+
});
|
129
|
+
|
130
|
+
it.each([
|
131
|
+
[
|
132
|
+
'Unsupported DOM tag',
|
133
|
+
[
|
134
|
+
{
|
135
|
+
children: [
|
136
|
+
{
|
137
|
+
type: 'text',
|
138
|
+
value: 'Should throw an error.',
|
139
|
+
},
|
140
|
+
],
|
141
|
+
type: 'tag',
|
142
|
+
tag: 'video',
|
143
|
+
},
|
144
|
+
],
|
145
|
+
{
|
146
|
+
type: 'doc',
|
147
|
+
content: [
|
148
|
+
{
|
149
|
+
type: 'paragraph',
|
150
|
+
content: [
|
151
|
+
{
|
152
|
+
type: 'unsupportedNode',
|
153
|
+
attrs: {
|
154
|
+
originalNode: {
|
155
|
+
children: [
|
156
|
+
{
|
157
|
+
type: 'text',
|
158
|
+
value: 'Should throw an error.',
|
159
|
+
},
|
160
|
+
],
|
161
|
+
type: 'tag',
|
162
|
+
tag: 'video',
|
163
|
+
},
|
164
|
+
errorMessage: 'Unsupported node type provided: tag (tag: video)',
|
165
|
+
},
|
166
|
+
},
|
167
|
+
],
|
168
|
+
},
|
169
|
+
],
|
170
|
+
},
|
171
|
+
],
|
172
|
+
[
|
173
|
+
'Unsupported node type',
|
174
|
+
[
|
175
|
+
{
|
176
|
+
children: [
|
177
|
+
{
|
178
|
+
type: 'text',
|
179
|
+
value: 'Should throw an error.',
|
180
|
+
},
|
181
|
+
],
|
182
|
+
type: 'unsupported-type',
|
183
|
+
},
|
184
|
+
],
|
185
|
+
{
|
186
|
+
type: 'doc',
|
187
|
+
content: [
|
188
|
+
{
|
189
|
+
type: 'paragraph',
|
190
|
+
content: [
|
191
|
+
{
|
192
|
+
type: 'unsupportedNode',
|
193
|
+
attrs: {
|
194
|
+
originalNode: {
|
195
|
+
children: [
|
196
|
+
{
|
197
|
+
type: 'text',
|
198
|
+
value: 'Should throw an error.',
|
199
|
+
},
|
200
|
+
],
|
201
|
+
type: 'unsupported-type',
|
202
|
+
},
|
203
|
+
errorMessage: 'Unsupported node type provided: unsupported-type',
|
204
|
+
},
|
205
|
+
},
|
206
|
+
],
|
207
|
+
},
|
208
|
+
],
|
209
|
+
},
|
210
|
+
],
|
211
|
+
])('should throw an error for non supported node types', (description: string, node: any, expected: any) => {
|
212
|
+
const result = squizNodeToRemirrorNode(node);
|
213
|
+
expect(result).toEqual(expected);
|
214
|
+
});
|
215
|
+
|
216
|
+
it('should handle line breaks', () => {
|
217
|
+
const squizComponentJSON: FormattedText = [
|
218
|
+
{
|
219
|
+
children: [],
|
220
|
+
type: 'tag',
|
221
|
+
tag: 'br',
|
222
|
+
},
|
223
|
+
];
|
224
|
+
|
225
|
+
const expected: RemirrorJSON = {
|
226
|
+
content: [
|
227
|
+
{
|
228
|
+
attrs: expect.any(Object),
|
229
|
+
type: 'hardBreak',
|
230
|
+
},
|
231
|
+
],
|
232
|
+
type: 'doc',
|
233
|
+
};
|
234
|
+
|
235
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
236
|
+
expect(result).toEqual(expected);
|
237
|
+
});
|
238
|
+
|
239
|
+
it('should handle pre formatted text', () => {
|
240
|
+
const squizComponentJSON: FormattedText = [
|
241
|
+
{
|
242
|
+
children: [
|
243
|
+
{
|
244
|
+
type: 'text',
|
245
|
+
value: 'Hello world!',
|
246
|
+
},
|
247
|
+
],
|
248
|
+
type: 'tag',
|
249
|
+
tag: 'pre',
|
250
|
+
},
|
251
|
+
];
|
252
|
+
|
253
|
+
const expected: RemirrorJSON = {
|
254
|
+
content: [
|
255
|
+
{
|
256
|
+
attrs: { nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
257
|
+
content: [{ text: 'Hello world!', type: 'text' }],
|
258
|
+
type: 'preformatted',
|
259
|
+
},
|
260
|
+
],
|
261
|
+
type: 'doc',
|
262
|
+
};
|
263
|
+
|
264
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
265
|
+
expect(result).toEqual(expected);
|
266
|
+
});
|
267
|
+
|
268
|
+
it('should handle code block text', () => {
|
269
|
+
const squizComponentJSON: FormattedText = [
|
270
|
+
{
|
271
|
+
children: [
|
272
|
+
{
|
273
|
+
type: 'text',
|
274
|
+
value: 'Hello world!',
|
275
|
+
},
|
276
|
+
],
|
277
|
+
type: 'tag',
|
278
|
+
tag: 'code',
|
279
|
+
},
|
280
|
+
];
|
281
|
+
|
282
|
+
const expected: RemirrorJSON = {
|
283
|
+
content: [
|
284
|
+
{
|
285
|
+
type: 'codeBlock',
|
286
|
+
attrs: {
|
287
|
+
language: 'markup',
|
288
|
+
wrap: true,
|
289
|
+
},
|
290
|
+
content: [
|
291
|
+
{
|
292
|
+
type: 'text',
|
293
|
+
text: 'Hello world!',
|
294
|
+
},
|
295
|
+
],
|
296
|
+
},
|
297
|
+
],
|
298
|
+
type: 'doc',
|
299
|
+
};
|
300
|
+
|
301
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
302
|
+
expect(result).toEqual(expected);
|
303
|
+
});
|
304
|
+
|
305
|
+
it('should handle images', () => {
|
306
|
+
const squizComponentJSON: FormattedText = [
|
307
|
+
{
|
308
|
+
children: [
|
309
|
+
{
|
310
|
+
children: [],
|
311
|
+
attributes: {
|
312
|
+
alt: 'This is a test alt',
|
313
|
+
height: '360',
|
314
|
+
width: '480',
|
315
|
+
src: 'https://media2.giphy.com/media/3o6ozsIxg5legYvggo/giphy.gif',
|
316
|
+
title: '',
|
317
|
+
},
|
318
|
+
type: 'tag',
|
319
|
+
tag: 'img',
|
320
|
+
},
|
321
|
+
],
|
322
|
+
type: 'tag',
|
323
|
+
tag: 'p',
|
324
|
+
},
|
325
|
+
];
|
326
|
+
|
327
|
+
const expected: RemirrorJSON = {
|
328
|
+
content: [
|
329
|
+
{
|
330
|
+
attrs: { nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
331
|
+
content: [
|
332
|
+
{
|
333
|
+
type: 'image',
|
334
|
+
attrs: {
|
335
|
+
alt: 'This is a test alt',
|
336
|
+
height: '360',
|
337
|
+
width: '480',
|
338
|
+
src: 'https://media2.giphy.com/media/3o6ozsIxg5legYvggo/giphy.gif',
|
339
|
+
title: '',
|
340
|
+
},
|
341
|
+
},
|
342
|
+
],
|
343
|
+
type: 'paragraph',
|
344
|
+
},
|
345
|
+
],
|
346
|
+
type: 'doc',
|
347
|
+
};
|
348
|
+
|
349
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
350
|
+
expect(result).toEqual(expected);
|
351
|
+
});
|
352
|
+
|
353
|
+
it.each([
|
354
|
+
['italics', 'italic'],
|
355
|
+
['bold', 'bold'],
|
356
|
+
['underline', 'underline'],
|
357
|
+
])('should handle %s formatting', (a, b) => {
|
358
|
+
const squizComponentJSON: FormattedText = [
|
359
|
+
{
|
360
|
+
children: [
|
361
|
+
{
|
362
|
+
children: [
|
363
|
+
{
|
364
|
+
type: 'text',
|
365
|
+
value: 'Hello world!',
|
366
|
+
},
|
367
|
+
],
|
368
|
+
font: {
|
369
|
+
[a]: true,
|
370
|
+
},
|
371
|
+
tag: 'span',
|
372
|
+
type: 'tag',
|
373
|
+
},
|
374
|
+
],
|
375
|
+
type: 'tag',
|
376
|
+
tag: 'p',
|
377
|
+
},
|
378
|
+
];
|
379
|
+
|
380
|
+
const expected: RemirrorJSON = {
|
381
|
+
content: [
|
382
|
+
{
|
383
|
+
attrs: { nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
384
|
+
content: [{ text: 'Hello world!', marks: [{ type: b }], type: 'text' }],
|
385
|
+
type: 'paragraph',
|
386
|
+
},
|
387
|
+
],
|
388
|
+
type: 'doc',
|
389
|
+
};
|
390
|
+
|
391
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
392
|
+
expect(result).toEqual(expected);
|
393
|
+
});
|
394
|
+
|
395
|
+
it.each([1, 2, 3, 4, 5, 6])('should handle heading %s and set it to level %s', (level) => {
|
396
|
+
const squizComponentJSON: FormattedText = [
|
397
|
+
{
|
398
|
+
children: [
|
399
|
+
{
|
400
|
+
type: 'text',
|
401
|
+
value: 'Hello world!',
|
402
|
+
},
|
403
|
+
],
|
404
|
+
type: 'tag',
|
405
|
+
tag: `h${level}`,
|
406
|
+
},
|
407
|
+
];
|
408
|
+
|
409
|
+
const expected: RemirrorJSON = {
|
410
|
+
content: [
|
411
|
+
{
|
412
|
+
attrs: { nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '', level },
|
413
|
+
content: [{ text: 'Hello world!', type: 'text' }],
|
414
|
+
type: 'heading',
|
415
|
+
},
|
416
|
+
],
|
417
|
+
type: 'doc',
|
418
|
+
};
|
419
|
+
|
420
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
421
|
+
expect(result).toEqual(expected);
|
422
|
+
});
|
423
|
+
|
424
|
+
it.each([...sharedNodeExamples, ...squizOnlyNodeExamples])(
|
425
|
+
'should convert a Squiz node to the expected Remirror representation - $description',
|
426
|
+
async ({ remirrorNode, squizNode }: any) => {
|
427
|
+
const result = squizNodeToRemirrorNode([
|
428
|
+
{
|
429
|
+
type: 'tag',
|
430
|
+
tag: 'p',
|
431
|
+
children: squizNode,
|
432
|
+
},
|
433
|
+
]);
|
434
|
+
expect(result).toEqual({
|
435
|
+
type: 'doc',
|
436
|
+
content: [
|
437
|
+
{
|
438
|
+
type: 'paragraph',
|
439
|
+
attrs: {
|
440
|
+
nodeIndent: null,
|
441
|
+
nodeLineHeight: null,
|
442
|
+
nodeTextAlignment: null,
|
443
|
+
style: '',
|
444
|
+
},
|
445
|
+
content: [remirrorNode],
|
446
|
+
},
|
447
|
+
],
|
448
|
+
});
|
449
|
+
},
|
450
|
+
);
|
451
|
+
|
452
|
+
it('should handle ordered lists', () => {
|
453
|
+
const squizComponentJSON: FormattedText = [
|
454
|
+
{
|
455
|
+
type: 'tag',
|
456
|
+
tag: 'ol',
|
457
|
+
children: [
|
458
|
+
{
|
459
|
+
type: 'tag',
|
460
|
+
tag: 'li',
|
461
|
+
children: [
|
462
|
+
{
|
463
|
+
type: 'tag',
|
464
|
+
tag: 'p',
|
465
|
+
children: [
|
466
|
+
{
|
467
|
+
type: 'text',
|
468
|
+
value: 'ddd',
|
469
|
+
},
|
470
|
+
],
|
471
|
+
},
|
472
|
+
],
|
473
|
+
},
|
474
|
+
],
|
475
|
+
},
|
476
|
+
];
|
477
|
+
|
478
|
+
const expected: RemirrorJSON = {
|
479
|
+
content: [
|
480
|
+
{
|
481
|
+
attrs: { level: undefined, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
482
|
+
type: 'orderedList',
|
483
|
+
marks: undefined,
|
484
|
+
text: undefined,
|
485
|
+
content: [
|
486
|
+
{
|
487
|
+
attrs: { level: undefined, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
488
|
+
type: 'listItem',
|
489
|
+
marks: undefined,
|
490
|
+
text: undefined,
|
491
|
+
content: [
|
492
|
+
{
|
493
|
+
attrs: {
|
494
|
+
level: undefined,
|
495
|
+
nodeIndent: null,
|
496
|
+
nodeLineHeight: null,
|
497
|
+
nodeTextAlignment: null,
|
498
|
+
style: '',
|
499
|
+
},
|
500
|
+
marks: undefined,
|
501
|
+
text: undefined,
|
502
|
+
type: 'paragraph',
|
503
|
+
content: [
|
504
|
+
{
|
505
|
+
attrs: undefined,
|
506
|
+
content: undefined,
|
507
|
+
marks: undefined,
|
508
|
+
text: 'ddd',
|
509
|
+
type: 'text',
|
510
|
+
},
|
511
|
+
],
|
512
|
+
},
|
513
|
+
],
|
514
|
+
},
|
515
|
+
],
|
516
|
+
},
|
517
|
+
],
|
518
|
+
type: 'doc',
|
519
|
+
};
|
520
|
+
|
521
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
522
|
+
expect(result).toEqual(expected);
|
523
|
+
});
|
524
|
+
|
525
|
+
it('should handle unordered lists', () => {
|
526
|
+
const squizComponentJSON: FormattedText = [
|
527
|
+
{
|
528
|
+
type: 'tag',
|
529
|
+
tag: 'ul',
|
530
|
+
children: [
|
531
|
+
{
|
532
|
+
type: 'tag',
|
533
|
+
tag: 'li',
|
534
|
+
children: [
|
535
|
+
{
|
536
|
+
type: 'tag',
|
537
|
+
tag: 'p',
|
538
|
+
children: [
|
539
|
+
{
|
540
|
+
type: 'text',
|
541
|
+
value: 'chicken',
|
542
|
+
},
|
543
|
+
],
|
544
|
+
},
|
545
|
+
],
|
546
|
+
},
|
547
|
+
{
|
548
|
+
type: 'tag',
|
549
|
+
tag: 'li',
|
550
|
+
children: [
|
551
|
+
{
|
552
|
+
type: 'tag',
|
553
|
+
tag: 'p',
|
554
|
+
children: [
|
555
|
+
{
|
556
|
+
type: 'text',
|
557
|
+
value: 'egg',
|
558
|
+
},
|
559
|
+
],
|
560
|
+
},
|
561
|
+
],
|
562
|
+
},
|
563
|
+
],
|
564
|
+
},
|
565
|
+
];
|
566
|
+
|
567
|
+
const expected: RemirrorJSON = {
|
568
|
+
content: [
|
569
|
+
{
|
570
|
+
attrs: { level: undefined, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
571
|
+
type: 'bulletList',
|
572
|
+
marks: undefined,
|
573
|
+
text: undefined,
|
574
|
+
content: [
|
575
|
+
{
|
576
|
+
attrs: { level: undefined, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
577
|
+
type: 'listItem',
|
578
|
+
marks: undefined,
|
579
|
+
text: undefined,
|
580
|
+
content: [
|
581
|
+
{
|
582
|
+
attrs: {
|
583
|
+
level: undefined,
|
584
|
+
nodeIndent: null,
|
585
|
+
nodeLineHeight: null,
|
586
|
+
nodeTextAlignment: null,
|
587
|
+
style: '',
|
588
|
+
},
|
589
|
+
marks: undefined,
|
590
|
+
text: undefined,
|
591
|
+
type: 'paragraph',
|
592
|
+
content: [
|
593
|
+
{
|
594
|
+
attrs: undefined,
|
595
|
+
content: undefined,
|
596
|
+
marks: undefined,
|
597
|
+
text: 'chicken',
|
598
|
+
type: 'text',
|
599
|
+
},
|
600
|
+
],
|
601
|
+
},
|
602
|
+
],
|
603
|
+
},
|
604
|
+
{
|
605
|
+
attrs: { level: undefined, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
606
|
+
type: 'listItem',
|
607
|
+
marks: undefined,
|
608
|
+
text: undefined,
|
609
|
+
content: [
|
610
|
+
{
|
611
|
+
attrs: {
|
612
|
+
level: undefined,
|
613
|
+
nodeIndent: null,
|
614
|
+
nodeLineHeight: null,
|
615
|
+
nodeTextAlignment: null,
|
616
|
+
style: '',
|
617
|
+
},
|
618
|
+
marks: undefined,
|
619
|
+
text: undefined,
|
620
|
+
type: 'paragraph',
|
621
|
+
content: [
|
622
|
+
{
|
623
|
+
attrs: undefined,
|
624
|
+
content: undefined,
|
625
|
+
marks: undefined,
|
626
|
+
text: 'egg',
|
627
|
+
type: 'text',
|
628
|
+
},
|
629
|
+
],
|
630
|
+
},
|
631
|
+
],
|
632
|
+
},
|
633
|
+
],
|
634
|
+
},
|
635
|
+
],
|
636
|
+
type: 'doc',
|
637
|
+
};
|
638
|
+
|
639
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
640
|
+
expect(result).toEqual(expected);
|
641
|
+
});
|
642
|
+
|
643
|
+
it('should handle horizontal lines', () => {
|
644
|
+
const squizComponentJSON: FormattedText = [
|
645
|
+
{
|
646
|
+
type: 'tag',
|
647
|
+
tag: 'hr',
|
648
|
+
children: [],
|
649
|
+
},
|
650
|
+
];
|
651
|
+
|
652
|
+
const expected: RemirrorJSON = {
|
653
|
+
content: [
|
654
|
+
{
|
655
|
+
attrs: { level: NaN, nodeIndent: null, nodeLineHeight: null, nodeTextAlignment: null, style: '' },
|
656
|
+
type: 'horizontalRule',
|
657
|
+
marks: undefined,
|
658
|
+
text: undefined,
|
659
|
+
content: undefined,
|
660
|
+
},
|
661
|
+
],
|
662
|
+
type: 'doc',
|
663
|
+
};
|
664
|
+
|
665
|
+
const result = squizNodeToRemirrorNode(squizComponentJSON);
|
666
|
+
expect(result).toEqual(expected);
|
667
|
+
});
|
668
|
+
|
669
|
+
it('should handle tables', () => {
|
670
|
+
const squizJSON: FormattedText = [
|
671
|
+
{
|
672
|
+
type: 'tag',
|
673
|
+
tag: 'table',
|
674
|
+
children: [
|
675
|
+
{
|
676
|
+
type: 'tag',
|
677
|
+
tag: 'tr',
|
678
|
+
children: [
|
679
|
+
{
|
680
|
+
type: 'tag',
|
681
|
+
tag: 'th',
|
682
|
+
children: [],
|
683
|
+
attributes: {
|
684
|
+
colspan: '1',
|
685
|
+
rowspan: '1',
|
686
|
+
tableControllerCell: 'true',
|
687
|
+
},
|
688
|
+
},
|
689
|
+
{
|
690
|
+
type: 'tag',
|
691
|
+
tag: 'th',
|
692
|
+
children: [],
|
693
|
+
attributes: {
|
694
|
+
colspan: '1',
|
695
|
+
rowspan: '1',
|
696
|
+
tableControllerCell: 'true',
|
697
|
+
colwidth: '366',
|
698
|
+
},
|
699
|
+
},
|
700
|
+
{
|
701
|
+
type: 'tag',
|
702
|
+
tag: 'th',
|
703
|
+
children: [],
|
704
|
+
attributes: {
|
705
|
+
colspan: '1',
|
706
|
+
rowspan: '1',
|
707
|
+
tableControllerCell: 'true',
|
708
|
+
},
|
709
|
+
},
|
710
|
+
],
|
711
|
+
},
|
712
|
+
{
|
713
|
+
type: 'tag',
|
714
|
+
tag: 'tr',
|
715
|
+
children: [
|
716
|
+
{
|
717
|
+
type: 'tag',
|
718
|
+
tag: 'th',
|
719
|
+
children: [],
|
720
|
+
attributes: {
|
721
|
+
colspan: '1',
|
722
|
+
rowspan: '1',
|
723
|
+
tableControllerCell: 'true',
|
724
|
+
},
|
725
|
+
},
|
726
|
+
{
|
727
|
+
type: 'tag',
|
728
|
+
tag: 'td',
|
729
|
+
children: [
|
730
|
+
{
|
731
|
+
type: 'tag',
|
732
|
+
tag: 'p',
|
733
|
+
children: [],
|
734
|
+
},
|
735
|
+
],
|
736
|
+
attributes: {
|
737
|
+
colspan: '1',
|
738
|
+
rowspan: '1',
|
739
|
+
colwidth: '366',
|
740
|
+
},
|
741
|
+
},
|
742
|
+
{
|
743
|
+
type: 'tag',
|
744
|
+
tag: 'td',
|
745
|
+
children: [
|
746
|
+
{
|
747
|
+
type: 'tag',
|
748
|
+
tag: 'p',
|
749
|
+
children: [],
|
750
|
+
},
|
751
|
+
],
|
752
|
+
attributes: {
|
753
|
+
colspan: '1',
|
754
|
+
rowspan: '1',
|
755
|
+
},
|
756
|
+
},
|
757
|
+
],
|
758
|
+
},
|
759
|
+
],
|
760
|
+
},
|
761
|
+
];
|
762
|
+
|
763
|
+
const expected: RemirrorJSON = {
|
764
|
+
type: 'doc',
|
765
|
+
content: [
|
766
|
+
{
|
767
|
+
type: 'table',
|
768
|
+
attrs: {
|
769
|
+
isControllersInjected: true,
|
770
|
+
},
|
771
|
+
content: [
|
772
|
+
{
|
773
|
+
type: 'tableRow',
|
774
|
+
attrs: {
|
775
|
+
nodeIndent: null,
|
776
|
+
nodeLineHeight: null,
|
777
|
+
nodeTextAlignment: null,
|
778
|
+
style: '',
|
779
|
+
},
|
780
|
+
content: [
|
781
|
+
{
|
782
|
+
type: 'tableControllerCell',
|
783
|
+
attrs: {
|
784
|
+
colspan: 1,
|
785
|
+
rowspan: 1,
|
786
|
+
colwidth: null,
|
787
|
+
background: null,
|
788
|
+
},
|
789
|
+
},
|
790
|
+
{
|
791
|
+
type: 'tableControllerCell',
|
792
|
+
attrs: {
|
793
|
+
colspan: 1,
|
794
|
+
rowspan: 1,
|
795
|
+
colwidth: [366],
|
796
|
+
background: null,
|
797
|
+
},
|
798
|
+
},
|
799
|
+
{
|
800
|
+
type: 'tableControllerCell',
|
801
|
+
attrs: {
|
802
|
+
colspan: 1,
|
803
|
+
rowspan: 1,
|
804
|
+
colwidth: null,
|
805
|
+
background: null,
|
806
|
+
},
|
807
|
+
},
|
808
|
+
],
|
809
|
+
},
|
810
|
+
{
|
811
|
+
type: 'tableRow',
|
812
|
+
attrs: {
|
813
|
+
nodeIndent: null,
|
814
|
+
nodeLineHeight: null,
|
815
|
+
nodeTextAlignment: null,
|
816
|
+
style: '',
|
817
|
+
},
|
818
|
+
content: [
|
819
|
+
{
|
820
|
+
type: 'tableControllerCell',
|
821
|
+
attrs: {
|
822
|
+
colspan: 1,
|
823
|
+
rowspan: 1,
|
824
|
+
colwidth: null,
|
825
|
+
background: null,
|
826
|
+
},
|
827
|
+
},
|
828
|
+
{
|
829
|
+
type: 'tableCell',
|
830
|
+
attrs: {
|
831
|
+
colspan: 1,
|
832
|
+
rowspan: 1,
|
833
|
+
colwidth: [366],
|
834
|
+
background: null,
|
835
|
+
},
|
836
|
+
content: [
|
837
|
+
{
|
838
|
+
type: 'paragraph',
|
839
|
+
attrs: {
|
840
|
+
nodeIndent: null,
|
841
|
+
nodeTextAlignment: null,
|
842
|
+
nodeLineHeight: null,
|
843
|
+
style: '',
|
844
|
+
},
|
845
|
+
},
|
846
|
+
],
|
847
|
+
},
|
848
|
+
{
|
849
|
+
type: 'tableCell',
|
850
|
+
attrs: {
|
851
|
+
colspan: 1,
|
852
|
+
rowspan: 1,
|
853
|
+
colwidth: null,
|
854
|
+
background: null,
|
855
|
+
},
|
856
|
+
content: [
|
857
|
+
{
|
858
|
+
type: 'paragraph',
|
859
|
+
attrs: {
|
860
|
+
nodeIndent: null,
|
861
|
+
nodeTextAlignment: null,
|
862
|
+
nodeLineHeight: null,
|
863
|
+
style: '',
|
864
|
+
},
|
865
|
+
},
|
866
|
+
],
|
867
|
+
},
|
868
|
+
],
|
869
|
+
},
|
870
|
+
],
|
871
|
+
},
|
872
|
+
],
|
873
|
+
};
|
874
|
+
|
875
|
+
const result = squizNodeToRemirrorNode(squizJSON);
|
876
|
+
expect(result).toEqual(expected);
|
877
|
+
});
|
878
|
+
});
|