diff --git a/apps/www/package.json b/apps/www/package.json index 99e75a3e81..5dfb1f9e12 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -102,7 +102,6 @@ "@udecode/plate-heading": "workspace:^", "@udecode/plate-highlight": "workspace:^", "@udecode/plate-horizontal-rule": "workspace:^", - "@udecode/plate-html": "workspace:^", "@udecode/plate-indent": "workspace:^", "@udecode/plate-indent-list": "workspace:^", "@udecode/plate-juice": "workspace:^", diff --git a/packages/core/src/lib/static/index.ts b/packages/core/src/lib/static/index.ts index 92a48de63e..4268d91113 100644 --- a/packages/core/src/lib/static/index.ts +++ b/packages/core/src/lib/static/index.ts @@ -4,7 +4,7 @@ export * from './pipeRenderStaticElement'; export * from './pipeRenderStaticLeaf'; +export * from './serializedHtml'; export * from './type'; export * from './components/index'; export * from './utils/index'; -export * from './serializedHtml'; \ No newline at end of file diff --git a/packages/core/src/lib/static/utils/index.ts b/packages/core/src/lib/static/utils/index.ts index 22df8691bc..94413ad050 100644 --- a/packages/core/src/lib/static/utils/index.ts +++ b/packages/core/src/lib/static/utils/index.ts @@ -3,3 +3,6 @@ */ export * from './createStaticString'; +export * from './getRenderStaticNodeProps'; +export * from './stripHtmlClassNames'; +export * from './stripSlateDataAttributes'; diff --git a/packages/core/src/lib/utils/index.ts b/packages/core/src/lib/utils/index.ts index 1f9f32b0b0..03a25321cd 100644 --- a/packages/core/src/lib/utils/index.ts +++ b/packages/core/src/lib/utils/index.ts @@ -6,6 +6,7 @@ export * from './applyDeepToNodes'; export * from './getInjectMatch'; export * from './getInjectedPlugins'; export * from './getKeysByTypes'; +export * from './getPluginNodeProps'; export * from './hotkeys'; export * from './mergeDeepToNodes'; export * from './normalizeDescendantsToDocumentFragment'; diff --git a/packages/html/.npmignore b/packages/html/.npmignore deleted file mode 100644 index 7d3b305b17..0000000000 --- a/packages/html/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -__tests__ -__test-utils__ -__mocks__ diff --git a/packages/html/CHANGELOG.md b/packages/html/CHANGELOG.md deleted file mode 100644 index b8c4f542b8..0000000000 --- a/packages/html/CHANGELOG.md +++ /dev/null @@ -1,285 +0,0 @@ -# @udecode/plate-serializer-html - -## 40.0.0 - -### Patch Changes - -- [#3744](https://github.com/udecode/plate/pull/3744) by [@zbeyens](https://github.com/zbeyens) – Sync with `@udecode/plate-core` - -## 39.0.0 - -## 38.0.1 - -### Patch Changes - -- [#3526](https://github.com/udecode/plate/pull/3526) by [@zbeyens](https://github.com/zbeyens) – Prefix base plugin with `Base` - -## 38.0.0 - -## 37.0.0 - -### Major Changes - -- [#3420](https://github.com/udecode/plate/pull/3420) by [@zbeyens](https://github.com/zbeyens) – - - `createDeserializeHtmlPlugin` -> `HtmlPlugin` - - Rename `deserializeHtml` plugin to `html` - - Rename `deserializeHtml.getNode` to `parse` - -## 36.0.0 - -## 34.0.0 - -## 33.0.0 - -## 32.0.0 - -### Patch Changes - -- [#3155](https://github.com/udecode/plate/pull/3155) by [@felixfeng33](https://github.com/felixfeng33) – Missing export - -## 31.4.4 - -### Patch Changes - -- [#3149](https://github.com/udecode/plate/pull/3149) by [@dimaanj](https://github.com/dimaanj) – `serialzieHtml`: remove `renderToStaticMarkup` from client code - -## 31.1.0 - -### Patch Changes - -- [#2837](https://github.com/udecode/plate/pull/2837) by [@dimaanj](https://github.com/dimaanj) – Fixes "The `useSlateStatic` hook must be used inside the component's context." error in `serializeHtml` - -## 31.0.0 - -### Minor Changes - -- [#3040](https://github.com/udecode/plate/pull/3040) by [@zbeyens](https://github.com/zbeyens) – Updated minor dependencies - -## 30.5.3 - -### Patch Changes - -- [`4cbed7159`](https://github.com/udecode/plate/commit/4cbed7159d51f7427051686e45bcf2a8899aeede) by [@zbeyens](https://github.com/zbeyens) – Move `@udecode/plate-common` to peerDeps to fix a bug when multiple instances were installed - -## 30.4.5 - -## 30.4.4 - -### Patch Changes - -- [#2943](https://github.com/udecode/plate/pull/2943) by [@shaungrady](https://github.com/shaungrady) – - - Fix handling of empty `preserveClassNames` array - - Previously, would output `
` - - Now, it outputs `
` - - Reduce time complexity of `stripClassNames` function - -## 30.1.2 - -## 30.0.0 - -## 29.1.0 - -## 29.0.1 - -## 29.0.0 - -## 28.0.0 - -## 27.0.3 - -## 27.0.0 - -## 26.0.6 - -### Patch Changes - -- [#2797](https://github.com/udecode/plate/pull/2797) by [@12joan](https://github.com/12joan) – Fix: `serializeHtml` mutates the live `editor` instance - -## 26.0.0 - -### Major Changes - -- [#2733](https://github.com/udecode/plate/pull/2733) by [@dimaanj](https://github.com/dimaanj) – - - [Breaking] `serializeHtml`: replaced option `slateProps` by `plateProps`. - - Fix errors when the components were using Plate hooks. - -## 25.0.1 - -## 25.0.0 - -## 24.5.2 - -## 24.4.0 - -### Minor Changes - -- [#2675](https://github.com/udecode/plate/pull/2675) by [@zbeyens](https://github.com/zbeyens) – Support slate-react 0.99.0 - -## 24.3.6 - -## 24.3.5 - -## 24.3.2 - -## 24.3.1 - -## 24.3.0 - -## 24.2.0 - -## 24.0.2 - -## 24.0.1 - -## 24.0.0 - -## 23.7.4 - -## 23.7.0 - -## 23.6.0 - -## 23.3.1 - -## 23.3.0 - -## 22.0.2 - -## 22.0.1 - -## 22.0.0 - -### Patch Changes - -- [#2471](https://github.com/udecode/plate/pull/2471) by [@zbeyens](https://github.com/zbeyens) – Fix `serializeHtml` to support `initialValue` - -## 21.5.0 - -## 21.4.2 - -### Patch Changes - -- [#2450](https://github.com/udecode/plate/pull/2450) by [@chandreshpatidar](https://github.com/chandreshpatidar) – Fix html serializer: expected dnd context - - When we want to serialize plate value in html with DnD support, it throws `Uncaught Invariant Violation: Expected drag drop context` error - - ```tsx - const Serialized = () => { - const editor = usePlateEditorState(); - const html = serializeHtml(editor, { - nodes: editor.children, - dndWrapper: (props) => , - }); - - return ; - }; - - export default () => ( - - - editableProps={editableProps} - plugins={plugins} - initialValue={deserializeHtmlValue} - > - - - - ); - ``` - - We can now serialize plate value in html with DnD support with above code - -## 21.4.1 - -## 21.3.2 - -## 21.3.0 - -## 21.1.5 - -## 21.0.0 - -## 20.7.2 - -## 20.7.0 - -## 20.4.0 - -## 20.3.2 - -## 20.0.0 - -## 19.7.0 - -## 19.5.0 - -## 19.4.4 - -## 19.4.2 - -## 19.2.0 - -## 19.1.1 - -## 19.1.0 - -## 19.0.3 - -## 19.0.1 - -## 19.0.0 - -## 18.15.0 - -## 18.13.0 - -## 18.9.0 - -## 18.7.0 - -## 18.6.0 - -## 18.2.0 - -## 18.1.1 - -## 17.0.3 - -## 17.0.2 - -## 17.0.1 - -## 17.0.0 - -## 16.8.0 - -## 16.5.0 - -### Patch Changes - -- [#1825](https://github.com/udecode/plate/pull/1825) by [@mskelton](https://github.com/mskelton) – Add missing `slate-history` peer dependency. - -## 16.3.0 - -## 16.2.0 - -## 16.1.0 - -## 16.0.2 - -## 16.0.0 - -## 15.0.3 - -## 15.0.0 - -## 14.4.2 - -## 14.0.2 - -### Patch Changes - -- [#1667](https://github.com/udecode/plate/pull/1667) by [@tjramage](https://github.com/tjramage) – - - fix `serializeHtml`: `convertNewLinesToHtmlBr` option was not used - -## 14.0.0 diff --git a/packages/html/README.md b/packages/html/README.md deleted file mode 100644 index 872cf190b1..0000000000 --- a/packages/html/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Plate HTML serializer plugin - -This package implements the HTML serializer for Plate. - -## Documentation - -Check out [Serializing HTML](https://platejs.org/docs/html). - -## License - -[MIT](../../LICENSE) diff --git a/packages/html/package.json b/packages/html/package.json deleted file mode 100644 index 732ac4b976..0000000000 --- a/packages/html/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@udecode/plate-html", - "version": "40.0.0", - "description": "HTML serializer plugin for Plate", - "keywords": [ - "html", - "plate", - "plugin", - "serializer", - "slate" - ], - "homepage": "https://platejs.org", - "bugs": { - "url": "https://github.com/udecode/plate/issues" - }, - "repository": { - "type": "git", - "url": "https://github.com/udecode/plate.git", - "directory": "packages/html" - }, - "license": "MIT", - "sideEffects": false, - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "module": "./dist/index.mjs", - "require": "./dist/index.js" - }, - "./react": { - "types": "./dist/react/index.d.ts", - "import": "./dist/react/index.mjs", - "module": "./dist/react/index.mjs", - "require": "./dist/react/index.js" - } - }, - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "files": [ - "dist/**/*" - ], - "scripts": { - "brl": "yarn p:brl", - "build": "yarn p:build", - "build:watch": "yarn p:build:watch", - "clean": "yarn p:clean", - "lint": "yarn p:lint", - "lint:fix": "yarn p:lint:fix", - "test": "yarn p:test", - "test:watch": "yarn p:test:watch", - "typecheck": "yarn p:typecheck" - }, - "dependencies": { - "html-entities": "^2.5.2" - }, - "devDependencies": { - "@types/papaparse": "^5.3.14", - "@udecode/plate-common": "workspace:^" - }, - "peerDependencies": { - "@udecode/plate-common": ">=40.3.1", - "react": ">=16.8.0", - "react-dom": ">=16.8.0", - "slate": ">=0.112.0", - "slate-dom": ">=0.111.0", - "slate-history": ">=0.93.0", - "slate-hyperscript": ">=0.66.0", - "slate-react": ">=0.111.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/html/src/__tests__/create-plate-ui-editor.ts b/packages/html/src/__tests__/create-plate-ui-editor.ts deleted file mode 100644 index ad7fc6d37d..0000000000 --- a/packages/html/src/__tests__/create-plate-ui-editor.ts +++ /dev/null @@ -1,184 +0,0 @@ -import type { AnyPluginConfig, Value } from '@udecode/plate-common'; - -import { withProps } from '@udecode/cn'; -import { AIPlugin } from '@udecode/plate-ai/react'; -import { - BoldPlugin, - CodePlugin, - ItalicPlugin, - StrikethroughPlugin, - SubscriptPlugin, - SuperscriptPlugin, - UnderlinePlugin, -} from '@udecode/plate-basic-marks/react'; -import { BlockquotePlugin } from '@udecode/plate-block-quote/react'; -import { - CodeBlockPlugin, - CodeLinePlugin, - CodeSyntaxPlugin, -} from '@udecode/plate-code-block/react'; -import { CommentsPlugin } from '@udecode/plate-comments/react'; -import { - type CreatePlateEditorOptions, - type PlateCorePlugin, - createPlateEditor, -} from '@udecode/plate-common/react'; -import { ParagraphPlugin } from '@udecode/plate-common/react'; -import { PlateElement, PlateLeaf } from '@udecode/plate-common/react'; -import { ExcalidrawPlugin } from '@udecode/plate-excalidraw/react'; -import { FindReplacePlugin } from '@udecode/plate-find-replace'; -import { HEADING_KEYS } from '@udecode/plate-heading'; -import { HighlightPlugin } from '@udecode/plate-highlight/react'; -import { HorizontalRulePlugin } from '@udecode/plate-horizontal-rule/react'; -import { KbdPlugin } from '@udecode/plate-kbd/react'; -import { ColumnItemPlugin, ColumnPlugin } from '@udecode/plate-layout/react'; -import { LinkPlugin } from '@udecode/plate-link/react'; -import { - BulletedListPlugin, - ListItemPlugin, - NumberedListPlugin, - TodoListPlugin, -} from '@udecode/plate-list/react'; -import { - AudioPlugin, - FilePlugin, - ImagePlugin, - MediaEmbedPlugin, - VideoPlugin, -} from '@udecode/plate-media/react'; -import { MentionInputPlugin } from '@udecode/plate-mention/react'; -import { - TableCellHeaderPlugin, - TableCellPlugin, - TablePlugin, - TableRowPlugin, -} from '@udecode/plate-table/react'; -// @ts-nocheck -import { AILeaf } from 'www/src/registry/default/plate-ui/ai-leaf'; -// @ts-nocheck -import { BlockquoteElement } from 'www/src/registry/default/plate-ui/blockquote-element'; -// @ts-nocheck -import { CodeBlockElement } from 'www/src/registry/default/plate-ui/code-block-element'; -// @ts-nocheck -import { CodeLeaf } from 'www/src/registry/default/plate-ui/code-leaf'; -// @ts-nocheck -import { CodeLineElement } from 'www/src/registry/default/plate-ui/code-line-element'; -// @ts-nocheck -import { CodeSyntaxLeaf } from 'www/src/registry/default/plate-ui/code-syntax-leaf'; -// @ts-nocheck -import { ColumnElement } from 'www/src/registry/default/plate-ui/column-element'; -// @ts-nocheck -import { ColumnGroupElement } from 'www/src/registry/default/plate-ui/column-group-element'; -// @ts-nocheck -import { CommentLeaf } from 'www/src/registry/default/plate-ui/comment-leaf'; -// @ts-nocheck -// @ts-nocheck -// @ts-nocheck -import { ExcalidrawElement } from 'www/src/registry/default/plate-ui/excalidraw-element'; -// @ts-nocheck -import { HeadingElement } from 'www/src/registry/default/plate-ui/heading-element'; -// @ts-nocheck -import { HighlightLeaf } from 'www/src/registry/default/plate-ui/highlight-leaf'; -// @ts-nocheck -import { HrElement } from 'www/src/registry/default/plate-ui/hr-element'; -// @ts-nocheck -import { ImageElement } from 'www/src/registry/default/plate-ui/image-element'; -// @ts-nocheck -import { KbdLeaf } from 'www/src/registry/default/plate-ui/kbd-leaf'; -// @ts-nocheck -import { LinkElement } from 'www/src/registry/default/plate-ui/link-element'; -// @ts-nocheck -import { ListElement } from 'www/src/registry/default/plate-ui/list-element'; -// @ts-nocheck -import { MediaAudioElement } from 'www/src/registry/default/plate-ui/media-audio-element'; -// @ts-nocheck -import { MediaEmbedElement } from 'www/src/registry/default/plate-ui/media-embed-element'; -// @ts-nocheck -import { MediaFileElement } from 'www/src/registry/default/plate-ui/media-file-element'; -// @ts-nocheck -// @ts-nocheck -import { MediaVideoElement } from 'www/src/registry/default/plate-ui/media-video-element'; -// @ts-nocheck -// @ts-nocheck -import { MentionInputElement } from 'www/src/registry/default/plate-ui/mention-input-element'; -// @ts-nocheck -import { ParagraphElement } from 'www/src/registry/default/plate-ui/paragraph-element'; -// @ts-nocheck -import { SearchHighlightLeaf } from 'www/src/registry/default/plate-ui/search-highlight-leaf'; -// @ts-nocheck -// @ts-nocheck -import { - TableCellElement, - TableCellHeaderElement, -} from 'www/src/registry/default/plate-ui/table-cell-element'; -// @ts-nocheck -import { TableElement } from 'www/src/registry/default/plate-ui/table-element'; -// @ts-nocheck -import { TableRowElement } from 'www/src/registry/default/plate-ui/table-row-element'; -// @ts-nocheck -// @ts-nocheck -import { TodoListElement } from 'www/src/registry/default/plate-ui/todo-list-element'; -// @ts-nocheck - -/** Create a plate editor with default UI. */ -export const createPlateUIEditor = < - V extends Value = Value, - P extends AnyPluginConfig = PlateCorePlugin, ->({ override, ...options }: CreatePlateEditorOptions = {}) => - createPlateEditor({ - ...options, - override: { - components: { - [AIPlugin.key]: AILeaf, - [AudioPlugin.key]: MediaAudioElement, - [BlockquotePlugin.key]: BlockquoteElement, - [BoldPlugin.key]: withProps(PlateLeaf, { as: 'strong' }), - [BulletedListPlugin.key]: withProps(ListElement, { variant: 'ul' }), - [CodeBlockPlugin.key]: CodeBlockElement, - [CodeLinePlugin.key]: CodeLineElement, - [CodePlugin.key]: CodeLeaf, - [CodeSyntaxPlugin.key]: CodeSyntaxLeaf, - [ColumnItemPlugin.key]: ColumnElement, - [ColumnPlugin.key]: ColumnGroupElement, - [CommentsPlugin.key]: CommentLeaf, - // [DatePlugin.key]: DateElement, - // [EmojiInputPlugin.key]: EmojiInputElement, - [ExcalidrawPlugin.key]: ExcalidrawElement, - [FilePlugin.key]: MediaFileElement, - [FindReplacePlugin.key]: SearchHighlightLeaf, - [HEADING_KEYS.h1]: withProps(HeadingElement, { variant: 'h1' }), - [HEADING_KEYS.h2]: withProps(HeadingElement, { variant: 'h2' }), - [HEADING_KEYS.h3]: withProps(HeadingElement, { variant: 'h3' }), - [HEADING_KEYS.h4]: withProps(HeadingElement, { variant: 'h4' }), - [HEADING_KEYS.h5]: withProps(HeadingElement, { variant: 'h5' }), - [HEADING_KEYS.h6]: withProps(HeadingElement, { variant: 'h6' }), - [HighlightPlugin.key]: HighlightLeaf, - [HorizontalRulePlugin.key]: HrElement, - [ImagePlugin.key]: ImageElement, - [ItalicPlugin.key]: withProps(PlateLeaf, { as: 'em' }), - [KbdPlugin.key]: KbdLeaf, - [LinkPlugin.key]: LinkElement, - [ListItemPlugin.key]: withProps(PlateElement, { as: 'li' }), - [MediaEmbedPlugin.key]: MediaEmbedElement, - [MentionInputPlugin.key]: MentionInputElement, - // [MentionPlugin.key]: MentionElement, - [NumberedListPlugin.key]: withProps(ListElement, { variant: 'ol' }), - [ParagraphPlugin.key]: ParagraphElement, - // [PlaceholderPlugin.key]: MediaPlaceholderElement, - // [SlashInputPlugin.key]: SlashInputElement, - [StrikethroughPlugin.key]: withProps(PlateLeaf, { as: 's' }), - [SubscriptPlugin.key]: withProps(PlateLeaf, { as: 'sub' }), - [SuperscriptPlugin.key]: withProps(PlateLeaf, { as: 'sup' }), - [TableCellHeaderPlugin.key]: TableCellHeaderElement, - [TableCellPlugin.key]: TableCellElement, - [TablePlugin.key]: TableElement, - [TableRowPlugin.key]: TableRowElement, - // [TocPlugin.key]: TocElement, - [TodoListPlugin.key]: TodoListElement, - // [TogglePlugin.key]: ToggleElement, - [UnderlinePlugin.key]: withProps(PlateLeaf, { as: 'u' }), - [VideoPlugin.key]: MediaVideoElement, - ...override?.components, - }, - }, - }); diff --git a/packages/html/src/__tests__/serializeHtml/classNames.spec.ts b/packages/html/src/__tests__/serializeHtml/classNames.spec.ts deleted file mode 100644 index 89650d035a..0000000000 --- a/packages/html/src/__tests__/serializeHtml/classNames.spec.ts +++ /dev/null @@ -1,295 +0,0 @@ -it('TODO: serialize html', () => { - expect(1).toBe(1); -}); - -// import { BoldPlugin } from '@udecode/plate-basic-marks/react'; -// import { ParagraphPlugin } from '@udecode/plate-common/react'; - -// import { serializeHtml } from '../../react/serializeHtml'; -// import { createPlateUIEditor } from '../create-plate-ui-editor'; - -// it('serialize with slate className', () => { -// const editor = createPlateUIEditor({ -// plugins: [ParagraphPlugin], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize with without modifying content', () => { -// const editor = createPlateUIEditor({ -// plugins: [ParagraphPlugin], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am class="preserved" text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe('
I am class="preserved" text!
'); -// }); - -// it('serialize with slate classNames: a+slate', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a slate-test', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize with slate classNames: slate+b', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'slate-test b', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize with classNames: a+slate+b', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a slate-test b', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize with classNames: a+slate+b+slate', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a slate-test b slate-cool', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe( -// '
I am centered text!
' -// ); -// }); - -// it('serialize with slate classNames: multiple tags', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a slate-test b', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe( -// '
I am centered text!
I am centered text!
' -// ); -// }); - -// it('serialize with custom preserved classname: a+custom', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a custom-align-center slate-test', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// preserveClassNames: ['custom-'], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize without preserving classnames', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a custom-align-center slate-test', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// preserveClassNames: [], -// }) -// ).toBe('
I am centered text!
'); -// }); - -// it('serialize nested with custom preserved classname: a+custom', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a custom-align-center slate-test', -// }, -// }, -// }), -// BoldPlugin.extend({ -// node: { -// props: { -// className: 'custom-bold', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [ -// { text: 'I am ' }, -// { bold: true, text: 'centered' }, -// { text: ' text!' }, -// ], -// type: ParagraphPlugin.key, -// }, -// ], -// preserveClassNames: ['custom-'], -// }) -// ).toBe( -// '
I am centered text!
' -// ); -// }); - -// it('serialize with multiple custom classname: a+custom+slate', () => { -// const editor = createPlateUIEditor({ -// plugins: [ -// ParagraphPlugin.extend({ -// node: { -// props: { -// className: 'a custom-align-center slate-test', -// }, -// }, -// }), -// ], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// preserveClassNames: ['custom-', 'slate-'], -// }) -// ).toBe( -// '
I am centered text!
' -// ); -// }); diff --git a/packages/html/src/__tests__/serializeHtml/elements.spec.ts b/packages/html/src/__tests__/serializeHtml/elements.spec.ts deleted file mode 100644 index a22f46a9ec..0000000000 --- a/packages/html/src/__tests__/serializeHtml/elements.spec.ts +++ /dev/null @@ -1,284 +0,0 @@ -it('TODO: serialize list to html', () => { - expect(1).toBe(1); -}); -// import { AlignPlugin } from '@udecode/plate-alignment/react'; -// import { BlockquotePlugin } from '@udecode/plate-block-quote/react'; -// import { CaptionPlugin } from '@udecode/plate-caption/react'; -// import { htmlStringToDOMNode } from '@udecode/plate-common'; -// import { ParagraphPlugin } from '@udecode/plate-common/react'; -// import { HeadingPlugin } from '@udecode/plate-heading/react'; -// import { LinkPlugin } from '@udecode/plate-link/react'; -// import { ListPlugin } from '@udecode/plate-list/react'; -// import { ImagePlugin } from '@udecode/plate-media/react'; -// import { TablePlugin } from '@udecode/plate-table/react'; - -// import { serializeHtml } from '../../react/serializeHtml'; -// import { createPlateUIEditor } from '../create-plate-ui-editor'; - -// it('serialize list to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [ListPlugin], -// }); - -// const render = htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [ -// { children: [{ text: 'Item one' }], type: 'li' }, -// { children: [{ text: 'Item two' }], type: 'li' }, -// ], -// type: 'ul', -// }, -// ], -// }) -// ).querySelectorAll('ul')[0]; -// expect(render.children).toHaveLength(2); -// expect(render.children[0].outerHTML).toEqual( -// '
  • Item one
  • ' -// ); -// expect(render.children[1].outerHTML).toEqual( -// '
  • Item two
  • ' -// ); -// }); - -// it('serialize link to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [LinkPlugin], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { text: 'Some paragraph of text with ' }, -// { -// children: [{ text: 'link' }], -// type: 'a', -// url: 'https://theuselessweb.com/', -// }, -// { text: ' part.' }, -// ], -// }) -// ).toBe( -// 'Some paragraph of text with link part.' -// ); -// }); - -// it('serialize blockquote to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [BlockquotePlugin], -// }); - -// expect( -// htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'Blockquoted text\n here...' }], -// type: 'blockquote', -// }, -// ], -// }) -// ).querySelectorAll('blockquote')[0] -// ).toHaveTextContent(`Blockquoted text here...`); -// }); - -// it('serialize blockquote to html, without trimming whitespace', () => { -// const editor = createPlateUIEditor({ -// plugins: [BlockquotePlugin], -// }); - -// const html = serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'Blockquoted text\nhere...' }], -// type: 'blockquote', -// }, -// ], -// stripWhitespace: false, -// }); - -// const node = htmlStringToDOMNode(html); -// expect(node.querySelectorAll('blockquote')[0]).toHaveTextContent( -// 'Blockquoted text here...' -// ); -// }); - -// it('serialize headings to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [HeadingPlugin], -// }); - -// const render = htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'Heading 1' }], -// type: 'h1', -// }, -// { -// children: [{ text: 'Heading 2' }], -// type: 'h2', -// }, -// { -// children: [{ text: 'Heading 3' }], -// type: 'h3', -// }, -// ], -// }) -// ); -// expect(render.querySelectorAll('h1')[0]).toHaveTextContent('Heading 1'); -// expect(render.querySelectorAll('h2')[0]).toHaveTextContent('Heading 2'); -// expect(render.querySelectorAll('h3')[0]).toHaveTextContent('Heading 3'); -// }); - -// it('serialize paragraph to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [ParagraphPlugin], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [{ text: 'Some random paragraph here...' }], -// type: 'p', -// }, -// ], -// }) -// ).toMatch( -// new RegExp('
    Some random paragraph here...
    ') -// ); -// }); - -// it('serialize image to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [ImagePlugin, CaptionPlugin], -// }); - -// expect( -// htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [], -// type: 'img', -// url: 'https://i.kym-cdn.com/photos/images/original/001/358/546/3fa.jpg', -// }, -// ], -// }) -// ).querySelectorAll('img')[0].src -// ).toEqual('https://i.kym-cdn.com/photos/images/original/001/358/546/3fa.jpg'); -// }); - -// it('serialize table to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [TablePlugin], -// }); - -// const render = htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// children: [ -// { -// children: [ -// { children: [{ text: 'Foo' }], type: 'td' }, -// { children: [{ text: 'Bar' }], type: 'td' }, -// ], -// type: 'tr', -// }, -// { -// children: [ -// { -// attributes: { colspan: '2' }, -// children: [{ text: 'Span' }], -// type: 'td', -// }, -// ], -// type: 'tr', -// }, -// ], -// type: 'table', -// }, -// ], -// }) -// ).querySelectorAll('table')[0]; -// expect( -// render.querySelector('table > tbody > tr:nth-child(1) > td:nth-child(1)') -// ?.textContent -// ).toEqual('Foo'); -// expect( -// render.querySelector('table > tbody > tr:nth-child(1) > td:nth-child(2)') -// ?.textContent -// ).toEqual('Bar'); -// expect( -// render.querySelector('table > tbody > tr:nth-child(2) > td:nth-child(1)') -// ?.textContent -// ).toEqual('Span'); -// }); - -// it('serialize align style to html', () => { -// const editor = createPlateUIEditor({ -// plugins: [ParagraphPlugin, AlignPlugin], -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// align: 'center', -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe( -// '
    I am centered text!
    ' -// ); -// }); - -// it('serialize align className to html', () => { -// const plugins = [ -// ParagraphPlugin, -// AlignPlugin.configure({ -// node: { props: { classNames: { center: 'slate-align-center' } } }, -// }), -// ]; - -// const editor = createPlateUIEditor({ -// plugins, -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { -// align: 'center', -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// ], -// }) -// ).toBe( -// '
    I am centered text!
    ' -// ); -// }); - -// it('serialize image and paragraph to html', () => { -// const plugins = [ParagraphPlugin, ImagePlugin, CaptionPlugin]; -// const render = serializeHtml(createPlateUIEditor({ plugins }), { -// nodes: [ -// { -// children: [{ text: 'I am centered text!' }], -// type: ParagraphPlugin.key, -// }, -// { -// children: [], -// type: 'img', -// url: 'https://i.kym-cdn.com/photos/images/original/001/358/546/3fa.jpg', -// }, -// ], -// }); -// expect(render).toContain(` { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { bold: true, text: 'bold' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with bold part.' - ); -}); - -it('serialize italic to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { italic: true, text: 'italic' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with italic part.' - ); -}); - -it('serialize highlight to html', () => { - expect( - htmlStringToDOMNode( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { highlight: true, text: 'highlighted' }, - { text: ' part.' }, - ], - }) - ).querySelectorAll('mark')[0] - ).toHaveTextContent('highlighted'); -}); - -it('serialize strikethrough to html', () => { - expect( - htmlStringToDOMNode( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { strikethrough: true, text: 'strikethrough' }, - { text: ' part.' }, - ], - }) - ).querySelectorAll('.slate-strikethrough')[0] - ).toHaveTextContent('strikethrough'); -}); - -it('serialize code to html', () => { - expect( - htmlStringToDOMNode( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { code: true, text: 'some code' }, - { text: ' part.' }, - ], - }) - ).querySelectorAll('code')[0] - ).toHaveTextContent('some code'); -}); - -it('serialize kbd to html', () => { - expect( - htmlStringToDOMNode( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { kbd: true, text: 'keyboard shortcut' }, - { text: ' part.' }, - ], - }) - ).querySelectorAll('kbd')[0] - ).toHaveTextContent('keyboard shortcut'); -}); - -it('serialize subscript to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { subscript: true, text: 'subscripted' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with subscripted part.' - ); -}); - -it('serialize superscript to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { superscript: true, text: 'superscripted' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with superscripted part.' - ); -}); - -it('serialize underline to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { text: 'underlined', underline: true }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with underlined part.' - ); -}); - -it('serialize bold and italic together to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { bold: true, italic: true, text: 'bold' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with bold part.' - ); -}); - -it('serialize bold and superscript together to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { bold: true, superscript: true, text: 'bold' }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with bold part.' - ); -}); - -it('serialize bold italic and underline together to html', () => { - expect( - serializeHtml(editor, { - nodes: [ - { text: 'Some paragraph of text with ' }, - { bold: true, italic: true, text: 'bold', underline: true }, - { text: ' part.' }, - ], - }) - ).toEqual( - 'Some paragraph of text with bold part.' - ); -}); diff --git a/packages/html/src/__tests__/serializeHtml/node-to-props.spec.ts b/packages/html/src/__tests__/serializeHtml/node-to-props.spec.ts deleted file mode 100644 index d79cf82f46..0000000000 --- a/packages/html/src/__tests__/serializeHtml/node-to-props.spec.ts +++ /dev/null @@ -1,82 +0,0 @@ -it('TODO: serialize list to html', () => { - expect(1).toBe(1); -}); -// import { CaptionPlugin } from '@udecode/plate-caption/react'; -// import { htmlStringToDOMNode } from '@udecode/plate-core'; -// import { LinkPlugin } from '@udecode/plate-link/react'; -// import { ImagePlugin } from '@udecode/plate-media/react'; - -// import { serializeHtml } from '../../react/serializeHtml'; -// import { createPlateUIEditor } from '../create-plate-ui-editor'; - -// const plugins = [ -// LinkPlugin.extend(() => ({ -// node: { -// props: ({ element }) => -// /^https?:\/\/slatejs.org\/?/.test((element as any).url) -// ? {} -// : { target: '_blank' }, -// }, -// })), -// CaptionPlugin, -// ImagePlugin.extend({ -// node: { -// props: ({ element }) => ({ -// alt: (element as any).attributes?.alt, -// width: (element as any).url.split('/').pop(), -// }), -// }, -// }), -// ]; - -// it('serialize link to html with attributes', () => { -// const editor = createPlateUIEditor({ -// plugins, -// }); - -// expect( -// serializeHtml(editor, { -// nodes: [ -// { text: 'An external ' }, -// { -// children: [{ text: 'link' }], -// type: 'a', -// url: 'https://theuselessweb.com/', -// }, -// { text: ' and an internal ' }, -// { -// children: [{ text: 'link' }], -// target: '_self', -// type: 'a', -// url: 'https://slatejs.org/', -// }, -// { text: '.' }, -// ], -// }) -// ).toBe( -// `An external link and an internal link.` -// ); -// }); - -// it('serialize image with alt to html', () => { -// const editor = createPlateUIEditor({ -// plugins, -// }); - -// expect( -// htmlStringToDOMNode( -// serializeHtml(editor, { -// nodes: [ -// { -// attributes: { alt: 'Placeholder' }, -// children: [], -// type: 'img', -// url: 'https://via.placeholder.com/300', -// }, -// ], -// }) -// ).querySelectorAll('img')[0].outerHTML -// ).toEqual( -// 'Placeholder' -// ); -// }); diff --git a/packages/html/src/__tests__/serializeHtml/nodes.spec.ts b/packages/html/src/__tests__/serializeHtml/nodes.spec.ts deleted file mode 100644 index 81c28ebf03..0000000000 --- a/packages/html/src/__tests__/serializeHtml/nodes.spec.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { BoldPlugin, ItalicPlugin } from '@udecode/plate-basic-marks/react'; -import { type Value, htmlStringToDOMNode } from '@udecode/plate-common'; -import { ParagraphPlugin } from '@udecode/plate-common/react'; -import { ListPlugin } from '@udecode/plate-list/react'; - -import { serializeHtml } from '../../react/serializeHtml'; -import { createPlateUIEditor } from '../create-plate-ui-editor'; - -it('serialize complex example list with paragraphs to html', () => { - const plugins = [ItalicPlugin, BoldPlugin, ParagraphPlugin, ListPlugin]; - const editor = createPlateUIEditor({ plugins }); - - const render = htmlStringToDOMNode( - serializeHtml(editor, { - nodes: [ - { - children: [ - { - text: 'Some paragraph that contains, ', - }, - { - italic: true, - text: 'italicized text', - }, - { - text: ' and ', - }, - { - bold: true, - text: 'bolded text', - }, - { - text: ' is first.', - }, - ], - type: 'p', - }, - { - children: [ - { - children: [ - { - children: [ - { - text: 'Item one in list', - }, - ], - type: 'p', - }, - ], - type: 'li', - }, - { - children: [ - { - children: [ - { - text: 'Item two in list', - }, - ], - type: 'p', - }, - ], - type: 'li', - }, - ], - type: 'ul', - }, - ], - }) - ); - expect(render.querySelectorAll('div')).toHaveLength(3); - expect(render.querySelectorAll('div')[0].outerHTML).toBe( - '
    Some paragraph that contains, italicized text and bolded text is first.
    ' - ); - expect(render.querySelectorAll('ul')).toHaveLength(1); - expect(render.querySelectorAll('li')).toHaveLength(2); - expect(render.querySelectorAll('ul')[0].innerHTML).toBe( - '
  • Item one in list
  • Item two in list
  • ' - ); -}); - -it('serialize complex example with no type on top level node to html', () => { - const plugins = [ItalicPlugin, BoldPlugin, ParagraphPlugin, ListPlugin]; - const editor = createPlateUIEditor({ plugins }); - - const render = serializeHtml(editor, { - nodes: [ - { - children: [ - { - children: [ - { - text: 'Some paragraph that contains, ', - }, - { - italic: true, - text: 'italicized text', - }, - { - text: ' and ', - }, - { - bold: true, - text: 'bolded text', - }, - { - text: ' is first.', - }, - ], - type: 'p', - }, - ], - }, - ] as Value, - }); - expect(render).toBe( - '
    Some paragraph that contains, italicized text and bolded text is first.
    ' - ); -}); - -it('serialize complex example with multiple no types on top level node to html', () => { - const plugins = [ItalicPlugin, BoldPlugin, ParagraphPlugin, ListPlugin]; - const editor = createPlateUIEditor({ plugins }); - - const render = serializeHtml(editor, { - nodes: [ - { - children: [ - { - children: [ - { - text: 'Some paragraph that contains, ', - }, - { - italic: true, - text: 'italicized text', - }, - { - text: ' and ', - }, - { - bold: true, - text: 'bolded text', - }, - { - text: ' is first.', - }, - ], - type: 'p', - }, - ], - }, - { - children: [{ bold: true, text: 'FOO' }], - }, - ] as Value, - }); - expect(render).toBe( - '
    Some paragraph that contains, italicized text and bolded text is first.
    FOO
    ' - ); -}); - -it('serialize string with %', () => { - const plugins = [ParagraphPlugin]; - const editor = createPlateUIEditor({ plugins }); - - const render = serializeHtml(editor, { - nodes: [ - { - children: [ - { - children: [ - { - text: 'None encoded string 100%', - }, - ], - type: 'p', - }, - ], - }, - { - children: [{ text: 'Encoded string 100%25' }], - }, - ] as Value, - }); - expect(render).toBe( - '
    None encoded string 100%
    Encoded string 100%25
    ' - ); -}); diff --git a/packages/html/src/__tests__/serializeHtml/plain-text.spec.ts b/packages/html/src/__tests__/serializeHtml/plain-text.spec.ts deleted file mode 100644 index b7d0cf60ae..0000000000 --- a/packages/html/src/__tests__/serializeHtml/plain-text.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { deserializeHtml, htmlStringToDOMNode } from '@udecode/plate-common'; - -import { serializeHtml } from '../../react/serializeHtml'; -import { createPlateUIEditor } from '../create-plate-ui-editor'; - -it('serializes with edge case where input is non-rich text', () => { - const input = htmlStringToDOMNode('Some non-rich text here.'); - const output = 'Some non-rich text here.'; - const editor = createPlateUIEditor({ plugins: [] }); - expect( - serializeHtml(editor, { - nodes: deserializeHtml(editor, { - element: input, - }), - }) - ).toEqual(output); -}); - -it('serializes with edge case where input is text element', () => { - const input = [{ text: 'Test just text.' }]; - const output = 'Test just text.'; - const editor = createPlateUIEditor({ plugins: [] }); - expect( - serializeHtml(editor, { - nodes: input, - }) - ).toEqual(output); -}); diff --git a/packages/html/src/__tests__/serializeHtml/with-attributes.spec.ts b/packages/html/src/__tests__/serializeHtml/with-attributes.spec.ts deleted file mode 100644 index 32ffe866a9..0000000000 --- a/packages/html/src/__tests__/serializeHtml/with-attributes.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -it('TODO', () => { - expect(1).toBe(1); -}); - -// import { CaptionPlugin } from '@udecode/plate-caption/react'; -// import { htmlStringToDOMNode } from '@udecode/plate-core'; -// import { LinkPlugin } from '@udecode/plate-link/react'; -// import { ImagePlugin } from '@udecode/plate-media/react'; - -// import { serializeHtml } from '../../react/serializeHtml'; -// import { createPlateUIEditor } from '../create-plate-ui-editor'; - -// it('serialize link to html with attributes', () => { -// const plugins = [ -// LinkPlugin.extend(() => ({ -// node: { -// props: { -// rel: 'noopener nofollow', -// target: '_blank', -// }, -// }, -// })), -// ]; - -// expect( -// serializeHtml( -// createPlateUIEditor({ -// plugins, -// }), -// { -// nodes: [ -// { text: 'Some paragraph of text with ' }, -// { -// attributes: { rel: 'noopener nofollow' }, -// children: [{ text: 'link' }], -// type: 'a', -// url: 'https://theuselessweb.com/', -// }, -// { text: ' part.' }, -// ], -// } -// ) -// ).toBe( -// `Some paragraph of text with link part.` -// ); -// }); - -// it('serialize image with alt to html', () => { -// const plugins = [ImagePlugin, CaptionPlugin]; - -// const element = { -// attributes: { alt: 'Never gonna give you up' }, -// children: [], -// type: 'img', -// url: 'https://i.kym-cdn.com/photos/images/original/001/358/546/3fa.jpg', -// }; - -// expect( -// htmlStringToDOMNode( -// serializeHtml(createPlateUIEditor({ plugins }), { -// nodes: [element], -// }) -// ).querySelectorAll('img')[0].outerHTML -// ).toEqual( -// 'Never gonna give you up' -// ); -// }); diff --git a/packages/html/src/__tests__/serializeHtml/with-serialize.spec.ts b/packages/html/src/__tests__/serializeHtml/with-serialize.spec.ts deleted file mode 100644 index 22d4604275..0000000000 --- a/packages/html/src/__tests__/serializeHtml/with-serialize.spec.ts +++ /dev/null @@ -1,123 +0,0 @@ -import React from 'react'; - -import { BoldPlugin } from '@udecode/plate-basic-marks/react'; -import { htmlStringToDOMNode } from '@udecode/plate-common'; -import { - type PlatePlugins, - createPlateEditor, - createPlatePlugin, -} from '@udecode/plate-core/react'; -import { ImagePlugin } from '@udecode/plate-media/react'; - -import { serializeHtml } from '../../react/serializeHtml'; -import { createPlateUIEditor } from '../create-plate-ui-editor'; - -const plugins = [ - ImagePlugin.configure({ - parsers: { - htmlReact: { - serializer: { - parse: ({ element }) => - React.createElement('img', { src: element.url }), - }, - }, - }, - }), -]; - -it('custom serialize image to html', () => { - expect( - htmlStringToDOMNode( - serializeHtml(createPlateUIEditor({ plugins }), { - nodes: [ - { - children: [], - type: 'img', - url: 'https://i.kym-cdn.com/photos/images/original/001/358/546/3fa.jpg', - }, - ], - }) - ).innerHTML - ).toEqual( - '' - ); -}); - -it('custom serialize bold to html', () => { - expect( - serializeHtml( - createPlateUIEditor({ - plugins: [ - BoldPlugin.extend({ - parsers: { - htmlReact: { - serializer: { - parse: ({ children, leaf }) => - leaf[BoldPlugin.key] && !!leaf.text - ? React.createElement('b', {}, children) - : children, - }, - }, - }, - }), - ], - }), - { - nodes: [ - { text: 'Some paragraph of text with ' }, - { bold: true, text: 'bold' }, - { text: ' part.' }, - ], - } - ) - ).toEqual('Some paragraph of text with bold part.'); -}); - -function Bold({ children }: any): React.ReactElement { - return React.createElement('b', {}, children); -} - -describe('multiple custom leaf serializers', () => { - const normalizeHTML = (html: string): string => - new DOMParser().parseFromString(html, 'text/html').body.innerHTML; - - it('serialization with the similar renderLeaf/serialize.left options of the same nodes should give the same result', () => { - const pluginsWithoutSerializers: PlatePlugins = [ - createPlatePlugin({ - key: 'bold', - node: { isLeaf: true }, - render: { node: Bold as any }, - }), // always bold - ]; - - const pluginsWithSerializers: PlatePlugins = [ - createPlatePlugin({ - key: 'bold', - node: { isLeaf: true }, - parsers: { htmlReact: { serializer: { parse: Bold } } }, - render: { node: Bold as any }, - }), - ]; - - const result1 = serializeHtml( - createPlateEditor({ - plugins: pluginsWithoutSerializers, - }), - { - nodes: [{ bold: true, text: 'any text' }], - } - ); - - const result2 = serializeHtml( - createPlateEditor({ - plugins: pluginsWithSerializers, - }), - { - nodes: [{ text: 'any text' }], - } - ); - - expect(normalizeHTML(result1)).toEqual(normalizeHTML(result2)); - expect(normalizeHTML(result2)).toEqual('any text'); - }); -}); diff --git a/packages/html/src/__tests__/serializeHtml/with-useEditor.spec.ts b/packages/html/src/__tests__/serializeHtml/with-useEditor.spec.ts deleted file mode 100644 index 81d20e1290..0000000000 --- a/packages/html/src/__tests__/serializeHtml/with-useEditor.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { - BulletedListPlugin, - ListItemContentPlugin, - ListItemPlugin, - ListPlugin, - TodoListPlugin, -} from '@udecode/plate-list/react'; - -import { serializeHtml } from '../../react/serializeHtml'; -import { createPlateUIEditor } from '../create-plate-ui-editor'; - -it('serialize elements using useSlateStatic', () => { - const plugins = [ - TodoListPlugin, - ListPlugin.extendPlugin(ListItemPlugin, { - node: { type: 'list-item' }, - }) - .extendPlugin(ListItemContentPlugin, { - node: { type: 'list-item-child' }, - }) - .extendPlugin(BulletedListPlugin, { - node: { type: 'unordered-list' }, - }), - ]; - const editor = createPlateUIEditor({ plugins }); - const render = serializeHtml(editor, { - nodes: [ - { - checked: true, - children: [{ text: 'Slide to the right.' }], - type: TodoListPlugin.key, - }, - { - children: [ - { - children: [ - { - children: [{ text: 'Level 3' }], - type: 'list-item-child', - }, - ], - type: 'list-item', - }, - ], - type: 'unordered-list', - }, - ], - }); - - expect(render).toContain('type="button" role="checkbox"'); -}); diff --git a/packages/html/src/__tests__/serializeHtml/without-deserialize.spec.ts b/packages/html/src/__tests__/serializeHtml/without-deserialize.spec.ts deleted file mode 100644 index 43a4942324..0000000000 --- a/packages/html/src/__tests__/serializeHtml/without-deserialize.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ParagraphPlugin } from '@udecode/plate-common/react'; - -import { serializeHtml } from '../../react/serializeHtml'; -import { createPlateUIEditor } from '../create-plate-ui-editor'; - -describe('when there is no deserializer', () => { - it('not serialize', () => { - const plugin = ParagraphPlugin.extend({ - parsers: { - htmlReact: { - serializer: null, - }, - }, - }); - - expect( - serializeHtml( - createPlateUIEditor({ - plugins: [plugin], - }), - { - nodes: [ - { - children: [{ text: 'I am centered text!' }], - type: ParagraphPlugin.key, - }, - ], - } - ) - ).toBe('
    I am centered text!
    '); - }); -}); diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts deleted file mode 100644 index e7cccc036f..0000000000 --- a/packages/html/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './lib/index'; diff --git a/packages/html/src/lib/index.ts b/packages/html/src/lib/index.ts deleted file mode 100644 index 5f34b1610f..0000000000 --- a/packages/html/src/lib/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './newLinesToHtmlBr'; -export * from './serializeHtml'; -export * from './stripClassNames'; -export * from './stripSlateDataAttributes'; -export * from './trimWhitespace'; diff --git a/packages/html/src/lib/newLinesToHtmlBr.ts b/packages/html/src/lib/newLinesToHtmlBr.ts deleted file mode 100644 index c37a019094..0000000000 --- a/packages/html/src/lib/newLinesToHtmlBr.ts +++ /dev/null @@ -1,3 +0,0 @@ -// Convert new line characters to HTML
    tags -export const newLinesToHtmlBr = (html: string): string => - html.replaceAll('\n', '
    '); diff --git a/packages/html/src/lib/serializeHtml.ts b/packages/html/src/lib/serializeHtml.ts deleted file mode 100644 index 15bde2a4e4..0000000000 --- a/packages/html/src/lib/serializeHtml.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { - type SlateEditor, - type StaticComponents, - type TDescendant, - isText, -} from '@udecode/plate-common'; -import { encode } from 'html-entities'; - -import { newLinesToHtmlBr } from './newLinesToHtmlBr'; -import { staticElementToHtml } from './staticElementToHtml'; -import { staticLeafToHtml } from './staticLeafToHtml'; - -const getReactDOMServer = async () => { - const ReactDOMServer = (await import('react-dom/server')).default; - - return ReactDOMServer; -}; - -type SerializeHtmlOptions = { - components: StaticComponents; - nodes: TDescendant[]; -}; - -export const serializeHtml = async ( - editor: SlateEditor, - { components, nodes }: SerializeHtmlOptions -): Promise => { - const ReactDOMServer = await getReactDOMServer(); - - const results = await Promise.all( - nodes.map(async (node) => { - if (isText(node)) { - return staticLeafToHtml(editor, { - ReactDOMServer, - components, - props: { - attributes: { 'data-slate-leaf': true }, - children: newLinesToHtmlBr(encode(node.text)), - leaf: node, - text: node, - }, - }); - } - - const childrenHtml = await serializeHtml(editor, { - components, - nodes: node.children as TDescendant[], - }); - - return staticElementToHtml(editor, { - ReactDOMServer, - components, - props: { - attributes: { - 'data-slate-node': 'element', - ref: null, - }, - children: childrenHtml, - editor, - element: node, - }, - }); - }) - ); - - const result = results.join(''); - - return result.trim(); -}; diff --git a/packages/html/src/lib/staticElementToHtml.ts b/packages/html/src/lib/staticElementToHtml.ts deleted file mode 100644 index ae4da805a7..0000000000 --- a/packages/html/src/lib/staticElementToHtml.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - type SlateEditor, - type SlatePlugin, - type StaticComponents, - PlateStaticElement, - getBelowNodesChildren, - getEditorPlugin, - getRenderStaticNodeProps, -} from '@udecode/plate-common'; - -import { renderComponentToHtml } from './utils/renderComponentToHtml'; - -export const staticElementToHtml = ( - editor: SlateEditor, - { - ReactDOMServer, - components, - props: nodeProps, - }: { - ReactDOMServer: any; - components: StaticComponents; - props: any; - preserveClassNames?: string[]; - } -): string => { - if (!nodeProps.element.type) { - return renderComponentToHtml(ReactDOMServer, PlateStaticElement, nodeProps); - } - - const plugin = editor.pluginList.find( - (plugin: SlatePlugin) => nodeProps.element.type === plugin.node.type - ); - - if (!plugin) { - return renderComponentToHtml(ReactDOMServer, PlateStaticElement, nodeProps); - } - - const Component = components[plugin.key]; - - // Apply below nodes to children for example indent list plugin - nodeProps.children = getBelowNodesChildren( - editor, - nodeProps, - plugin, - nodeProps.children - ); - - // console.log(plugin ? (getEditorPlugin(editor, plugin) as any) : {}, 'fj'); - - const html = renderComponentToHtml( - ReactDOMServer, - Component, - // inject plugin props for example link plugin and table plugin - getRenderStaticNodeProps({ - editor, - plugin, - props: { - ...nodeProps, - plugin, - ...(plugin ? getEditorPlugin(editor, plugin) : {}), - }, - }) - ); - - return ( - html ?? renderComponentToHtml(ReactDOMServer, PlateStaticElement, nodeProps) - ); -}; diff --git a/packages/html/src/lib/staticLeafToHtml.ts b/packages/html/src/lib/staticLeafToHtml.ts deleted file mode 100644 index 73c5577ee5..0000000000 --- a/packages/html/src/lib/staticLeafToHtml.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - type SlateEditor, - type SlatePlugin, - PlateStaticLeaf, - createStaticString, - getRenderStaticNodeProps, -} from '@udecode/plate-common'; - -import { renderComponentToHtml } from './utils/renderComponentToHtml'; - -export const staticLeafToHtml = ( - editor: SlateEditor, - { - ReactDOMServer, - components, - props, - }: { ReactDOMServer: any; components: any; props: any } -): string => { - const innerString = editor.pluginList.reduce( - (result: string, plugin: SlatePlugin) => { - if (!plugin.node.isLeaf) return result; - if (props.leaf[plugin.key]) { - const Component = components[plugin.key]; - - if (!Component) return result; - - const ctxProps = getRenderStaticNodeProps({ - editor, - plugin, - props: props, - }); - - return renderComponentToHtml(ReactDOMServer, Component, { - ...ctxProps, - children: result, - }); - } - - return result; - }, - renderComponentToHtml(ReactDOMServer, createStaticString, { - ...props, - text: props.children, - }) - ); - - const ctxProps = getRenderStaticNodeProps({ - editor, - props, - }) as any; - - return renderComponentToHtml(ReactDOMServer, PlateStaticLeaf, { - ...ctxProps, - children: innerString, - }); -}; diff --git a/packages/html/src/lib/stripClassNames.ts b/packages/html/src/lib/stripClassNames.ts deleted file mode 100644 index 6d8bcc7443..0000000000 --- a/packages/html/src/lib/stripClassNames.ts +++ /dev/null @@ -1,31 +0,0 @@ -const classAttrRegExp = / class="([^"]*)"/g; - -/** - * Remove all class names that do not start with one of preserveClassNames - * (`slate-` by default) - */ -export const stripClassNames = ( - html: string, - { preserveClassNames = ['slate-'] }: { preserveClassNames?: string[] } -) => { - if (preserveClassNames.length === 0) { - return html.replaceAll(classAttrRegExp, ''); - } - - const preserveRegExp = new RegExp( - preserveClassNames.map((cn) => `^${cn}`).join('|') - ); - - return html.replaceAll( - classAttrRegExp, - (match: string, className: string) => { - const classesToKeep = className - .split(/\s+/) - .filter((cn) => preserveRegExp.test(cn)); - - return classesToKeep.length === 0 - ? '' - : ` class="${classesToKeep.join(' ')}"`; - } - ); -}; diff --git a/packages/html/src/lib/stripSlateDataAttributes.ts b/packages/html/src/lib/stripSlateDataAttributes.ts deleted file mode 100644 index f39b6b2f70..0000000000 --- a/packages/html/src/lib/stripSlateDataAttributes.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Remove redundant data attributes -export const stripSlateDataAttributes = (rawHtml: string): string => - rawHtml - .replaceAll(/ data-slate(?:-node|-type|-leaf)="[^"]+"/g, '') - .replaceAll(/ data-testid="[^"]+"/g, ''); diff --git a/packages/html/src/lib/trimWhitespace.ts b/packages/html/src/lib/trimWhitespace.ts deleted file mode 100644 index 00fcc95a33..0000000000 --- a/packages/html/src/lib/trimWhitespace.ts +++ /dev/null @@ -1,3 +0,0 @@ -// Remove extra whitespace generated by ReactDOMServer -export const trimWhitespace = (rawHtml: string): string => - rawHtml.replaceAll(/\r\n|[\t\n\r]/g, ''); diff --git a/packages/html/src/lib/utils/renderComponentToHtml.ts b/packages/html/src/lib/utils/renderComponentToHtml.ts deleted file mode 100644 index 870635d602..0000000000 --- a/packages/html/src/lib/utils/renderComponentToHtml.ts +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; - -import { decode } from 'html-entities'; - -export const renderComponentToHtml =

    ( - ReactDOMServer: any, - type: React.ComponentType

    , - props: P -): string => { - return decode( - ReactDOMServer.renderToStaticMarkup(React.createElement(type, props)) - ); -}; diff --git a/packages/html/src/react/HtmlReactPlugin.tsx b/packages/html/src/react/HtmlReactPlugin.tsx deleted file mode 100644 index 490d0a19f9..0000000000 --- a/packages/html/src/react/HtmlReactPlugin.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { bindFirst } from '@udecode/plate-common'; -import { createPlatePlugin } from '@udecode/plate-common/react'; - -import { serializeHtml } from './serializeHtml'; - -export const HtmlReactPlugin = createPlatePlugin({ - key: 'htmlReact', -}).extendApi(({ editor }) => ({ - serialize: bindFirst(serializeHtml, editor), -})); diff --git a/packages/html/src/react/elementToHtml.ts b/packages/html/src/react/elementToHtml.ts deleted file mode 100644 index dd9d94420f..0000000000 --- a/packages/html/src/react/elementToHtml.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type React from 'react'; - -import type { TRenderElementProps } from '@udecode/slate-react'; - -import { getEditorPlugin } from '@udecode/plate-common'; -import { - type PlateEditor, - type PlateProps, - pluginRenderElement, -} from '@udecode/plate-common/react'; -import { decode } from 'html-entities'; - -import { stripClassNames } from '../lib/stripClassNames'; -import { createElementWithSlate } from './utils/createElementWithSlate'; -import { renderToStaticMarkup } from './utils/renderToStaticMarkupClient'; - -export const elementToHtml = ( - editor: PlateEditor, - { - dndWrapper, - plateProps, - preserveClassNames, - props, - }: { - props: TRenderElementProps; - dndWrapper?: React.ComponentClass | React.FC | string; - plateProps?: Partial; - preserveClassNames?: string[]; - } -) => { - let html = `

    ${props.children}
    `; - - // If no type provided we wrap children with div tag - if (!props.element.type) { - return html; - } - - // Search for matching plugin based on element type - editor.pluginList.some((plugin) => { - const serializer = plugin.parsers.htmlReact?.serializer; - - if ( - !plugin.node.isElement || - serializer === null || - (serializer?.query && !serializer.query(props as any)) || - props.element.type !== plugin.node.type - ) { - return false; - } - - // Render element using picked plugins renderElement function and ReactDOM - html = decode( - renderToStaticMarkup( - createElementWithSlate( - { - ...plateProps, - children: - serializer?.parse?.({ - ...props, - ...getEditorPlugin(editor, plugin), - } as any) ?? - pluginRenderElement(editor, plugin)({ ...props } as any), - }, - dndWrapper - ) - ) - ); - - html = stripClassNames(html, { preserveClassNames }); - - return true; - }); - - return html; -}; diff --git a/packages/html/src/react/index.ts b/packages/html/src/react/index.ts deleted file mode 100644 index f41b8a6028..0000000000 --- a/packages/html/src/react/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './HtmlReactPlugin'; -export * from './elementToHtml'; -export * from './leafToHtml'; -export * from './serializeHtml'; -export * from './utils/index'; diff --git a/packages/html/src/react/leafToHtml.ts b/packages/html/src/react/leafToHtml.ts deleted file mode 100644 index 1837e25400..0000000000 --- a/packages/html/src/react/leafToHtml.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { TRenderLeafProps } from '@udecode/slate-react'; - -import { getEditorPlugin } from '@udecode/plate-common'; -import { - type PlateEditor, - type PlateProps, - pluginRenderLeaf, -} from '@udecode/plate-common/react'; -import { decode } from 'html-entities'; - -import { stripClassNames } from '../lib'; -import { createElementWithSlate } from './utils/createElementWithSlate'; -import { renderToStaticMarkup } from './utils/renderToStaticMarkupClient'; - -export const leafToHtml = ( - editor: PlateEditor, - { - plateProps, - preserveClassNames, - props, - }: { - props: TRenderLeafProps; - plateProps?: Partial; - preserveClassNames?: string[]; - } -) => { - const { children } = props; - - return editor.pluginList.reduce((result, plugin) => { - if (!plugin.node.isLeaf) return result; - - props = { - ...props, - children: result, - ...getEditorPlugin(editor, plugin), - }; - - const serializer = plugin.parsers.htmlReact?.serializer; - - if ( - serializer === null || - (serializer?.query && !serializer.query(props as any)) - ) { - return result; - } - - const serialized = - serializer?.parse?.(props as any) ?? - pluginRenderLeaf(editor, plugin)(props as any); - - if (serialized === children) return result; - - let html = decode( - renderToStaticMarkup( - createElementWithSlate({ - ...plateProps, - children: serialized, - }) - ) - ); - - html = stripClassNames(html, { preserveClassNames }); - - return html; - }, children); -}; diff --git a/packages/html/src/react/serializeHtml.ts b/packages/html/src/react/serializeHtml.ts deleted file mode 100644 index 0eb59135b9..0000000000 --- a/packages/html/src/react/serializeHtml.ts +++ /dev/null @@ -1,103 +0,0 @@ -import type React from 'react'; - -import type { PlateEditor, PlateProps } from '@udecode/plate-common/react'; - -import { type TDescendant, isText } from '@udecode/plate-common'; -import { encode } from 'html-entities'; - -import { newLinesToHtmlBr } from '../lib/newLinesToHtmlBr'; -import { stripSlateDataAttributes } from '../lib/stripSlateDataAttributes'; -import { trimWhitespace } from '../lib/trimWhitespace'; -import { elementToHtml } from './elementToHtml'; -import { leafToHtml } from './leafToHtml'; - -/** Convert Slate Nodes into HTML string. */ -export const serializeHtml = ( - editor: PlateEditor, - { - convertNewLinesToHtmlBr = false, - dndWrapper, - nodes, - plateProps = {}, - preserveClassNames, - stripDataAttributes = true, - stripWhitespace = true, - }: { - /** Slate nodes to convert to HTML. */ - nodes: TDescendant[]; - - /** - * Optionally convert new line chars (\n) to HTML
    tags - * - * @default false - */ - convertNewLinesToHtmlBr?: boolean; - - /** Drag and drop component */ - dndWrapper?: React.ComponentClass | React.FC | string; - - /** Slate props to provide if the rendering depends on plate/slate hooks */ - plateProps?: Omit, 'editor'>; - - /** List of className prefixes to preserve from being stripped out */ - preserveClassNames?: string[]; - - /** Enable stripping data attributes */ - stripDataAttributes?: boolean; - - /** - * Whether stripping whitespaces from serialized HTML - * - * @default true - */ - stripWhitespace?: boolean; - } -): string => { - (plateProps as any).editor = editor; - - let result = nodes - .map((node) => { - if (isText(node)) { - const children = encode(node.text); - - return leafToHtml(editor, { - plateProps, - preserveClassNames, - props: { - attributes: { 'data-slate-leaf': true }, - children: convertNewLinesToHtmlBr - ? newLinesToHtmlBr(children) - : children, - leaf: node as any, - text: node as any, - }, - }); - } - - return elementToHtml(editor, { - dndWrapper, - plateProps, - preserveClassNames, - props: { - attributes: { 'data-slate-node': 'element', ref: null }, - children: serializeHtml(editor, { - convertNewLinesToHtmlBr, - nodes: node.children as TDescendant[], - preserveClassNames, - stripWhitespace, - }), - element: node, - }, - }); - }) - .join(''); - - if (stripWhitespace) { - result = trimWhitespace(result); - } - if (stripDataAttributes) { - result = stripSlateDataAttributes(result); - } - - return result; -}; diff --git a/packages/html/src/react/utils/createElementWithSlate.ts b/packages/html/src/react/utils/createElementWithSlate.ts deleted file mode 100644 index 255ca51419..0000000000 --- a/packages/html/src/react/utils/createElementWithSlate.ts +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; - -import { - type PlateProps, - Plate, - PlateContent, -} from '@udecode/plate-common/react'; - -/** Create a React element wrapped in a Plate provider. */ -export const createElementWithSlate = ( - plateProps?: Partial, - dndWrapper?: React.ComponentClass | React.FC | string -) => { - const { children, editor, onChange = () => {}, ...props } = plateProps || {}; - - const plateContent = React.createElement(PlateContent, { - renderEditable: () => children, - }); - - const plate = React.createElement( - Plate, - { - editor, - onChange, - ...props, - } as PlateProps, - plateContent - ); - - if (dndWrapper) { - return React.createElement(dndWrapper, null, plate); - } - - return plate; -}; diff --git a/packages/html/src/react/utils/index.ts b/packages/html/src/react/utils/index.ts deleted file mode 100644 index 76c1ce041f..0000000000 --- a/packages/html/src/react/utils/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './createElementWithSlate'; -export * from './renderToStaticMarkupClient'; diff --git a/packages/html/src/react/utils/renderToStaticMarkupClient.ts b/packages/html/src/react/utils/renderToStaticMarkupClient.ts deleted file mode 100644 index 920ffef2c2..0000000000 --- a/packages/html/src/react/utils/renderToStaticMarkupClient.ts +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; - -import ReactDOMClient from 'react-dom/client'; -import ReactDOMServer from 'react-dom/server'; - -import type { createElementWithSlate } from './createElementWithSlate'; - -const REACT_API_UPDATE_VERSION = 18; - -/** - * See - * https://react.dev/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code - */ -const renderToStaticNew = (elem: ReturnType) => { - const div = document.createElement('div'); - const root = ReactDOMClient.createRoot(div); - ReactDOM.flushSync(() => { - root.render(elem); - }); - - return div.innerHTML; -}; - -const renderToStaticOld = (elem: ReturnType) => { - const div = document.createElement('div'); - // eslint-disable-next-line react/no-deprecated - ReactDOM.render(elem, div); - - return div.innerHTML; -}; - -const createRenderToStaticMarkupClient = () => { - const reactMajorVersion = +React.version.slice(0, 2); - - return reactMajorVersion >= REACT_API_UPDATE_VERSION - ? renderToStaticNew - : renderToStaticOld; -}; - -export const renderToStaticMarkup = - typeof window === 'undefined' - ? ReactDOMServer.renderToStaticMarkup - : createRenderToStaticMarkupClient(); diff --git a/packages/html/tsconfig.build.json b/packages/html/tsconfig.build.json deleted file mode 100644 index 425481e027..0000000000 --- a/packages/html/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../config/tsconfig.build.json", - "compilerOptions": { - "declarationDir": "./dist", - "outDir": "./dist" - }, - "include": ["src"] -} diff --git a/packages/html/tsconfig.json b/packages/html/tsconfig.json deleted file mode 100644 index ad83d092a5..0000000000 --- a/packages/html/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../../config/tsconfig.base.json", - "include": ["src"], - "exclude": [] -} diff --git a/packages/plate/package.json b/packages/plate/package.json index d9b567a224..a677267c0c 100644 --- a/packages/plate/package.json +++ b/packages/plate/package.json @@ -75,7 +75,6 @@ "@udecode/plate-heading": "40.2.6", "@udecode/plate-highlight": "40.0.0", "@udecode/plate-horizontal-rule": "40.0.0", - "@udecode/plate-html": "40.0.0", "@udecode/plate-indent": "40.0.0", "@udecode/plate-indent-list": "40.0.0", "@udecode/plate-kbd": "40.0.0", diff --git a/packages/plate/src/index.tsx b/packages/plate/src/index.tsx index 71ea309060..915a211469 100644 --- a/packages/plate/src/index.tsx +++ b/packages/plate/src/index.tsx @@ -29,7 +29,6 @@ export * from '@udecode/plate-reset-node'; export * from '@udecode/plate-select'; export * from '@udecode/plate-csv'; export * from '@udecode/plate-docx'; -export * from '@udecode/plate-html'; export * from '@udecode/plate-markdown'; export * from '@udecode/plate-slash-command'; export * from '@udecode/plate-suggestion'; diff --git a/packages/plate/src/react/index.tsx b/packages/plate/src/react/index.tsx index b27328bf63..80e47b5f92 100644 --- a/packages/plate/src/react/index.tsx +++ b/packages/plate/src/react/index.tsx @@ -23,7 +23,6 @@ export * from '@udecode/plate-list/react'; export * from '@udecode/plate-media/react'; export * from '@udecode/plate-reset-node/react'; export * from '@udecode/plate-selection'; -export * from '@udecode/plate-html/react'; export * from '@udecode/plate-suggestion/react'; export * from '@udecode/plate-tabbable/react'; export * from '@udecode/plate-table/react'; diff --git a/yarn.lock b/yarn.lock index f12f8959a7..9380f25bb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6944,25 +6944,6 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-html@npm:40.0.0, @udecode/plate-html@workspace:^, @udecode/plate-html@workspace:packages/html": - version: 0.0.0-use.local - resolution: "@udecode/plate-html@workspace:packages/html" - dependencies: - "@types/papaparse": "npm:^5.3.14" - "@udecode/plate-common": "workspace:^" - html-entities: "npm:^2.5.2" - peerDependencies: - "@udecode/plate-common": ">=40.3.1" - react: ">=16.8.0" - react-dom: ">=16.8.0" - slate: ">=0.112.0" - slate-dom: ">=0.111.0" - slate-history: ">=0.93.0" - slate-hyperscript: ">=0.66.0" - slate-react: ">=0.111.0" - languageName: unknown - linkType: soft - "@udecode/plate-indent-list@npm:40.0.0, @udecode/plate-indent-list@workspace:^, @udecode/plate-indent-list@workspace:packages/indent-list": version: 0.0.0-use.local resolution: "@udecode/plate-indent-list@workspace:packages/indent-list" @@ -7507,7 +7488,6 @@ __metadata: "@udecode/plate-heading": "npm:40.2.6" "@udecode/plate-highlight": "npm:40.0.0" "@udecode/plate-horizontal-rule": "npm:40.0.0" - "@udecode/plate-html": "npm:40.0.0" "@udecode/plate-indent": "npm:40.0.0" "@udecode/plate-indent-list": "npm:40.0.0" "@udecode/plate-kbd": "npm:40.0.0" @@ -22524,7 +22504,6 @@ __metadata: "@udecode/plate-heading": "workspace:^" "@udecode/plate-highlight": "workspace:^" "@udecode/plate-horizontal-rule": "workspace:^" - "@udecode/plate-html": "workspace:^" "@udecode/plate-indent": "workspace:^" "@udecode/plate-indent-list": "workspace:^" "@udecode/plate-juice": "workspace:^"