diff --git a/apps/www/src/app/(app)/dev/page.tsx b/apps/www/src/app/(app)/dev/page.tsx new file mode 100644 index 0000000000..d1c1c4470f --- /dev/null +++ b/apps/www/src/app/(app)/dev/page.tsx @@ -0,0 +1,89 @@ +'use client'; + +import { withProps } from '@udecode/cn'; +import { + BaseBoldPlugin, + BaseCodePlugin, + BaseItalicPlugin, + BaseStrikethroughPlugin, + BaseSubscriptPlugin, + BaseSuperscriptPlugin, + BaseUnderlinePlugin, +} from '@udecode/plate-basic-marks'; +import { BaseBlockquotePlugin } from '@udecode/plate-block-quote'; +import { + BaseCodeBlockPlugin, + BaseCodeLinePlugin, + BaseCodeSyntaxPlugin, +} from '@udecode/plate-code-block'; +import { + BaseParagraphPlugin, + PlateStatic, + createSlateEditor, +} from '@udecode/plate-common'; +import { BaseHeadingPlugin, HEADING_KEYS } from '@udecode/plate-heading'; +import { serializeHtml } from '@udecode/plate-html'; + +import { basicNodesValue } from '@/registry/default/example/values/basic-nodes-value'; +import { BlockquoteStaticElement } from '@/registry/default/plate-ui/blockquote-element'; +import { CodeBlockElementStatic } from '@/registry/default/plate-ui/code-block-element'; +import { CodeStaticLeaf } from '@/registry/default/plate-ui/code-leaf'; +import { CodeLineStaticElement } from '@/registry/default/plate-ui/code-line-element'; +import { CodeSyntaxStaticLeaf } from '@/registry/default/plate-ui/code-syntax-leaf'; +import { HeadingStaticElement } from '@/registry/default/plate-ui/heading-element'; +import { + ParagraphStaticElement, + PlateStaticLeaf, +} from '@/registry/default/plate-ui/paragraph-element'; + +export default function DevPage() { + const editorStatic = createSlateEditor({ + plugins: [ + BaseParagraphPlugin, + BaseHeadingPlugin, + BaseBoldPlugin, + BaseCodePlugin, + BaseItalicPlugin, + BaseStrikethroughPlugin, + BaseSubscriptPlugin, + BaseSuperscriptPlugin, + BaseUnderlinePlugin, + BaseBlockquotePlugin, + BaseCodeBlockPlugin, + ], + staticComponents: { + [BaseBlockquotePlugin.key]: BlockquoteStaticElement, + [BaseBoldPlugin.key]: withProps(PlateStaticLeaf, { as: 'strong' }), + [BaseCodeBlockPlugin.key]: CodeBlockElementStatic, + [BaseCodeLinePlugin.key]: CodeLineStaticElement, + [BaseCodePlugin.key]: CodeStaticLeaf, + [BaseCodeSyntaxPlugin.key]: CodeSyntaxStaticLeaf, + [BaseItalicPlugin.key]: withProps(PlateStaticLeaf, { as: 'em' }), + [BaseParagraphPlugin.key]: ParagraphStaticElement, + [BaseStrikethroughPlugin.key]: withProps(PlateStaticLeaf, { as: 'del' }), + [BaseSubscriptPlugin.key]: withProps(PlateStaticLeaf, { as: 'sub' }), + [BaseSuperscriptPlugin.key]: withProps(PlateStaticLeaf, { as: 'sup' }), + [BaseUnderlinePlugin.key]: withProps(PlateStaticLeaf, { as: 'u' }), + [HEADING_KEYS.h1]: withProps(HeadingStaticElement, { variant: 'h1' }), + [HEADING_KEYS.h2]: withProps(HeadingStaticElement, { variant: 'h2' }), + [HEADING_KEYS.h3]: withProps(HeadingStaticElement, { variant: 'h3' }), + [HEADING_KEYS.h4]: withProps(HeadingStaticElement, { variant: 'h4' }), + [HEADING_KEYS.h5]: withProps(HeadingStaticElement, { variant: 'h5' }), + [HEADING_KEYS.h6]: withProps(HeadingStaticElement, { variant: 'h6' }), + }, + value: [...basicNodesValue], + }); + + const html = serializeHtml(editorStatic, { + convertNewLinesToHtmlBr: true, + nodes: editorStatic.children, + stripWhitespace: true, + }); + console.log('🚀 ~ DevPage ~ html:', html); + + return ( +
+ +
+ ); +} diff --git a/apps/www/src/registry/default/plate-ui/blockquote-element.tsx b/apps/www/src/registry/default/plate-ui/blockquote-element.tsx index f6fa8a208e..3244c16f4e 100644 --- a/apps/www/src/registry/default/plate-ui/blockquote-element.tsx +++ b/apps/www/src/registry/default/plate-ui/blockquote-element.tsx @@ -2,6 +2,8 @@ import React from 'react'; +import type { StaticElementProps } from '@udecode/plate-common'; + import { cn, withRef } from '@udecode/cn'; import { PlateElement } from './plate-element'; @@ -20,3 +22,11 @@ export const BlockquoteElement = withRef( ); } ); + +export const BlockquoteStaticElement = (props: StaticElementProps) => { + return ( +
+ {props.children} +
+ ); +}; diff --git a/apps/www/src/registry/default/plate-ui/code-block-element.tsx b/apps/www/src/registry/default/plate-ui/code-block-element.tsx index afc18a529e..b6980a2011 100644 --- a/apps/www/src/registry/default/plate-ui/code-block-element.tsx +++ b/apps/www/src/registry/default/plate-ui/code-block-element.tsx @@ -2,38 +2,56 @@ import React from 'react'; -import { cn, withRef } from '@udecode/cn'; -import { useCodeBlockElementState } from '@udecode/plate-code-block/react'; +import type { TCodeBlockElement } from '@udecode/plate-code-block'; +import type { StaticElementProps } from '@udecode/plate-common'; -import { CodeBlockCombobox } from './code-block-combobox'; -import { PlateElement } from './plate-element'; +import { cn } from '@udecode/cn'; import './code-block-element.css'; -export const CodeBlockElement = withRef( - ({ children, className, ...props }, ref) => { - const { element } = props; - const state = useCodeBlockElementState({ element }); - - return ( - -
-          {children}
-        
- - {state.syntax && ( -
- -
- )} -
- ); - } -); +// export const CodeBlockElement = withRef( +// ({ children, className, ...props }, ref) => { +// const { element } = props; + +// const state = useCodeBlockElementState({ element }); + +// return ( +// +//
+//           {children}
+//         
+ +// {state.syntax && ( +//
+// +//
+// )} +//
+// ); +// } +// ); + +export const CodeBlockElementStatic = ( + props: StaticElementProps +) => { + const { attributes, children, element } = props; + + const codeClassName = element?.lang + ? `${element.lang} language-${element.lang}` + : ''; + + return ( +
+
+        {children}
+      
+
+ ); +}; diff --git a/apps/www/src/registry/default/plate-ui/code-leaf.tsx b/apps/www/src/registry/default/plate-ui/code-leaf.tsx index dd0c48a2fd..e1d3975395 100644 --- a/apps/www/src/registry/default/plate-ui/code-leaf.tsx +++ b/apps/www/src/registry/default/plate-ui/code-leaf.tsx @@ -2,6 +2,8 @@ import React from 'react'; +import type { StaticLeafProps } from '@udecode/plate-common'; + import { cn, withRef } from '@udecode/cn'; import { PlateLeaf } from '@udecode/plate-common/react'; @@ -22,3 +24,13 @@ export const CodeLeaf = withRef( ); } ); + +export const CodeStaticLeaf = (props: StaticLeafProps) => { + return ( + + + {props.children} + + + ); +}; diff --git a/apps/www/src/registry/default/plate-ui/code-line-element.tsx b/apps/www/src/registry/default/plate-ui/code-line-element.tsx index b041b5256f..540f4cb525 100644 --- a/apps/www/src/registry/default/plate-ui/code-line-element.tsx +++ b/apps/www/src/registry/default/plate-ui/code-line-element.tsx @@ -2,6 +2,8 @@ import React from 'react'; +import type { StaticElementProps } from '@udecode/plate-common'; + import { withRef } from '@udecode/cn'; import { PlateElement } from './plate-element'; @@ -9,3 +11,9 @@ import { PlateElement } from './plate-element'; export const CodeLineElement = withRef((props, ref) => ( )); + +export const CodeLineStaticElement = (props: StaticElementProps) => { + const { children } = props; + + return
{children}
; +}; diff --git a/apps/www/src/registry/default/plate-ui/code-syntax-leaf.tsx b/apps/www/src/registry/default/plate-ui/code-syntax-leaf.tsx index 8cbf8bcbbf..d9b455250c 100644 --- a/apps/www/src/registry/default/plate-ui/code-syntax-leaf.tsx +++ b/apps/www/src/registry/default/plate-ui/code-syntax-leaf.tsx @@ -2,6 +2,8 @@ import React from 'react'; +import type { StaticLeafProps } from '@udecode/plate-core'; + import { withRef } from '@udecode/cn'; import { useCodeSyntaxLeaf } from '@udecode/plate-code-block/react'; import { PlateLeaf } from '@udecode/plate-common/react'; @@ -19,3 +21,7 @@ export const CodeSyntaxLeaf = withRef( ); } ); + +export function CodeSyntaxStaticLeaf({ children, ...props }: StaticLeafProps) { + return
{children}
; +} diff --git a/apps/www/src/registry/default/plate-ui/editor.tsx b/apps/www/src/registry/default/plate-ui/editor.tsx index f89f0a26ea..8a239e082c 100644 --- a/apps/www/src/registry/default/plate-ui/editor.tsx +++ b/apps/www/src/registry/default/plate-ui/editor.tsx @@ -13,7 +13,7 @@ import { } from '@udecode/plate-common/react'; import { cva } from 'class-variance-authority'; -const editorContainerVariants = cva( +export const editorContainerVariants = cva( 'relative w-full cursor-text overflow-y-auto caret-primary selection:bg-brand/25 focus-visible:outline-none [&_.slate-selection-area]:border [&_.slate-selection-area]:border-brand/25 [&_.slate-selection-area]:bg-brand/15', { defaultVariants: { @@ -57,7 +57,7 @@ export const EditorContainer = ({ EditorContainer.displayName = 'EditorContainer'; -const editorVariants = cva( +export const editorVariants = cva( cn( 'group/editor', 'relative w-full overflow-x-hidden whitespace-pre-wrap break-words', diff --git a/apps/www/src/registry/default/plate-ui/heading-element.tsx b/apps/www/src/registry/default/plate-ui/heading-element.tsx index 9386d1df2d..495fdfeea6 100644 --- a/apps/www/src/registry/default/plate-ui/heading-element.tsx +++ b/apps/www/src/registry/default/plate-ui/heading-element.tsx @@ -2,6 +2,8 @@ import React from 'react'; +import type { StaticElementProps } from '@udecode/plate-common'; + import { withRef, withVariants } from '@udecode/cn'; import { cva } from 'class-variance-authority'; @@ -38,3 +40,18 @@ export const HeadingElement = withRef( ); } ); + +interface HeadingElementViewProps extends StaticElementProps { + variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; +} + +export const HeadingStaticElement = ({ + children, + variant = 'h1', +}: HeadingElementViewProps) => { + const Component = variant as any; + + return ( + {children} + ); +}; diff --git a/apps/www/src/registry/default/plate-ui/paragraph-element.tsx b/apps/www/src/registry/default/plate-ui/paragraph-element.tsx index a9388efb0c..a2dc862149 100644 --- a/apps/www/src/registry/default/plate-ui/paragraph-element.tsx +++ b/apps/www/src/registry/default/plate-ui/paragraph-element.tsx @@ -2,6 +2,11 @@ import React from 'react'; +import type { + StaticElementProps, + StaticLeafProps, +} from '@udecode/plate-common'; + import { cn } from '@udecode/cn'; import { withRef } from '@udecode/plate-common/react'; @@ -20,3 +25,13 @@ export const ParagraphElement = withRef( ); } ); + +export const ParagraphStaticElement = ({ children }: StaticElementProps) => { + return
{children}
; +}; + +export function PlateStaticLeaf({ as, children }: StaticLeafProps) { + const Leaf = (as ?? 'span') as any; + + return {children}; +} diff --git a/packages/core/src/lib/editor/SlateEditor.ts b/packages/core/src/lib/editor/SlateEditor.ts index b85defbf13..aaaf86eb4f 100644 --- a/packages/core/src/lib/editor/SlateEditor.ts +++ b/packages/core/src/lib/editor/SlateEditor.ts @@ -17,6 +17,7 @@ import type { InjectNodeProps, } from '../plugin/SlatePlugin'; import type { CorePlugin } from '../plugins'; +import type { NodeComponent } from './withSlate'; export type BaseEditor = TEditor & { key: any; @@ -98,6 +99,7 @@ export type SlateEditor = BaseEditor & { plugins: Record; + staticComponents: Record; // Alias for transforms tf: SlateEditor['transforms']; transforms: UnionToIntersection>; diff --git a/packages/core/src/lib/editor/withSlate.ts b/packages/core/src/lib/editor/withSlate.ts index 869f39d3ae..c94ad1b025 100644 --- a/packages/core/src/lib/editor/withSlate.ts +++ b/packages/core/src/lib/editor/withSlate.ts @@ -19,6 +19,11 @@ import { getPluginType, getSlatePlugin } from '../plugin/getSlatePlugin'; import { type CorePlugin, getCorePlugins } from '../plugins/getCorePlugins'; import { pipeNormalizeInitialValue } from '../utils/pipeNormalizeInitialValue'; import { resolvePlugins } from '../utils/resolvePlugins'; +import { resolveStaticPlugin } from '../utils/resolveStaticPlugin'; + +export type NodeComponent = React.FC; + +export type StaticComponents = Record; export type BaseWithSlateOptions

= { id?: any; @@ -49,6 +54,8 @@ export type BaseWithSlateOptions

= { * @default false */ shouldNormalizeEditor?: boolean; + + staticComponents?: Record; }; export type WithSlateOptions< @@ -96,6 +103,7 @@ export const withSlate = < rootPlugin, selection, shouldNormalizeEditor, + staticComponents, value, ...pluginConfig }: WithSlateOptions = {} @@ -188,6 +196,8 @@ export const withSlate = < resolvePlugins(editor, [rootPluginInstance]); + resolveStaticPlugin(editor, staticComponents ?? {}); + if (typeof value === 'string') { editor.children = editor.api.html.deserialize({ element: value }) as Value; } else if (typeof value === 'function') { diff --git a/packages/core/src/lib/index.ts b/packages/core/src/lib/index.ts index 03abca7e8f..5a9a047735 100644 --- a/packages/core/src/lib/index.ts +++ b/packages/core/src/lib/index.ts @@ -6,6 +6,7 @@ export * from './editor/index'; export * from './libs/index'; export * from './plugin/index'; export * from './plugins/index'; +export * from './static/index'; export * from './transforms/index'; export * from './types/index'; export * from './utils/index'; diff --git a/packages/core/src/lib/plugin/BasePlugin.ts b/packages/core/src/lib/plugin/BasePlugin.ts index 754ae64a13..c98577df36 100644 --- a/packages/core/src/lib/plugin/BasePlugin.ts +++ b/packages/core/src/lib/plugin/BasePlugin.ts @@ -2,6 +2,7 @@ import type { TElement, TText } from '@udecode/slate'; import type { AnyObject } from '@udecode/utils'; import type { SetImmerState, StoreApi } from 'zustand-x'; +import type { NodeComponent } from '../editor'; import type { Nullable } from '../types'; export type BasePlugin = { @@ -171,6 +172,8 @@ export type BasePluginNode = { * void. */ isVoid?: boolean; + + staticComponent?: NodeComponent; }; export type BaseSerializer = AnyObject; diff --git a/packages/core/src/lib/static/PlateStatic.tsx b/packages/core/src/lib/static/PlateStatic.tsx new file mode 100644 index 0000000000..b99c0d9c33 --- /dev/null +++ b/packages/core/src/lib/static/PlateStatic.tsx @@ -0,0 +1,106 @@ +/* eslint-disable react/no-children-prop */ +import React from 'react'; + +import type { RenderElementFn, RenderLeafFn } from '@udecode/slate-react'; +import type { + EditableProps, + RenderElementProps, + RenderLeafProps, +} from 'slate-react/dist/components/editable'; + +import { + type TDescendant, + type TElement, + type TText, + isElement, +} from '@udecode/slate'; + +import type { SlateEditor } from '..'; + +import { pipeRenderStaticElement } from './pipeRenderStaticElement'; +import { pipeRenderStaticLeaf } from './pipeRenderStaticLeaf'; + +export type ChildrenProps = { + children: TDescendant[]; + editor: SlateEditor; +}; + +export type ElementProps = { + editor: SlateEditor; + element: TElement; +}; + +export type LeafProps = { + editor: SlateEditor; + leaf: TText; +}; + +export type PlateViewContextProps = { + editor: SlateEditor; + renderElement: RenderElementFn; + renderLeaf: RenderLeafFn; +}; + +export type PlateViewProps = { + editor: SlateEditor; + renderElement?: EditableProps['renderElement']; + renderLeaf?: EditableProps['renderLeaf']; +}; + +function Element({ + editor, + element = { children: [], type: '' }, +}: ElementProps) { + const renderElement = pipeRenderStaticElement(editor); + + return ( + + {renderElement?.({ + attributes: {} as any, + children: ( + + ), + element, + })} + + ); +} + +function Leaf({ editor, leaf = { text: '' } }: LeafProps) { + const renderLeaf = pipeRenderStaticLeaf(editor); + + return renderLeaf!({ + attributes: {} as any, + children: {leaf.text === '' ? '\uFEFF' : leaf.text}, + leaf, + text: leaf, + }); +} + +function PlateViewContent({ children = [], editor }: ChildrenProps) { + return ( + + {children.map((child, i) => { + return isElement(child) ? ( + + ) : ( + + ); + })} + + ); +} + +export function PlateStatic(props: PlateViewProps) { + const { editor } = props; + + return ; +} + +export function DefaultStaticElement({ children }: RenderElementProps) { + return

{children}
; +} + +export function DefaultStaticLeaf({ children }: RenderLeafProps) { + return {children}; +} diff --git a/packages/core/src/lib/static/index.ts b/packages/core/src/lib/static/index.ts new file mode 100644 index 0000000000..3931eaec9a --- /dev/null +++ b/packages/core/src/lib/static/index.ts @@ -0,0 +1,7 @@ +/** + * @file Automatically generated by barrelsby. + */ + +export * from './PlateStatic'; +export * from './pipeRenderStaticElement'; +export * from './pipeRenderStaticLeaf'; diff --git a/packages/core/src/lib/static/pipeRenderStaticElement.tsx b/packages/core/src/lib/static/pipeRenderStaticElement.tsx new file mode 100644 index 0000000000..f07250e9bc --- /dev/null +++ b/packages/core/src/lib/static/pipeRenderStaticElement.tsx @@ -0,0 +1,83 @@ +import React from 'react'; + +import type { TElement } from '@udecode/slate'; +import type { TEditableProps, TRenderElementProps } from '@udecode/slate-react'; + +import type { SlateEditor } from '../editor'; +import type { SlatePlugin } from '../plugin'; + +import { DefaultStaticElement } from './PlateStatic'; + +export type RenderElement = ( + props: TRenderElementProps +) => React.ReactElement | undefined; + +export interface StaticElementProps { + attributes?: Record; + children?: React.ReactNode; + element?: T; +} + +const pluginRenderStaticElement = ( + editor: SlateEditor, + plugin: SlatePlugin +): RenderElement => + function render(nodeProps) { + if (nodeProps.element.type === plugin.node.type) { + const { children, element } = nodeProps; + + const Element = plugin.node.staticComponent ?? DefaultStaticElement; + + const component = ( + + {children} + + ); + + return component; + } + }; + +/** @see {@link RenderElement} */ +export const pipeRenderStaticElement = ( + editor: SlateEditor, + renderElementProp?: TEditableProps['renderElement'] +): TEditableProps['renderElement'] => { + const renderElements: RenderElement[] = []; + + editor.pluginList.forEach((plugin) => { + if (plugin.node.isElement) { + renderElements.push(pluginRenderStaticElement(editor, plugin)); + } + }); + + return function render(props) { + let element; + + renderElements.some((renderElement) => { + element = renderElement(props as any); + + return !!element; + }); + + if (element) return element; + if (renderElementProp) { + return renderElementProp(props); + } + + return ( + + {props.children} + + ); + }; +}; diff --git a/packages/core/src/lib/static/pipeRenderStaticLeaf.tsx b/packages/core/src/lib/static/pipeRenderStaticLeaf.tsx new file mode 100644 index 0000000000..b5aa14bb0a --- /dev/null +++ b/packages/core/src/lib/static/pipeRenderStaticLeaf.tsx @@ -0,0 +1,72 @@ +import React from 'react'; + +import type { TText } from '@udecode/slate'; +import type { TEditableProps, TRenderLeafProps } from '@udecode/slate-react'; + +import type { SlateEditor } from '../editor'; +import type { SlatePlugin } from '../plugin'; + +import { DefaultStaticLeaf } from './PlateStatic'; + +export type RenderLeaf = ( + props: TRenderLeafProps +) => React.ReactElement | undefined; + +export interface StaticLeafProps { + as?: React.ElementType; + children?: React.ReactNode; + leaf?: T; +} + +export const pluginRenderStaticLeaf = ( + editor: SlateEditor, + plugin: SlatePlugin +): RenderLeaf => + function render(nodeProps) { + const { + node: { staticComponent }, + } = plugin; + const { children, leaf } = nodeProps; + + if (leaf[plugin.node.type ?? plugin.key]) { + const Leaf = staticComponent ?? DefaultStaticLeaf; + + return ( + + {children} + + ); + } + + return children; + }; + +/** @see {@link RenderLeaf} */ +export const pipeRenderStaticLeaf = ( + editor: SlateEditor, + renderLeafProp?: TEditableProps['renderLeaf'] +): TEditableProps['renderLeaf'] => { + const renderLeafs: RenderLeaf[] = []; + + editor.pluginList.forEach((plugin) => { + if (plugin.node.isLeaf && plugin.key) { + renderLeafs.push(pluginRenderStaticLeaf(editor, plugin)); + } + }); + + return function render(props) { + renderLeafs.forEach((renderLeaf) => { + const newChildren = renderLeaf(props as any); + + if (newChildren !== undefined) { + props.children = newChildren; + } + }); + + if (renderLeafProp) { + return renderLeafProp(props); + } + + return ; + }; +}; diff --git a/packages/core/src/lib/utils/index.ts b/packages/core/src/lib/utils/index.ts index 146909dcc2..5f017e3b46 100644 --- a/packages/core/src/lib/utils/index.ts +++ b/packages/core/src/lib/utils/index.ts @@ -18,4 +18,5 @@ export * from './pipeTransformFragment'; export * from './resolveCreatePluginTest'; export * from './resolvePlugin'; export * from './resolvePlugins'; +export * from './resolveStaticPlugin'; export * from './misc/index'; diff --git a/packages/core/src/lib/utils/resolveStaticPlugin.ts b/packages/core/src/lib/utils/resolveStaticPlugin.ts new file mode 100644 index 0000000000..c3212751ed --- /dev/null +++ b/packages/core/src/lib/utils/resolveStaticPlugin.ts @@ -0,0 +1,17 @@ +import type { SlateEditor, StaticComponents } from '../editor'; +import type { SlatePlugin } from '../plugin'; + +export const resolveStaticPlugin = ( + editor: SlateEditor, + staticComponents: StaticComponents +) => { + editor.staticComponents = staticComponents; + + editor.pluginList.forEach((plugin: SlatePlugin) => { + const component = staticComponents[plugin.key]; + + if (component) { + plugin.node.staticComponent = component; + } + }); +}; diff --git a/packages/core/src/react/editor/PlateEditor.ts b/packages/core/src/react/editor/PlateEditor.ts index fc5663300b..645b319cfe 100644 --- a/packages/core/src/react/editor/PlateEditor.ts +++ b/packages/core/src/react/editor/PlateEditor.ts @@ -8,6 +8,7 @@ import type { InferApi, InferOptions, InferTransforms, + NodeComponent, PluginConfig, WithRequiredKey, } from '../../lib'; @@ -67,6 +68,7 @@ export type PlateEditor = { plugins: Record; shortcuts: Shortcuts; + staticComponents: Record; // Alias for transforms tf: PlateEditor['transforms']; diff --git a/packages/html/src/lib/index.ts b/packages/html/src/lib/index.ts index 4fe01f0cee..5f34b1610f 100644 --- a/packages/html/src/lib/index.ts +++ b/packages/html/src/lib/index.ts @@ -3,6 +3,7 @@ */ export * from './newLinesToHtmlBr'; +export * from './serializeHtml'; export * from './stripClassNames'; export * from './stripSlateDataAttributes'; export * from './trimWhitespace'; diff --git a/packages/html/src/lib/leaf2html.ts b/packages/html/src/lib/leaf2html.ts new file mode 100644 index 0000000000..e32695e397 --- /dev/null +++ b/packages/html/src/lib/leaf2html.ts @@ -0,0 +1,131 @@ +import type { SlateEditor, SlatePlugin } from '@udecode/plate-common'; +import type { TRenderLeafProps } from '@udecode/plate-common/react'; + +import { decode } from 'html-entities'; + +// 处理属性 +const serializeAttributes = (attrs: Record): string => { + return Object.entries(attrs) + .filter(([_, value]) => value != null) + .map(([key, value]) => `${key}="${value}"`) + .join(' '); +}; + +// 将组件props转换为HTML属性 +const propsToAttributes = (props: any): Record => { + const attributes: Record = {}; + + Object.entries(props).forEach(([key, value]) => { + // 处理文本节点的特殊属性 + if (key === 'leaf') { + // 从leaf中提取样式属性 + Object.entries(value).forEach(([leafKey, leafValue]) => { + if (typeof leafValue === 'boolean' && leafValue) { + switch (leafKey) { + case 'bold': { + attributes.style = + (attributes.style || '') + 'font-weight: bold;'; + + break; + } + case 'italic': { + attributes.style = + (attributes.style || '') + 'font-style: italic;'; + + break; + } + case 'strikethrough': { + attributes.style = + (attributes.style || '') + 'text-decoration: line-through;'; + + break; + } + case 'underline': { + attributes.style = + (attributes.style || '') + 'text-decoration: underline;'; + + break; + } + // 可以添加更多文本样式处理 + } + } + }); + } else if (key === 'attributes') { + // 合并直接的HTML属性 + Object.assign(attributes, value); + } + }); + + return attributes; +}; + +// 渲染静态文本组件 +const renderStaticLeaf = (Component: any, props: any): string => { + const attributes = propsToAttributes(props); + const attributeString = serializeAttributes(attributes); + const children = props.children || ''; + + return attributeString + ? `${children}` + : `${children}`; +}; + +// 增强的leafToHtml函数 +const leafToHtml = ( + editor: SlateEditor, + { props }: { props: TRenderLeafProps } +): string => { + const { leaf } = props; + let html = ''; + + // 查找匹配的插件 + editor.pluginList.some((plugin: SlatePlugin) => { + if (!plugin.node.staticComponent || !plugin.node.isLeaf) { + return false; + } + + try { + // 创建叶子节点的props + const leafProps = { + attributes: props.attributes, + children: props.children, + leaf, + text: props.text, + }; + + // 使用插件的静态组件进行渲染 + const Component = plugin.node.staticComponent; + html = decode(renderStaticLeaf(Component, leafProps)); + + return true; + } catch (error) { + console.error('Error rendering leaf component:', error); + + return false; + } + }); + + // 如果没有找到匹配的插件,使用默认渲染 + if (!html) { + const defaultProps = { + attributes: props.attributes || {}, + children: props.children, + leaf, + }; + + // 处理默认的文本修饰 + if (leaf) { + if (leaf.bold) defaultProps.attributes['data-slate-bold'] = 'true'; + if (leaf.italic) defaultProps.attributes['data-slate-italic'] = 'true'; + if (leaf.underline) + defaultProps.attributes['data-slate-underline'] = 'true'; + if (leaf.code) defaultProps.attributes['data-slate-code'] = 'true'; + } + + html = renderStaticLeaf(null, defaultProps); + } + + return html; +}; + +export { leafToHtml }; diff --git a/packages/html/src/lib/serializeHtml.ts b/packages/html/src/lib/serializeHtml.ts new file mode 100644 index 0000000000..d6a3f87d08 --- /dev/null +++ b/packages/html/src/lib/serializeHtml.ts @@ -0,0 +1,185 @@ +import React from 'react'; + +import type { + TRenderElementProps, + TRenderLeafProps, +} from '@udecode/plate-common/react'; + +import { + type SlateEditor, + type SlatePlugin, + type TDescendant, + isText, +} from '@udecode/plate-common'; +import { decode, encode } from 'html-entities'; +import ReactDOMServer from 'react-dom/server'; + +import { newLinesToHtmlBr } from './newLinesToHtmlBr'; +import { stripClassNames } from './stripClassNames'; + +// 处理叶子节点 +const leafToHtml = ( + editor: SlateEditor, + { props }: { props: TRenderLeafProps } +): string => { + const { children, leaf } = props; + + let html = ''; + + editor.pluginList.some((plugin: SlatePlugin) => { + if (!plugin.node.isLeaf) return false; + + console.log(plugin, 'fj'); + + if (leaf[plugin.key]) { + const Component = plugin.node.staticComponent!; + + const elementProps = { + attributes: props.attributes, + children, + leaf, + }; + + html = decode( + ReactDOMServer.renderToStaticMarkup( + React.createElement(Component, elementProps) + ) + ); + + return true; + } + + return false; + }); + + return html || `${leaf.text}`; +}; + +// 处理元素节点 +const elementToHtml = ( + editor: SlateEditor, + { + preserveClassNames, + props, + }: { + props: TRenderElementProps; + preserveClassNames?: string[]; + } +): string => { + const { children, element } = props; + + if (!element.type) { + return ReactDOMServer.renderToStaticMarkup( + React.createElement('div', null, children) + ); + } + + let html = ''; + + editor.pluginList.some((plugin: SlatePlugin) => { + if ( + !plugin.node.staticComponent || + props.element.type !== plugin.node.type + ) { + return false; + } + + try { + const Component = plugin.node.staticComponent; + const elementProps = { + attributes: props.attributes, + children, + element, + }; + + html = decode( + ReactDOMServer.renderToStaticMarkup( + React.createElement(Component, elementProps) + ) + ); + + if (preserveClassNames) { + html = stripClassNames(html, { preserveClassNames }); + } + + return true; + } catch (error) { + console.error( + `Error rendering plugin component for type ${element.type}:`, + error + ); + + return false; + } + }); + + return ( + html || + ReactDOMServer.renderToStaticMarkup( + React.createElement('div', null, children) + ) + ); +}; + +// 主序列化函数 +export const serializeHtml = ( + editor: SlateEditor, + { + convertNewLinesToHtmlBr = true, + nodes, + preserveClassNames, + stripWhitespace = true, + }: { + convertNewLinesToHtmlBr: boolean; + nodes: TDescendant[]; + stripWhitespace: boolean; + preserveClassNames?: string[]; + } +): string => { + try { + const result = nodes + .map((node) => { + if (isText(node)) { + const textContent = encode(node.text); + const children = convertNewLinesToHtmlBr + ? newLinesToHtmlBr(textContent) + : textContent; + + return leafToHtml(editor, { + props: { + attributes: { 'data-slate-leaf': true }, + children, + leaf: node, + text: node, + }, + }); + } + + const childrenHtml = serializeHtml(editor, { + convertNewLinesToHtmlBr, + nodes: node.children as TDescendant[], + preserveClassNames, + stripWhitespace, + }); + + return elementToHtml(editor, { + preserveClassNames, + props: { + attributes: { + 'data-slate-node': 'element', + ref: null, + }, + children: childrenHtml, + element: node, + }, + }); + }) + .join(''); + + return stripWhitespace ? result.trim() : result; + } catch (error) { + console.error('Error in serializeHtml:', error); + + return ''; + } +}; diff --git a/packages/markdown/src/lib/remark-slate/index.ts b/packages/markdown/src/lib/remark-slate/index.ts index 6271256236..9350f682b1 100644 --- a/packages/markdown/src/lib/remark-slate/index.ts +++ b/packages/markdown/src/lib/remark-slate/index.ts @@ -2,10 +2,11 @@ * @file Automatically generated by barrelsby. */ +export * from './remarkDefaultCompiler'; export * from './remarkDefaultElementRules'; export * from './remarkDefaultTextRules'; -export * from './remarkSplitLineBreaksCompiler'; export * from './remarkPlugin'; +export * from './remarkSplitLineBreaksCompiler'; export * from './remarkTextTypes'; export * from './remarkTransformElement'; export * from './remarkTransformElementChildren'; diff --git a/yarn.lock b/yarn.lock index e47c9970e7..b513c71a5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6370,7 +6370,7 @@ __metadata: version: 0.0.0-use.local resolution: "@udecode/cn@workspace:packages/cn" dependencies: - "@udecode/react-utils": "npm:39.0.0" + "@udecode/react-utils": "npm:40.2.8" peerDependencies: class-variance-authority: ">=0.7.0" react: ">=16.8.0" @@ -6385,7 +6385,7 @@ __metadata: dependencies: "@udecode/plate-combobox": "npm:40.0.0" "@udecode/plate-markdown": "npm:40.2.2" - "@udecode/plate-selection": "npm:40.1.0" + "@udecode/plate-selection": "npm:40.2.9" ai: "npm:^3.4.10" lodash: "npm:^4.17.21" peerDependencies: @@ -6406,7 +6406,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6424,7 +6424,7 @@ __metadata: "@udecode/plate-common": "workspace:^" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6444,7 +6444,7 @@ __metadata: "@udecode/plate-common": "workspace:^" "@udecode/plate-heading": "npm:40.2.6" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6461,7 +6461,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6478,7 +6478,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6495,7 +6495,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6512,7 +6512,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6530,7 +6530,7 @@ __metadata: "@udecode/plate-common": "workspace:^" react-textarea-autosize: "npm:^8.5.3" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6550,7 +6550,7 @@ __metadata: delay: "npm:5.0.0" p-defer: "npm:^4.0.1" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6568,7 +6568,7 @@ __metadata: "@udecode/plate-common": "workspace:^" prismjs: "npm:^1.29.0" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6585,7 +6585,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6603,7 +6603,7 @@ __metadata: "@udecode/plate-common": "workspace:^" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6614,17 +6614,17 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-common@npm:40.0.3, @udecode/plate-common@workspace:^, @udecode/plate-common@workspace:packages/common": +"@udecode/plate-common@npm:40.2.8, @udecode/plate-common@workspace:^, @udecode/plate-common@workspace:packages/common": version: 0.0.0-use.local resolution: "@udecode/plate-common@workspace:packages/common" dependencies: - "@udecode/plate-core": "npm:40.0.3" - "@udecode/plate-utils": "npm:40.0.3" + "@udecode/plate-core": "npm:40.2.8" + "@udecode/plate-utils": "npm:40.2.8" "@udecode/react-hotkeys": "npm:37.0.0" - "@udecode/react-utils": "npm:39.0.0" + "@udecode/react-utils": "npm:40.2.8" "@udecode/slate": "npm:39.2.1" - "@udecode/slate-react": "npm:40.0.0" - "@udecode/slate-utils": "npm:39.2.20" + "@udecode/slate-react": "npm:40.2.8" + "@udecode/slate-utils": "npm:40.2.7" "@udecode/utils": "npm:37.0.0" peerDependencies: react: ">=16.8.0" @@ -6637,15 +6637,15 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-core@npm:40.0.3, @udecode/plate-core@workspace:^, @udecode/plate-core@workspace:packages/core": +"@udecode/plate-core@npm:40.2.8, @udecode/plate-core@workspace:^, @udecode/plate-core@workspace:packages/core": version: 0.0.0-use.local resolution: "@udecode/plate-core@workspace:packages/core" dependencies: "@udecode/react-hotkeys": "npm:37.0.0" - "@udecode/react-utils": "npm:39.0.0" + "@udecode/react-utils": "npm:40.2.8" "@udecode/slate": "npm:39.2.1" - "@udecode/slate-react": "npm:40.0.0" - "@udecode/slate-utils": "npm:39.2.20" + "@udecode/slate-react": "npm:40.2.8" + "@udecode/slate-utils": "npm:40.2.7" "@udecode/utils": "npm:37.0.0" clsx: "npm:^2.1.1" is-hotkey: "npm:^0.2.0" @@ -6678,7 +6678,7 @@ __metadata: "@udecode/plate-table": "npm:40.0.0" papaparse: "npm:^5.4.1" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6695,7 +6695,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6712,7 +6712,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.94.0" @@ -6730,7 +6730,7 @@ __metadata: diff-match-patch-ts: "npm:^0.6.0" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6749,7 +6749,7 @@ __metadata: lodash: "npm:^4.17.21" raf: "npm:^3.4.1" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dnd: ">=14.0.0" react-dnd-html5-backend: ">=14.0.0" @@ -6762,7 +6762,7 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-docx@npm:40.2.6, @udecode/plate-docx@workspace:^, @udecode/plate-docx@workspace:packages/docx": +"@udecode/plate-docx@npm:40.2.7, @udecode/plate-docx@workspace:^, @udecode/plate-docx@workspace:packages/docx": version: 0.0.0-use.local resolution: "@udecode/plate-docx@workspace:packages/docx" dependencies: @@ -6770,11 +6770,11 @@ __metadata: "@udecode/plate-heading": "npm:40.2.6" "@udecode/plate-indent": "npm:40.0.0" "@udecode/plate-indent-list": "npm:40.0.0" - "@udecode/plate-media": "npm:40.2.4" + "@udecode/plate-media": "npm:40.2.7" "@udecode/plate-table": "npm:40.0.0" validator: "npm:^13.12.0" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6793,7 +6793,7 @@ __metadata: "@udecode/plate-combobox": "npm:40.0.0" "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6811,7 +6811,7 @@ __metadata: "@excalidraw/excalidraw": "npm:0.16.4" "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6822,13 +6822,13 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-find-replace@npm:40.0.0, @udecode/plate-find-replace@workspace:^, @udecode/plate-find-replace@workspace:packages/find-replace": +"@udecode/plate-find-replace@npm:40.2.8, @udecode/plate-find-replace@workspace:^, @udecode/plate-find-replace@workspace:packages/find-replace": version: 0.0.0-use.local resolution: "@udecode/plate-find-replace@workspace:packages/find-replace" dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6847,7 +6847,7 @@ __metadata: "@floating-ui/react": "npm:^0.26.23" "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6865,7 +6865,7 @@ __metadata: "@udecode/plate-common": "workspace:^" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6882,7 +6882,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6899,7 +6899,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6916,7 +6916,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6935,7 +6935,7 @@ __metadata: "@udecode/plate-common": "workspace:^" html-entities: "npm:^2.5.2" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6955,7 +6955,7 @@ __metadata: "@udecode/plate-list": "npm:40.0.0" clsx: "npm:^2.1.1" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6972,7 +6972,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -6990,7 +6990,7 @@ __metadata: "@udecode/plate-common": "workspace:^" juice: "npm:^8.1.0" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7007,7 +7007,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7024,7 +7024,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7041,7 +7041,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7060,7 +7060,7 @@ __metadata: "@udecode/plate-floating": "npm:40.0.0" "@udecode/plate-normalizers": "npm:40.0.0" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7079,7 +7079,7 @@ __metadata: "@udecode/plate-reset-node": "npm:40.0.0" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7100,7 +7100,7 @@ __metadata: remark-parse: "npm:^11.0.0" unified: "npm:^11.0.5" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7119,7 +7119,7 @@ __metadata: "@udecode/plate-common": "workspace:^" katex: "npm:0.16.11" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7130,14 +7130,14 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-media@npm:40.2.4, @udecode/plate-media@workspace:^, @udecode/plate-media@workspace:packages/media": +"@udecode/plate-media@npm:40.2.7, @udecode/plate-media@workspace:^, @udecode/plate-media@workspace:packages/media": version: 0.0.0-use.local resolution: "@udecode/plate-media@workspace:packages/media" dependencies: "@udecode/plate-common": "workspace:^" js-video-url-parser: "npm:^0.5.1" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7155,7 +7155,7 @@ __metadata: "@udecode/plate-combobox": "npm:40.0.0" "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7173,7 +7173,7 @@ __metadata: "@udecode/plate-common": "workspace:^" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7191,7 +7191,7 @@ __metadata: "@udecode/plate-common": "workspace:^" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7209,7 +7209,7 @@ __metadata: "@udecode/plate-common": "workspace:^" peerDependencies: "@playwright/test": ">=1.42.1" - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7226,7 +7226,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7243,7 +7243,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7260,7 +7260,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7271,14 +7271,14 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-selection@npm:40.1.0, @udecode/plate-selection@workspace:^, @udecode/plate-selection@workspace:packages/selection": +"@udecode/plate-selection@npm:40.2.9, @udecode/plate-selection@workspace:^, @udecode/plate-selection@workspace:packages/selection": version: 0.0.0-use.local resolution: "@udecode/plate-selection@workspace:packages/selection" dependencies: "@udecode/plate-common": "workspace:^" copy-to-clipboard: "npm:^3.3.3" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7296,7 +7296,7 @@ __metadata: "@udecode/plate-combobox": "npm:40.0.0" "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7307,7 +7307,7 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-suggestion@npm:40.0.0, @udecode/plate-suggestion@workspace:^, @udecode/plate-suggestion@workspace:packages/suggestion": +"@udecode/plate-suggestion@npm:40.2.8, @udecode/plate-suggestion@workspace:^, @udecode/plate-suggestion@workspace:packages/suggestion": version: 0.0.0-use.local resolution: "@udecode/plate-suggestion@workspace:packages/suggestion" dependencies: @@ -7315,7 +7315,7 @@ __metadata: "@udecode/plate-diff": "npm:40.0.0" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7333,7 +7333,7 @@ __metadata: "@udecode/plate-common": "workspace:^" tabbable: "npm:^6.2.0" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7352,7 +7352,7 @@ __metadata: "@udecode/plate-resizable": "npm:40.0.0" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7368,7 +7368,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7397,7 +7397,7 @@ __metadata: "@udecode/plate-node-id": "npm:40.0.0" lodash: "npm:^4.17.21" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7414,7 +7414,7 @@ __metadata: dependencies: "@udecode/plate-common": "workspace:^" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7425,15 +7425,15 @@ __metadata: languageName: unknown linkType: soft -"@udecode/plate-utils@npm:40.0.3, @udecode/plate-utils@workspace:^, @udecode/plate-utils@workspace:packages/plate-utils": +"@udecode/plate-utils@npm:40.2.8, @udecode/plate-utils@workspace:^, @udecode/plate-utils@workspace:packages/plate-utils": version: 0.0.0-use.local resolution: "@udecode/plate-utils@workspace:packages/plate-utils" dependencies: - "@udecode/plate-core": "npm:40.0.3" - "@udecode/react-utils": "npm:39.0.0" + "@udecode/plate-core": "npm:40.2.8" + "@udecode/react-utils": "npm:40.2.8" "@udecode/slate": "npm:39.2.1" - "@udecode/slate-react": "npm:40.0.0" - "@udecode/slate-utils": "npm:39.2.20" + "@udecode/slate-react": "npm:40.2.8" + "@udecode/slate-utils": "npm:40.2.7" "@udecode/utils": "npm:37.0.0" clsx: "npm:^2.1.1" lodash: "npm:^4.17.21" @@ -7456,7 +7456,7 @@ __metadata: "@udecode/plate-common": "workspace:^" yjs: "npm:^13.6.19" peerDependencies: - "@udecode/plate-common": ">=40.0.3" + "@udecode/plate-common": ">=40.2.8" react: ">=16.8.0" react-dom: ">=16.8.0" slate: ">=0.103.0" @@ -7480,11 +7480,11 @@ __metadata: "@udecode/plate-code-block": "npm:40.0.0" "@udecode/plate-combobox": "npm:40.0.0" "@udecode/plate-comments": "npm:40.0.0" - "@udecode/plate-common": "npm:40.0.3" + "@udecode/plate-common": "npm:40.2.8" "@udecode/plate-csv": "npm:40.0.0" "@udecode/plate-diff": "npm:40.0.0" - "@udecode/plate-docx": "npm:40.2.6" - "@udecode/plate-find-replace": "npm:40.0.0" + "@udecode/plate-docx": "npm:40.2.7" + "@udecode/plate-find-replace": "npm:40.2.8" "@udecode/plate-floating": "npm:40.0.0" "@udecode/plate-font": "npm:40.0.0" "@udecode/plate-heading": "npm:40.2.6" @@ -7499,16 +7499,16 @@ __metadata: "@udecode/plate-link": "npm:40.0.0" "@udecode/plate-list": "npm:40.0.0" "@udecode/plate-markdown": "npm:40.2.2" - "@udecode/plate-media": "npm:40.2.4" + "@udecode/plate-media": "npm:40.2.7" "@udecode/plate-mention": "npm:40.0.0" "@udecode/plate-node-id": "npm:40.0.0" "@udecode/plate-normalizers": "npm:40.0.0" "@udecode/plate-reset-node": "npm:40.0.0" "@udecode/plate-resizable": "npm:40.0.0" "@udecode/plate-select": "npm:40.0.0" - "@udecode/plate-selection": "npm:40.1.0" + "@udecode/plate-selection": "npm:40.2.9" "@udecode/plate-slash-command": "npm:40.0.0" - "@udecode/plate-suggestion": "npm:40.0.0" + "@udecode/plate-suggestion": "npm:40.2.8" "@udecode/plate-tabbable": "npm:40.0.0" "@udecode/plate-table": "npm:40.0.0" "@udecode/plate-toggle": "npm:40.0.0" @@ -7533,7 +7533,7 @@ __metadata: languageName: unknown linkType: soft -"@udecode/react-utils@npm:39.0.0, @udecode/react-utils@workspace:^, @udecode/react-utils@workspace:packages/react-utils": +"@udecode/react-utils@npm:40.2.8, @udecode/react-utils@workspace:^, @udecode/react-utils@workspace:packages/react-utils": version: 0.0.0-use.local resolution: "@udecode/react-utils@workspace:packages/react-utils" dependencies: @@ -7546,11 +7546,11 @@ __metadata: languageName: unknown linkType: soft -"@udecode/slate-react@npm:40.0.0, @udecode/slate-react@workspace:^, @udecode/slate-react@workspace:packages/slate-react": +"@udecode/slate-react@npm:40.2.8, @udecode/slate-react@workspace:^, @udecode/slate-react@workspace:packages/slate-react": version: 0.0.0-use.local resolution: "@udecode/slate-react@workspace:packages/slate-react" dependencies: - "@udecode/react-utils": "npm:39.0.0" + "@udecode/react-utils": "npm:40.2.8" "@udecode/slate": "npm:39.2.1" "@udecode/utils": "npm:37.0.0" peerDependencies: @@ -7562,7 +7562,7 @@ __metadata: languageName: unknown linkType: soft -"@udecode/slate-utils@npm:39.2.20, @udecode/slate-utils@workspace:^, @udecode/slate-utils@workspace:packages/slate-utils": +"@udecode/slate-utils@npm:40.2.7, @udecode/slate-utils@workspace:^, @udecode/slate-utils@workspace:packages/slate-utils": version: 0.0.0-use.local resolution: "@udecode/slate-utils@workspace:packages/slate-utils" dependencies: