@lofcz/platejs-core 53.1.8 → 53.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { Ht as BaseParagraphPlugin, b as NavigationFeedbackPlugin$1, bt as getPluginNodeProps, cn as createSlatePlugin, n as withSlate, ot as DOMPlugin, p as isEditOnly, s as SlateExtensionPlugin, sn as getEditorPlugin$1, tn as getPluginByType, ut as ChunkingPlugin, yt as getSlateClass } from "../withSlate-NVP0S9vL.js";
1
+ import { Ut as BaseParagraphPlugin, bt as getSlateClass, cn as getEditorPlugin$1, dt as ChunkingPlugin, ln as createSlatePlugin, m as isEditOnly, n as withSlate, nn as getPluginByType, s as SlateExtensionPlugin, st as DOMPlugin, x as NavigationFeedbackPlugin$1, xt as getPluginNodeProps } from "../withSlate-pfxNb3FA.js";
2
2
  import { t as Hotkeys } from "../hotkeys-DI1HPO2Q.js";
3
- import { A as pipeInjectNodeProps, C as createStaticEditor, k as pipeDecorate, s as PlateStatic } from "../static-KMalmfNw.js";
3
+ import { A as pipeInjectNodeProps, C as createStaticEditor, k as pipeDecorate, s as PlateStatic } from "../static-C-jR24Fx.js";
4
4
  import { NodeApi, PathApi, createEditor } from "@platejs/slate";
5
5
  import { isDefined } from "@udecode/utils";
6
6
  import { DefaultPlaceholder, Editable, Slate, useComposing, useFocused, useReadOnly, useSelected, useSlateStatic, withReact } from "slate-react";
@@ -1148,10 +1148,9 @@ const pipeRenderLeaf = (editor, renderLeafProp) => {
1148
1148
  }
1149
1149
  props.children = /* @__PURE__ */ React.createElement(Tag, { className }, props.children);
1150
1150
  }
1151
- if (hasActiveComplexRenderLeaf) for (const { key, renderLeaf } of complexRenderLeafEntries) {
1151
+ if (hasActiveComplexRenderLeaf) for (const { key, renderLeaf: RenderLeaf } of complexRenderLeafEntries) {
1152
1152
  if (!leaf[key]) continue;
1153
- const newChildren = renderLeaf(props);
1154
- if (newChildren !== void 0) props.children = newChildren;
1153
+ props.children = /* @__PURE__ */ React.createElement(RenderLeaf, props, props.children);
1155
1154
  }
1156
1155
  leafPropsPlugins.forEach((plugin) => {
1157
1156
  if (props.leaf[plugin.node.type]) {
@@ -1276,10 +1275,9 @@ const pipeRenderText = (editor, renderTextProp) => {
1276
1275
  if (isEditOnly(readOnly, plugin, "render")) continue;
1277
1276
  props.children = /* @__PURE__ */ React.createElement(Tag, { className }, props.children);
1278
1277
  }
1279
- if (hasActiveRenderText) for (const { renderText, textKey } of renderTexts) {
1278
+ if (hasActiveRenderText) for (const { renderText: RenderText, textKey } of renderTexts) {
1280
1279
  if (!text[textKey]) continue;
1281
- const newChildren = renderText(props);
1282
- if (newChildren !== void 0) props.children = newChildren;
1280
+ props.children = /* @__PURE__ */ React.createElement(RenderText, props, props.children);
1283
1281
  }
1284
1282
  textPropsPlugins.forEach((plugin) => {
1285
1283
  if (props.text[plugin.node.type ?? plugin.key]) {
@@ -1,2 +1,2 @@
1
- import { $a as SlateElement, Ao as pluginRenderElementStatic, Ba as pipeDecorate, Co as pipeRenderTextStatic, Do as pluginRenderLeafStatic, Eo as pipeRenderLeafStatic, Ga as getRenderNodeStaticProps, Ha as getSelectedDomNode, Ja as createStaticString, Ka as getNodeDataAttributes, Oo as pipeRenderElementStatic, Qa as getEditorDOMFromHtmlString, Ra as stripSlateDataAttributes, So as SlateRenderText, To as SlateRenderLeaf, Ua as getSelectedDomFragment, Va as isSelectOutside, Wa as getSelectedDomBlocks, Xa as ViewPlugin, Ya as getStaticPlugins, Za as createStaticEditor, _o as serializeHtml, ao as SlateText, bo as PlateStatic, co as StyledSlateLeafProps, do as BoxStaticProps, eo as SlateElementProps, fo as SlateRenderElementProps, go as SerializeHtmlOptions, ho as SlateRenderTextProps, io as SlateNodeProps, ko as SlateRenderElement, lo as StyledSlateTextProps, mo as SlateRenderNodeProps, no as SlateLeaf, oo as SlateTextProps, po as SlateRenderLeafProps, qa as getPluginDataAttributes, ro as SlateLeafProps, so as StyledSlateElementProps, to as SlateHTMLProps, uo as useNodeAttributes, vo as ElementStatic, wo as pluginRenderTextStatic, xo as PlateStaticProps, yo as LeafStatic, za as stripHtmlClassNames } from "../index-BDSzA1zP";
1
+ import { $a as getEditorDOMFromHtmlString, Ao as SlateRenderElement, Ba as stripHtmlClassNames, Co as SlateRenderText, Do as pipeRenderLeafStatic, Eo as SlateRenderLeaf, Ga as getSelectedDomBlocks, Ha as isSelectOutside, Ja as getPluginDataAttributes, Ka as getRenderNodeStaticProps, Oo as pluginRenderLeafStatic, Qa as createStaticEditor, So as PlateStaticProps, To as pluginRenderTextStatic, Ua as getSelectedDomNode, Va as pipeDecorate, Wa as getSelectedDomFragment, Xa as getStaticPlugins, Ya as createStaticString, Za as ViewPlugin, _o as SerializeHtmlOptions, ao as SlateNodeProps, bo as LeafStatic, co as StyledSlateElementProps, do as useNodeAttributes, eo as SlateElement, fo as BoxStaticProps, go as SlateRenderTextProps, ho as SlateRenderNodeProps, io as SlateLeafProps, jo as pluginRenderElementStatic, ko as pipeRenderElementStatic, lo as StyledSlateLeafProps, mo as SlateRenderLeafProps, no as SlateHTMLProps, oo as SlateText, po as SlateRenderElementProps, qa as getNodeDataAttributes, ro as SlateLeaf, so as SlateTextProps, to as SlateElementProps, uo as StyledSlateTextProps, vo as serializeHtml, wo as pipeRenderTextStatic, xo as PlateStatic, yo as ElementStatic, za as stripSlateDataAttributes } from "../index-ClAE30YQ";
2
2
  export { BoxStaticProps, ElementStatic, LeafStatic, PlateStatic, PlateStaticProps, SerializeHtmlOptions, SlateElement, SlateElementProps, SlateHTMLProps, SlateLeaf, SlateLeafProps, SlateNodeProps, SlateRenderElement, SlateRenderElementProps, SlateRenderLeaf, SlateRenderLeafProps, SlateRenderNodeProps, SlateRenderText, SlateRenderTextProps, SlateText, SlateTextProps, StyledSlateElementProps, StyledSlateLeafProps, StyledSlateTextProps, ViewPlugin, createStaticEditor, createStaticString, getEditorDOMFromHtmlString, getNodeDataAttributes, getPluginDataAttributes, getRenderNodeStaticProps, getSelectedDomBlocks, getSelectedDomFragment, getSelectedDomNode, getStaticPlugins, isSelectOutside, pipeDecorate, pipeRenderElementStatic, pipeRenderLeafStatic, pipeRenderTextStatic, pluginRenderElementStatic, pluginRenderLeafStatic, pluginRenderTextStatic, serializeHtml, stripHtmlClassNames, stripSlateDataAttributes, useNodeAttributes };
@@ -1,4 +1,4 @@
1
- import "../withSlate-NVP0S9vL.js";
2
- import { C as createStaticEditor, D as getSelectedDomNode, E as isSelectOutside, O as getSelectedDomFragment, S as useNodeAttributes, T as ViewPlugin, _ as getPluginDataAttributes, a as ElementStatic, b as SlateLeaf, c as pipeRenderTextStatic, d as pluginRenderElementStatic, f as stripSlateDataAttributes, g as getNodeDataAttributes, h as getRenderNodeStaticProps, i as pluginRenderLeafStatic, k as pipeDecorate, l as pluginRenderTextStatic, m as getSelectedDomBlocks, n as serializeHtml, o as LeafStatic, p as stripHtmlClassNames, r as pipeRenderLeafStatic, s as PlateStatic, t as getEditorDOMFromHtmlString, u as pipeRenderElementStatic, v as createStaticString, w as getStaticPlugins, x as SlateText, y as SlateElement } from "../static-KMalmfNw.js";
1
+ import "../withSlate-pfxNb3FA.js";
2
+ import { C as createStaticEditor, D as getSelectedDomNode, E as isSelectOutside, O as getSelectedDomFragment, S as useNodeAttributes, T as ViewPlugin, _ as getPluginDataAttributes, a as ElementStatic, b as SlateLeaf, c as pipeRenderTextStatic, d as pluginRenderElementStatic, f as stripSlateDataAttributes, g as getNodeDataAttributes, h as getRenderNodeStaticProps, i as pluginRenderLeafStatic, k as pipeDecorate, l as pluginRenderTextStatic, m as getSelectedDomBlocks, n as serializeHtml, o as LeafStatic, p as stripHtmlClassNames, r as pipeRenderLeafStatic, s as PlateStatic, t as getEditorDOMFromHtmlString, u as pipeRenderElementStatic, v as createStaticString, w as getStaticPlugins, x as SlateText, y as SlateElement } from "../static-C-jR24Fx.js";
3
3
 
4
4
  export { ElementStatic, LeafStatic, PlateStatic, SlateElement, SlateLeaf, SlateText, ViewPlugin, createStaticEditor, createStaticString, getEditorDOMFromHtmlString, getNodeDataAttributes, getPluginDataAttributes, getRenderNodeStaticProps, getSelectedDomBlocks, getSelectedDomFragment, getSelectedDomNode, getStaticPlugins, isSelectOutside, pipeDecorate, pipeRenderElementStatic, pipeRenderLeafStatic, pipeRenderTextStatic, pluginRenderElementStatic, pluginRenderLeafStatic, pluginRenderTextStatic, serializeHtml, stripHtmlClassNames, stripSlateDataAttributes, useNodeAttributes };
@@ -1,4 +1,4 @@
1
- import { St as keyToDataAttribute, bt as getPluginNodeProps, n as withSlate, ot as DOMPlugin, p as isEditOnly, sn as getEditorPlugin, tn as getPluginByType, wt as getInjectMatch, yt as getSlateClass } from "./withSlate-NVP0S9vL.js";
1
+ import { Ct as keyToDataAttribute, Tt as getInjectMatch, bt as getSlateClass, cn as getEditorPlugin, m as isEditOnly, n as withSlate, nn as getPluginByType, st as DOMPlugin, xt as getPluginNodeProps } from "./withSlate-pfxNb3FA.js";
2
2
  import { ElementApi, NodeApi, RangeApi, TextApi, createEditor, isElementDecorationsEqual, isTextDecorationsEqual } from "@platejs/slate";
3
3
  import { isDefined } from "@udecode/utils";
4
4
  import React from "react";
@@ -782,6 +782,7 @@ const resolvePlugins = (editor, plugins = [], createStore = createVanillaStore)
782
782
  node: {
783
783
  isContainer: [],
784
784
  isLeaf: [],
785
+ isMetadataProp: [],
785
786
  isText: [],
786
787
  leafProps: [],
787
788
  textProps: [],
@@ -813,6 +814,7 @@ const resolvePlugins = (editor, plugins = [], createStore = createVanillaStore)
813
814
  }
814
815
  resolvePluginMethods(editor, plugin);
815
816
  if (plugin.node?.isContainer) editor.meta.pluginCache.node.isContainer.push(plugin.key);
817
+ if (plugin.node?.isMetadataProp) editor.meta.pluginCache.node.isMetadataProp.push(plugin.key);
816
818
  editor.meta.pluginCache.node.types[plugin.node.type] = plugin.key;
817
819
  if (plugin.inject?.nodeProps) editor.meta.pluginCache.inject.nodeProps.push(plugin.key);
818
820
  if (plugin.render?.node) editor.meta.components[plugin.key] = plugin.render.node;
@@ -2967,7 +2969,7 @@ const NodeIdPlugin = createTSlatePlugin({
2967
2969
  filter: defaultNodeIdFilter,
2968
2970
  idCreator: () => nanoid(10)
2969
2971
  }
2970
- }).extendTransforms(({ editor, getOptions }) => ({ normalize() {
2972
+ }).extend(({ getOptions }) => ({ node: { isMetadataProp: ({ key }) => key === (getOptions().idKey ?? "id") } })).extendTransforms(({ editor, getOptions }) => ({ normalize() {
2971
2973
  const options = getOptions();
2972
2974
  const { idCreator, idKey } = options;
2973
2975
  const updates = [];
@@ -3265,6 +3267,21 @@ const setValue = (editor, value) => {
3265
3267
  //#region src/lib/plugins/slate-extension/SlateExtensionPlugin.ts
3266
3268
  const NOOP_ON_NODE_CHANGE = () => {};
3267
3269
  const NOOP_ON_TEXT_CHANGE = () => {};
3270
+ const isElementStateEmpty = (editor, element) => {
3271
+ const props = NodeApi.extractProps(element);
3272
+ return Object.entries(props).every(([key, value]) => {
3273
+ if (key === "type") return true;
3274
+ return editor.meta.pluginCache.node.isMetadataProp.some((pluginKey) => {
3275
+ const plugin = editor.plugins[pluginKey];
3276
+ return plugin.node.isMetadataProp?.({
3277
+ ...getEditorPlugin(editor, plugin),
3278
+ key,
3279
+ node: element,
3280
+ value
3281
+ });
3282
+ });
3283
+ });
3284
+ };
3268
3285
  /** Opinionated extension of slate default behavior. */
3269
3286
  const SlateExtensionPlugin = createTSlatePlugin({
3270
3287
  api: { redecorate: () => {} },
@@ -3273,7 +3290,7 @@ const SlateExtensionPlugin = createTSlatePlugin({
3273
3290
  onNodeChange: NOOP_ON_NODE_CHANGE,
3274
3291
  onTextChange: NOOP_ON_TEXT_CHANGE
3275
3292
  }
3276
- }).extendEditorTransforms(({ editor, getOption, tf }) => {
3293
+ }).extendEditorApi(({ editor }) => ({ isElementStateEmpty: bindFirst(isElementStateEmpty, editor) })).extendEditorTransforms(({ editor, getOption, tf }) => {
3277
3294
  const apply = tf?.apply ?? editor.tf.apply;
3278
3295
  return {
3279
3296
  init: bindFirst(init, editor),
@@ -3807,4 +3824,4 @@ const withSlate = (e, { id, affinity = true, autoSelect, chunking = true, maxLen
3807
3824
  const createSlateEditor = ({ editor = createEditor(), ...options } = {}) => withSlate(editor, options);
3808
3825
 
3809
3826
  //#endregion
3810
- export { collapseString as $, defineInputRule as $t, deserializeHtml as A, isSlatePluginElement as At, getDataNodeProps as B, withDeleteRules as Bt, flashTarget as C, getInjectedPlugins as Ct, LengthPlugin as D, isSlateElement as Dt, NavigationFeedbackPluginKey as E, isSlateEditor as Et, htmlElementToLeaf as F, applyDeepToNodes as Ft, collapseWhiteSpaceElement as G, AstPlugin as Gt, htmlBodyToFragment as H, BaseParagraphPlugin as Ht, pipeDeserializeHtmlLeaf as I, OverridePlugin as It, collapseWhiteSpaceNode as J, createMarkInputRule as Jt, inferWhiteSpaceRule as K, createBlockFenceInputRule as Kt, htmlElementToElement as L, withOverrides as Lt, deserializeHtmlElement as M, isSlateString as Mt, deserializeHtmlNode as N, isSlateText as Nt, HtmlPlugin as O, isSlateLeaf as Ot, htmlTextNodeToString as P, isSlateVoid as Pt, isLastNonEmptyTextOfInlineFormattingContext as Q, matchDelimitedInline as Qt, pipeDeserializeHtmlElement as R, withNormalizeRules as Rt, clearNavigationFeedbackTarget as S, keyToDataAttribute as St, NAVIGATION_FEEDBACK_KEY as T, getSlateElements as Tt, deserializeHtmlNodeChildren as U, HistoryPlugin as Ut, htmlBrToNewLine as V, withBreakRules as Vt, collapseWhiteSpace as W, withPlateHistory as Wt, endInlineFormattingContext as X, matchBlockFence as Xt, collapseWhiteSpaceText as Y, createTextSubstitutionInputRule as Yt, upsertInlineFormattingContext as Z, matchBlockStart as Zt, normalizeNodeId as _, getEdgeNodes as _t, pipeInsertDataQuery as a, getPluginTypes as an, AUTO_SCROLL as at, NavigationFeedbackPlugin as b, getPluginNodeProps as bt, setValue as c, createSlatePlugin as cn, DebugPlugin as ct, insertExitBreak as d, withChunking as dt, getContainerTypes as en, isHtmlBlockElement as et, init as f, AffinityPlugin as ft, NodeIdPlugin as g, getMarkBoundaryAffinity as gt, pipeOnNodeChange as h, isNodesAffinity as ht, ParserPlugin as i, getPluginType as in, isHtmlElement as it, htmlStringToDOMNode as j, isSlatePluginNode as jt, parseHtmlDocument as k, isSlateNode as kt, resetBlock as l, createTSlatePlugin as ln, PlateError as lt, pipeOnTextChange as m, isNodeAffinity as mt, withSlate as n, getPluginKey as nn, inlineTagNames as nt, normalizeDescendantsToDocumentFragment as o, getSlatePlugin as on, DOMPlugin as ot, isEditOnly as p, setAffinitySelection as pt, collapseWhiteSpaceChildren as q, createBlockStartInputRule as qt, getCorePlugins as r, getPluginKeys as rn, isHtmlText as rt, SlateExtensionPlugin as s, getEditorPlugin as sn, withScrolling as st, createSlateEditor as t, getPluginByType as tn, isHtmlInlineElement as tt, liftBlock as u, ChunkingPlugin as ut, normalizeNodeIdWithEditor as v, mergeDeepToNodes as vt, resolveNavigationFeedbackTarget as w, getInjectMatch as wt, navigate as x, getNodeDataAttributeKeys as xt, withNodeId as y, getSlateClass as yt, pluginDeserializeHtml as z, withMergeRules as zt };
3827
+ export { isLastNonEmptyTextOfInlineFormattingContext as $, matchDelimitedInline as $t, parseHtmlDocument as A, isSlateNode as At, pluginDeserializeHtml as B, withMergeRules as Bt, clearNavigationFeedbackTarget as C, keyToDataAttribute as Ct, NavigationFeedbackPluginKey as D, isSlateEditor as Dt, NAVIGATION_FEEDBACK_KEY as E, getSlateElements as Et, htmlTextNodeToString as F, isSlateVoid as Ft, collapseWhiteSpace as G, withPlateHistory as Gt, htmlBrToNewLine as H, withBreakRules as Ht, htmlElementToLeaf as I, applyDeepToNodes as It, collapseWhiteSpaceChildren as J, createBlockStartInputRule as Jt, collapseWhiteSpaceElement as K, AstPlugin as Kt, pipeDeserializeHtmlLeaf as L, OverridePlugin as Lt, htmlStringToDOMNode as M, isSlatePluginNode as Mt, deserializeHtmlElement as N, isSlateString as Nt, LengthPlugin as O, isSlateElement as Ot, deserializeHtmlNode as P, isSlateText as Pt, upsertInlineFormattingContext as Q, matchBlockStart as Qt, htmlElementToElement as R, withOverrides as Rt, navigate as S, getNodeDataAttributeKeys as St, resolveNavigationFeedbackTarget as T, getInjectMatch as Tt, htmlBodyToFragment as U, BaseParagraphPlugin as Ut, getDataNodeProps as V, withDeleteRules as Vt, deserializeHtmlNodeChildren as W, HistoryPlugin as Wt, collapseWhiteSpaceText as X, createTextSubstitutionInputRule as Xt, collapseWhiteSpaceNode as Y, createMarkInputRule as Yt, endInlineFormattingContext as Z, matchBlockFence as Zt, NodeIdPlugin as _, getMarkBoundaryAffinity as _t, pipeInsertDataQuery as a, getPluginType as an, isHtmlElement as at, withNodeId as b, getSlateClass as bt, isElementStateEmpty as c, getEditorPlugin as cn, withScrolling as ct, liftBlock as d, ChunkingPlugin as dt, defineInputRule as en, collapseString as et, insertExitBreak as f, withChunking as ft, pipeOnNodeChange as g, isNodesAffinity as gt, pipeOnTextChange as h, isNodeAffinity as ht, ParserPlugin as i, getPluginKeys as in, isHtmlText as it, deserializeHtml as j, isSlatePluginElement as jt, HtmlPlugin as k, isSlateLeaf as kt, setValue as l, createSlatePlugin as ln, DebugPlugin as lt, isEditOnly as m, setAffinitySelection as mt, withSlate as n, getPluginByType as nn, isHtmlInlineElement as nt, normalizeDescendantsToDocumentFragment as o, getPluginTypes as on, AUTO_SCROLL as ot, init as p, AffinityPlugin as pt, inferWhiteSpaceRule as q, createBlockFenceInputRule as qt, getCorePlugins as r, getPluginKey as rn, inlineTagNames as rt, SlateExtensionPlugin as s, getSlatePlugin as sn, DOMPlugin as st, createSlateEditor as t, getContainerTypes as tn, isHtmlBlockElement as tt, resetBlock as u, createTSlatePlugin as un, PlateError as ut, normalizeNodeId as v, getEdgeNodes as vt, flashTarget as w, getInjectedPlugins as wt, NavigationFeedbackPlugin as x, getPluginNodeProps as xt, normalizeNodeIdWithEditor as y, mergeDeepToNodes as yt, pipeDeserializeHtmlElement as z, withNormalizeRules as zt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/platejs-core",
3
- "version": "53.1.8",
3
+ "version": "53.2.1",
4
4
  "description": "The core of Plate – a plugin system for slate",
5
5
  "keywords": [
6
6
  "contentEditable",