@uxf/wysiwyg 11.129.0 → 11.130.0

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.
Files changed (148) hide show
  1. package/README.md +9 -7
  2. package/create-all-plugins-with-ui.d.ts +78 -14
  3. package/create-all-plugins-with-ui.js +3 -5
  4. package/create-plugins-with-ui.d.ts +2 -2
  5. package/create-plugins-with-ui.js +25 -30
  6. package/data-format.test.d.ts +1 -0
  7. package/data-format.test.js +132 -0
  8. package/editor-smoke.test.d.ts +1 -0
  9. package/editor-smoke.test.js +9 -0
  10. package/hooks.d.ts +1971 -8
  11. package/hooks.js +18 -11
  12. package/package.json +15 -47
  13. package/plugins/blockquote/create-blockquote-plugin.d.ts +9 -3
  14. package/plugins/blockquote/create-blockquote-plugin.js +31 -3
  15. package/plugins/blockquote/create-blockquote-plugin.test.d.ts +1 -0
  16. package/plugins/blockquote/create-blockquote-plugin.test.js +55 -0
  17. package/plugins/blockquote/types.d.ts +1 -1
  18. package/plugins/blockquote/types.js +2 -2
  19. package/plugins/button/create-button-plugin.d.ts +1 -2
  20. package/plugins/button/create-button-plugin.js +3 -5
  21. package/plugins/button/transforms/is-button-active.js +1 -2
  22. package/plugins/button/transforms/update-button.js +1 -2
  23. package/plugins/constants.test.d.ts +1 -0
  24. package/plugins/constants.test.js +52 -0
  25. package/plugins/embedded/types.d.ts +6 -0
  26. package/plugins/embedded/types.js +2 -0
  27. package/plugins/embedded/utils.d.ts +2 -1
  28. package/plugins/embedded/utils.js +4 -4
  29. package/plugins/embedded/video/create-video-plugin.d.ts +10 -3
  30. package/plugins/embedded/video/create-video-plugin.js +8 -9
  31. package/plugins/embedded/video/create-video-plugin.test.d.ts +1 -0
  32. package/plugins/embedded/video/create-video-plugin.test.js +30 -0
  33. package/plugins/embedded/video/update-video.js +1 -2
  34. package/plugins/exit-break/create-exit-break-plugin.d.ts +8 -3
  35. package/plugins/exit-break/create-exit-break-plugin.js +8 -25
  36. package/plugins/heading/create-headings-plugin.d.ts +13 -4
  37. package/plugins/heading/create-headings-plugin.js +22 -36
  38. package/plugins/heading/create-headings-plugin.test.d.ts +1 -0
  39. package/plugins/heading/create-headings-plugin.test.js +42 -0
  40. package/plugins/highlight/createHighlightPlugin.d.ts +4 -2
  41. package/plugins/highlight/createHighlightPlugin.js +8 -21
  42. package/plugins/highlight/types.d.ts +1 -2
  43. package/plugins/image/create-image-plugin.d.ts +3 -3
  44. package/plugins/image/create-image-plugin.js +58 -91
  45. package/plugins/image/create-image-plugin.test.d.ts +1 -0
  46. package/plugins/image/create-image-plugin.test.js +33 -0
  47. package/plugins/image/transforms/is-image-active.js +1 -2
  48. package/plugins/image/transforms/update-image.js +1 -2
  49. package/plugins/image/types.d.ts +6 -3
  50. package/plugins/image/types.js +2 -2
  51. package/plugins/image/utils/is-image-url.js +2 -2
  52. package/plugins/image/with-paste-image-url.d.ts +5 -5
  53. package/plugins/image/with-paste-image-url.js +29 -25
  54. package/plugins/image/with-paste-image.d.ts +4 -7
  55. package/plugins/image/with-paste-image.js +41 -39
  56. package/plugins/link/constants.d.ts +1 -1
  57. package/plugins/link/constants.js +2 -2
  58. package/plugins/link/create-link-plugin.d.ts +38 -3
  59. package/plugins/link/create-link-plugin.js +9 -7
  60. package/plugins/link/create-link-plugin.test.d.ts +1 -0
  61. package/plugins/link/create-link-plugin.test.js +24 -0
  62. package/plugins/link/floating-link-wrapper.d.ts +14 -7
  63. package/plugins/link/floating-link-wrapper.js +46 -17
  64. package/plugins/link/hooks/index.d.ts +1 -1
  65. package/plugins/link/hooks/index.js +2 -2
  66. package/plugins/link/hooks/use-floating-link-selectors.d.ts +8 -0
  67. package/plugins/link/hooks/use-floating-link-selectors.js +21 -0
  68. package/plugins/link/hooks/use-link-actions.d.ts +991 -8
  69. package/plugins/link/hooks/use-link-actions.js +22 -19
  70. package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +1 -1
  71. package/plugins/link/hooks/use-link-cancel-on-escape.js +2 -2
  72. package/plugins/link/hooks/use-link-submit-on-enter.js +5 -5
  73. package/plugins/link/transforms/get-active-link.d.ts +1 -1
  74. package/plugins/link/transforms/get-active-link.js +3 -5
  75. package/plugins/link/transforms/insert-link.js +9 -9
  76. package/plugins/link/transforms/submit-link.d.ts +2 -3
  77. package/plugins/link/transforms/submit-link.js +13 -13
  78. package/plugins/link/transforms/trigger-link-insert-or-edit.js +2 -2
  79. package/plugins/link/transforms/unwrap-link.js +2 -2
  80. package/plugins/list/constants.d.ts +11 -3
  81. package/plugins/list/constants.js +14 -10
  82. package/plugins/list/create-list-plugin.d.ts +26 -4
  83. package/plugins/list/create-list-plugin.js +13 -12
  84. package/plugins/list/create-list-plugin.test.d.ts +1 -0
  85. package/plugins/list/create-list-plugin.test.js +20 -0
  86. package/plugins/mark-bold/create-bold-plugin.d.ts +3 -3
  87. package/plugins/mark-bold/create-bold-plugin.js +2 -2
  88. package/plugins/mark-bold/types.d.ts +2 -2
  89. package/plugins/mark-bold/types.js +3 -3
  90. package/plugins/mark-code/create-code-plugin.d.ts +7 -3
  91. package/plugins/mark-code/create-code-plugin.js +6 -2
  92. package/plugins/mark-code/types.d.ts +2 -2
  93. package/plugins/mark-code/types.js +3 -3
  94. package/plugins/mark-italic/create-italic-plugin.d.ts +3 -3
  95. package/plugins/mark-italic/create-italic-plugin.js +2 -2
  96. package/plugins/mark-italic/types.d.ts +2 -2
  97. package/plugins/mark-italic/types.js +3 -3
  98. package/plugins/mark-underline/create-underline-plugin.d.ts +3 -3
  99. package/plugins/mark-underline/create-underline-plugin.js +2 -2
  100. package/plugins/mark-underline/types.d.ts +2 -2
  101. package/plugins/mark-underline/types.js +3 -3
  102. package/plugins/marks.test.d.ts +1 -0
  103. package/plugins/marks.test.js +42 -0
  104. package/plugins/node-id/add-ids-to-nodes.d.ts +1 -1
  105. package/plugins/node-id/create-node-id-plugin.d.ts +22 -3
  106. package/plugins/node-id/create-node-id-plugin.js +3 -2
  107. package/plugins/paragraph/create-paragraph-plugin.d.ts +1 -3
  108. package/plugins/paragraph/create-paragraph-plugin.js +3 -4
  109. package/plugins/paragraph/types.d.ts +1 -1
  110. package/plugins/paragraph/types.js +2 -2
  111. package/plugins/structural.test.d.ts +1 -0
  112. package/plugins/structural.test.js +29 -0
  113. package/plugins/trailing-block/create-trailing-block-plugin.d.ts +13 -3
  114. package/plugins/trailing-block/create-trailing-block-plugin.js +8 -2
  115. package/serializers/serialize-to-plaintext.js +2 -2
  116. package/styles/styles.css +1 -0
  117. package/types.d.ts +23 -14
  118. package/ui/floating-link.js +28 -28
  119. package/ui/highlight-mark.d.ts +2 -3
  120. package/ui/highlight-mark.js +4 -1
  121. package/ui/link-element.js +6 -3
  122. package/ui/toolbar/buttons/button-toolbar-button.d.ts +1 -1
  123. package/ui/toolbar/buttons/element-toolbar-button.d.ts +1 -1
  124. package/ui/toolbar/buttons/image-toolbar-button.d.ts +1 -1
  125. package/ui/toolbar/buttons/link-toolbar-button.d.ts +1 -1
  126. package/ui/toolbar/buttons/link-toolbar-button.js +1 -1
  127. package/ui/toolbar/buttons/list-toolbar-button.d.ts +1 -1
  128. package/ui/toolbar/buttons/list-toolbar-button.js +3 -3
  129. package/ui/toolbar/buttons/mark-toolbar-button.d.ts +1 -1
  130. package/ui/toolbar/buttons/undo-redo-button-group.d.ts +1 -1
  131. package/ui/toolbar/buttons/video-toolbar-button.d.ts +1 -1
  132. package/ui/toolbar/types.d.ts +1 -1
  133. package/ui/utils.js +1 -1
  134. package/utils.d.ts +18 -19
  135. package/utils.js +31 -28
  136. package/utils.test.d.ts +1 -0
  137. package/utils.test.js +23 -0
  138. package/wysiwyg-editor.d.ts +2 -2
  139. package/wysiwyg-editor.js +29 -23
  140. package/wysiwyg-editor.test.js +111 -6
  141. package/plugins/image/with-image.d.ts +0 -7
  142. package/plugins/image/with-image.js +0 -19
  143. package/plugins/reset-node/create-reset-node.d.ts +0 -3
  144. package/plugins/reset-node/create-reset-node.js +0 -28
  145. package/plugins/select-on-backspace/create-select-on-backspace-plugin.d.ts +0 -3
  146. package/plugins/select-on-backspace/create-select-on-backspace-plugin.js +0 -14
  147. package/plugins/soft-break/create-soft-break-plugin.d.ts +0 -3
  148. package/plugins/soft-break/create-soft-break-plugin.js +0 -22
package/hooks.js CHANGED
@@ -1,20 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSelected = exports.useUxfPlateStates = exports.useUxfPlateActions = exports.useUxfPlateSelectors = exports.useUxfPlateEditorState = exports.useUxfEditorState = exports.useUxfEditorRef = exports.useUxfPlateEditorRef = void 0;
4
- const plate_core_1 = require("@udecode/plate-core");
5
- const useUxfPlateEditorRef = (id) => (0, plate_core_1.usePlateEditorRef)(id);
3
+ exports.useSelected = exports.usePlateStore = exports.useUxfPlateStates = exports.useUxfPlateActions = exports.useUxfPlateSelectors = exports.useUxfPlateEditorState = exports.useUxfEditorState = exports.useUxfEditorRef = exports.useUxfPlateEditorRef = void 0;
4
+ const react_1 = require("platejs/react");
5
+ const useUxfPlateEditorRef = (id) => (0, react_1.useEditorRef)((0, react_1.useEventPlateId)(id));
6
6
  exports.useUxfPlateEditorRef = useUxfPlateEditorRef;
7
- const useUxfEditorRef = () => (0, plate_core_1.useEditorRef)();
7
+ const useUxfEditorRef = () => (0, react_1.useEditorRef)();
8
8
  exports.useUxfEditorRef = useUxfEditorRef;
9
- const useUxfEditorState = () => (0, plate_core_1.useEditorState)();
9
+ const useUxfEditorState = () => (0, react_1.useEditorState)();
10
10
  exports.useUxfEditorState = useUxfEditorState;
11
- const useUxfPlateEditorState = (id) => (0, plate_core_1.usePlateEditorState)((0, plate_core_1.useEventPlateId)(id));
11
+ const useUxfPlateEditorState = (id) => (0, react_1.useEditorState)((0, react_1.useEventPlateId)(id));
12
12
  exports.useUxfPlateEditorState = useUxfPlateEditorState;
13
- const useUxfPlateSelectors = (id) => (0, plate_core_1.usePlateSelectors)(id);
13
+ /**
14
+ * Plate 53 merged the split selectors/actions/states store into one, so these three cannot honour
15
+ * their old contract; they keep their names and hand back that store. `unknown` because naming its
16
+ * type would emit a `.d.ts` pointing into `@platejs/core/node_modules` (TS2883) – use the re-exported
17
+ * `usePlateStore` instead. Nothing in the monorepo consumes them.
18
+ */
19
+ const useUxfPlateSelectors = (id) => (0, react_1.usePlateStore)(id);
14
20
  exports.useUxfPlateSelectors = useUxfPlateSelectors;
15
- const useUxfPlateActions = (id) => (0, plate_core_1.usePlateActions)(id);
21
+ const useUxfPlateActions = (id) => (0, react_1.usePlateStore)(id);
16
22
  exports.useUxfPlateActions = useUxfPlateActions;
17
- const useUxfPlateStates = (id) => (0, plate_core_1.usePlateStates)(id);
23
+ const useUxfPlateStates = (id) => (0, react_1.usePlateStore)(id);
18
24
  exports.useUxfPlateStates = useUxfPlateStates;
19
- var slate_react_1 = require("slate-react");
20
- Object.defineProperty(exports, "useSelected", { enumerable: true, get: function () { return slate_react_1.useSelected; } });
25
+ var react_2 = require("platejs/react");
26
+ Object.defineProperty(exports, "usePlateStore", { enumerable: true, get: function () { return react_2.usePlateStore; } });
27
+ Object.defineProperty(exports, "useSelected", { enumerable: true, get: function () { return react_2.useSelected; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/wysiwyg",
3
- "version": "11.129.0",
3
+ "version": "11.130.0",
4
4
  "description": "UXF Wysiwyg editor",
5
5
  "author": "Robin Dvorak <dvorak@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/wysiwyg",
@@ -13,63 +13,31 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "peerDependencies": {
16
- "@udecode/plate-basic-marks": "20.7.2",
17
- "@udecode/plate-block-quote": "20.7.2",
18
- "@udecode/plate-break": "20.7.2",
19
- "@udecode/plate-code-block": "20.7.2",
20
- "@udecode/plate-common": "20.7.2",
21
- "@udecode/plate-core": "20.7.2",
22
- "@udecode/plate-floating": "20.7.2",
23
- "@udecode/plate-link": "20.7.2",
24
- "@udecode/plate-list": "20.7.2",
25
- "@udecode/plate-media": "20.7.2",
26
- "@udecode/plate-node-id": "20.7.2",
27
- "@udecode/plate-paragraph": "20.7.2",
28
- "@udecode/plate-reset-node": "20.7.2",
29
- "@udecode/plate-select": "20.7.2",
30
- "@udecode/plate-trailing-block": "20.7.2",
31
- "@udecode/slate": "19.8.0",
32
- "@udecode/slate-react": "19.7.1",
33
- "@udecode/slate-utils": "19.7.1",
16
+ "@platejs/basic-nodes": "53.0.0",
17
+ "@platejs/floating": "53.0.0",
18
+ "@platejs/link": "53.3.5",
19
+ "@platejs/list-classic": "53.0.0",
20
+ "@platejs/media": "53.1.4",
34
21
  "@uxf/core": "11.129.0",
35
22
  "@uxf/core-react": "11.129.0",
36
23
  "@uxf/ui": "11.129.0",
24
+ "platejs": "53.3.9",
37
25
  "react": ">=18.2.0",
38
- "react-dom": ">=18.2.0",
39
- "slate": "0.90.0",
40
- "slate-history": "0.86.0",
41
- "slate-hyperscript": "0.77.0",
42
- "slate-react": "0.91.11"
26
+ "react-dom": ">=18.2.0"
43
27
  },
44
28
  "devDependencies": {
29
+ "@platejs/basic-nodes": "53.0.0",
30
+ "@platejs/floating": "53.0.0",
31
+ "@platejs/link": "53.3.5",
32
+ "@platejs/list-classic": "53.0.0",
33
+ "@platejs/media": "53.1.4",
45
34
  "@types/react": "18.3.31",
46
35
  "@types/react-dom": "18.3.7",
47
- "@udecode/plate-basic-marks": "20.7.2",
48
- "@udecode/plate-block-quote": "20.7.2",
49
- "@udecode/plate-break": "20.7.2",
50
- "@udecode/plate-code-block": "20.7.2",
51
- "@udecode/plate-common": "20.7.2",
52
- "@udecode/plate-core": "20.7.2",
53
- "@udecode/plate-floating": "20.7.2",
54
- "@udecode/plate-link": "20.7.2",
55
- "@udecode/plate-list": "20.7.2",
56
- "@udecode/plate-media": "20.7.2",
57
- "@udecode/plate-node-id": "20.7.2",
58
- "@udecode/plate-paragraph": "20.7.2",
59
- "@udecode/plate-reset-node": "20.7.2",
60
- "@udecode/plate-select": "20.7.2",
61
- "@udecode/plate-trailing-block": "20.7.2",
62
- "@udecode/slate": "19.8.0",
63
- "@udecode/slate-react": "19.7.1",
64
- "@udecode/slate-utils": "19.7.1",
65
36
  "@uxf/core": "11.129.0",
66
37
  "@uxf/core-react": "11.129.0",
67
38
  "@uxf/ui": "11.129.0",
39
+ "platejs": "53.3.9",
68
40
  "react": "18.3.1",
69
- "react-dom": "18.3.1",
70
- "slate": "0.90.0",
71
- "slate-history": "0.86.0",
72
- "slate-hyperscript": "0.77.0",
73
- "slate-react": "0.91.11"
41
+ "react-dom": "18.3.1"
74
42
  }
75
43
  }
@@ -1,3 +1,9 @@
1
- import { HotkeyPlugin } from "@udecode/plate-core";
2
- import { UxfEditor, WysiwygContent } from "../../types";
3
- export declare const createBlockquotePlugin: () => import("@udecode/plate-core").PlatePlugin<HotkeyPlugin, WysiwygContent, UxfEditor>;
1
+ /**
2
+ * Hand-built, not Plate's `BlockquotePlugin`: that one treats a quote as a container of blocks and
3
+ * normalizes `blockquote > text` into `blockquote > paragraph > text`, rewriting every stored quote.
4
+ * The wrapping lives in an `overrideEditor` and cannot be configured away.
5
+ *
6
+ * `delete.start` and the hotkey replace plugins Plate 53 dropped. Why each is what it is:
7
+ * docs/decisions/wysiwyg-plate-53-migration.md.
8
+ */
9
+ export declare const createBlockquotePlugin: () => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"blockquote", {}, {}, {}, {}>>;
@@ -1,9 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBlockquotePlugin = void 0;
4
- const plate_block_quote_1 = require("@udecode/plate-block-quote");
4
+ const platejs_1 = require("platejs");
5
+ const react_1 = require("platejs/react");
5
6
  const types_1 = require("./types");
6
- const createBlockquotePlugin = () => (0, plate_block_quote_1.createBlockquotePlugin)({
7
- type: types_1.BLOCKQUOTE_PLUGIN_TYPE,
7
+ /**
8
+ * Hand-built, not Plate's `BlockquotePlugin`: that one treats a quote as a container of blocks and
9
+ * normalizes `blockquote > text` into `blockquote > paragraph > text`, rewriting every stored quote.
10
+ * The wrapping lives in an `overrideEditor` and cannot be configured away.
11
+ *
12
+ * `delete.start` and the hotkey replace plugins Plate 53 dropped. Why each is what it is:
13
+ * docs/decisions/wysiwyg-plate-53-migration.md.
14
+ */
15
+ const createBlockquotePlugin = () => (0, react_1.createPlatePlugin)({
16
+ key: platejs_1.KEYS.blockquote,
17
+ node: { isElement: true, type: types_1.BLOCKQUOTE_PLUGIN_TYPE },
18
+ parsers: { html: { deserializer: { rules: [{ validNodeName: "BLOCKQUOTE" }] } } },
19
+ rules: {
20
+ // Enter splits the quote and a second Enter on the empty line leaves it, as every editor
21
+ // does. Plate 20 inserted a literal "\n" here and never let Enter out of a quote at all,
22
+ // which was an accident of matching a plugin key against a node type, not a decision.
23
+ // shift+enter still soft-breaks, from slate-react's own hotkey table.
24
+ break: { empty: "reset" },
25
+ delete: { start: "reset" },
26
+ },
27
+ shortcuts: {
28
+ toggle: {
29
+ handler: ({ editor }) => {
30
+ editor.tf.toggleBlock(types_1.BLOCKQUOTE_PLUGIN_TYPE);
31
+ return true;
32
+ },
33
+ keys: "mod+shift+.",
34
+ },
35
+ },
8
36
  });
9
37
  exports.createBlockquotePlugin = createBlockquotePlugin;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const platejs_1 = require("platejs");
4
+ const create_paragraph_plugin_1 = require("../paragraph/create-paragraph-plugin");
5
+ const create_blockquote_plugin_1 = require("./create-blockquote-plugin");
6
+ function editor(value) {
7
+ return (0, platejs_1.createSlateEditor)({
8
+ plugins: [(0, create_paragraph_plugin_1.createParagraphPlugin)(), (0, create_blockquote_plugin_1.createBlockquotePlugin)()],
9
+ value,
10
+ });
11
+ }
12
+ describe("blockquote", () => {
13
+ it("keeps the stored node type", () => {
14
+ expect(editor([]).plugins.blockquote.node.type).toBe("blockquote");
15
+ });
16
+ // Why the plugin is hand-built: Plate's own quote normalizes inline children into a paragraph,
17
+ // rewriting every stored quote. Swapping back to `BlockquotePlugin` makes this fail.
18
+ it("does not wrap inline children in a paragraph on normalisation", () => {
19
+ const e = (0, platejs_1.createSlateEditor)({
20
+ plugins: [(0, create_paragraph_plugin_1.createParagraphPlugin)(), (0, create_blockquote_plugin_1.createBlockquotePlugin)()],
21
+ shouldNormalizeEditor: true,
22
+ value: [{ children: [{ text: "citace" }], type: "blockquote" }],
23
+ });
24
+ expect(e.children[0].children).toEqual([{ text: "citace" }]);
25
+ });
26
+ // @udecode/plate-block-quote@20.7.2 defaulted to mod+shift+. ; Plate 53 ships no quote shortcut.
27
+ it("keeps the mod+shift+. hotkey", () => {
28
+ var _a;
29
+ expect((_a = editor([]).plugins.blockquote.shortcuts.toggle) === null || _a === void 0 ? void 0 : _a.keys).toBe("mod+shift+.");
30
+ });
31
+ // Plate 20 inserted a literal "\n" and never let Enter out of a quote. Deliberately changed.
32
+ it("splits the quote on Enter", () => {
33
+ const e = editor([{ children: [{ text: "citace" }], type: "blockquote" }]);
34
+ e.tf.select({ offset: 6, path: [0, 0] });
35
+ e.tf.insertBreak();
36
+ expect(e.children.map((node) => node.type)).toEqual(["blockquote", "blockquote"]);
37
+ expect(e.api.string([0])).toBe("citace");
38
+ });
39
+ // The empty line becomes a paragraph in place, leaving no stray quote behind. "lift" is a no-op
40
+ // for a top-level quote and "exit" strands the empty one, so neither would do.
41
+ it("leaves the quote on a second Enter, on the now empty line", () => {
42
+ const e = editor([{ children: [{ text: "" }], type: "blockquote" }]);
43
+ e.tf.select({ offset: 0, path: [0, 0] });
44
+ e.tf.insertBreak();
45
+ expect(e.children.map((node) => node.type)).toEqual(["paragraph"]);
46
+ });
47
+ // The one approved deviation: the old rule reset to "p", which nothing registers.
48
+ it("resets a quote to a paragraph on Backspace at its start", () => {
49
+ const e = editor([{ children: [{ text: "citace" }], type: "blockquote" }]);
50
+ e.tf.select({ offset: 0, path: [0, 0] });
51
+ e.tf.deleteBackward("character");
52
+ expect(e.children.map((node) => node.type)).toEqual(["paragraph"]);
53
+ expect(e.api.string([0])).toBe("citace");
54
+ });
55
+ });
@@ -1,2 +1,2 @@
1
- export declare const BLOCKQUOTE_PLUGIN_KEY = "blockquote";
1
+ export declare const BLOCKQUOTE_PLUGIN_KEY: "blockquote";
2
2
  export declare const BLOCKQUOTE_PLUGIN_TYPE = "blockquote";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BLOCKQUOTE_PLUGIN_TYPE = exports.BLOCKQUOTE_PLUGIN_KEY = void 0;
4
- const plate_block_quote_1 = require("@udecode/plate-block-quote");
5
- exports.BLOCKQUOTE_PLUGIN_KEY = plate_block_quote_1.ELEMENT_BLOCKQUOTE;
4
+ const platejs_1 = require("platejs");
5
+ exports.BLOCKQUOTE_PLUGIN_KEY = platejs_1.KEYS.blockquote;
6
6
  exports.BLOCKQUOTE_PLUGIN_TYPE = "blockquote";
@@ -1,2 +1 @@
1
- import { WysiwygContent } from "../../types";
2
- export declare const createButtonPlugin: <OP = import("@udecode/utils").AnyObject, OV extends import("@udecode/slate").Value = WysiwygContent, OE extends import("@udecode/plate-core").PlateEditor<OV> = import("@udecode/plate-core").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>;
1
+ export declare const createButtonPlugin: import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"button", {}, {}, {}, {}>>;
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createButtonPlugin = void 0;
4
- const plate_core_1 = require("@udecode/plate-core");
4
+ const react_1 = require("platejs/react");
5
5
  const constants_1 = require("./constants");
6
- exports.createButtonPlugin = (0, plate_core_1.createPluginFactory)({
6
+ exports.createButtonPlugin = (0, react_1.createPlatePlugin)({
7
7
  key: constants_1.PLUGIN_BUTTON_KEY,
8
- type: constants_1.PLUGIN_BUTTON_TYPE,
9
- isElement: true,
10
- isVoid: true,
8
+ node: { isElement: true, isVoid: true, type: constants_1.PLUGIN_BUTTON_TYPE },
11
9
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isButtonActive = void 0;
4
- const plate_common_1 = require("@udecode/plate-common");
5
4
  const get_active_button_1 = require("./get-active-button");
6
- const isButtonActive = (editor) => Boolean((0, get_active_button_1.getActiveButton)(editor) && (0, plate_common_1.isRangeInSameBlock)(editor));
5
+ const isButtonActive = (editor) => Boolean((0, get_active_button_1.getActiveButton)(editor) && editor.api.isAt({ block: true }));
7
6
  exports.isButtonActive = isButtonActive;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateButton = void 0;
4
- const plate_common_1 = require("@udecode/plate-common");
5
- const updateButton = (editor, buttonText, buttonUrl) => (0, plate_common_1.setNodes)(editor, {
4
+ const updateButton = (editor, buttonText, buttonUrl) => editor.tf.setNodes({
6
5
  buttonText,
7
6
  buttonUrl,
8
7
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const platejs_1 = require("platejs");
4
+ const create_all_plugins_with_ui_1 = require("../create-all-plugins-with-ui");
5
+ const types_1 = require("./blockquote/types");
6
+ const constants_1 = require("./button/constants");
7
+ const create_video_plugin_1 = require("./embedded/video/create-video-plugin");
8
+ const constants_2 = require("./heading/constants");
9
+ const types_2 = require("./highlight/types");
10
+ const types_3 = require("./image/types");
11
+ const constants_3 = require("./link/constants");
12
+ const constants_4 = require("./list/constants");
13
+ const types_4 = require("./mark-bold/types");
14
+ const types_5 = require("./mark-code/types");
15
+ const types_6 = require("./mark-italic/types");
16
+ const types_7 = require("./mark-underline/types");
17
+ const types_8 = require("./paragraph/types");
18
+ const FILE = { extension: ".png", id: 1, name: "a.png", namespace: "wysiwyg", uuid: "u" };
19
+ const editor = (0, platejs_1.createSlateEditor)({
20
+ plugins: (0, create_all_plugins_with_ui_1.createAllPluginsWithUi)({
21
+ image: { getImageUrl: (file) => file.name, uploadImage: async () => FILE },
22
+ }),
23
+ });
24
+ /**
25
+ * Guards the bug that took a browser to find: `ELEMENT_UL` read from `KEYS.ul` is "disc", so the
26
+ * toolbar silently dropped its list group while the elements kept rendering.
27
+ */
28
+ describe("exported plugin key constants", () => {
29
+ it.each([
30
+ ["PARAGRAPH_PLUGIN_KEY", types_8.PARAGRAPH_PLUGIN_KEY],
31
+ ["BLOCKQUOTE_PLUGIN_KEY", types_1.BLOCKQUOTE_PLUGIN_KEY],
32
+ ["BOLD_PLUGIN_KEY", types_4.BOLD_PLUGIN_KEY],
33
+ ["ITALIC_PLUGIN_KEY", types_6.ITALIC_PLUGIN_KEY],
34
+ ["UNDER_LINE_PLUGIN_KEY", types_7.UNDER_LINE_PLUGIN_KEY],
35
+ ["CODE_PLUGIN_KEY", types_5.CODE_PLUGIN_KEY],
36
+ ["HIGHLIGHT_PLUGIN_KEY", types_2.HIGHLIGHT_PLUGIN_KEY],
37
+ ["ELEMENT_LINK", constants_3.ELEMENT_LINK],
38
+ ["IMAGE_PLUGIN_KEY", types_3.IMAGE_PLUGIN_KEY],
39
+ ["ELEMENT_VIDEO_EMBED", create_video_plugin_1.ELEMENT_VIDEO_EMBED],
40
+ ["PLUGIN_BUTTON_KEY", constants_1.PLUGIN_BUTTON_KEY],
41
+ ["ELEMENT_UL", constants_4.ELEMENT_UL],
42
+ ["ELEMENT_OL", constants_4.ELEMENT_OL],
43
+ ["ELEMENT_LI", constants_4.ELEMENT_LI],
44
+ ["ELEMENT_LIC", constants_4.ELEMENT_LIC],
45
+ ...constants_2.KEYS_HEADING.map((key) => [`KEYS_HEADING ${key}`, key]),
46
+ ])("%s addresses a registered plugin", (_name, key) => {
47
+ expect(editor.plugins[key]).toBeDefined();
48
+ });
49
+ it("keeps the list keys as the stored element names", () => {
50
+ expect([constants_4.ELEMENT_UL, constants_4.ELEMENT_OL, constants_4.ELEMENT_LI, constants_4.ELEMENT_LIC]).toEqual(["ul", "ol", "li", "lic"]);
51
+ });
52
+ });
@@ -0,0 +1,6 @@
1
+ /** Plate 53 no longer exports `EmbedUrlData`, so the shape `parseVideoUrl` returns is declared here. */
2
+ export interface EmbedUrlData {
3
+ id?: string;
4
+ provider?: string;
5
+ url?: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export { parseIframeUrl, parseTwitterUrl, parseVideoUrl } from "@udecode/plate-media";
1
+ export { parseIframeUrl, parseTwitterUrl, parseVideoUrl } from "@platejs/media";
2
+ export type { EmbedUrlData } from "./types";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseVideoUrl = exports.parseTwitterUrl = exports.parseIframeUrl = void 0;
4
- var plate_media_1 = require("@udecode/plate-media");
5
- Object.defineProperty(exports, "parseIframeUrl", { enumerable: true, get: function () { return plate_media_1.parseIframeUrl; } });
6
- Object.defineProperty(exports, "parseTwitterUrl", { enumerable: true, get: function () { return plate_media_1.parseTwitterUrl; } });
7
- Object.defineProperty(exports, "parseVideoUrl", { enumerable: true, get: function () { return plate_media_1.parseVideoUrl; } });
4
+ var media_1 = require("@platejs/media");
5
+ Object.defineProperty(exports, "parseIframeUrl", { enumerable: true, get: function () { return media_1.parseIframeUrl; } });
6
+ Object.defineProperty(exports, "parseTwitterUrl", { enumerable: true, get: function () { return media_1.parseTwitterUrl; } });
7
+ Object.defineProperty(exports, "parseVideoUrl", { enumerable: true, get: function () { return media_1.parseVideoUrl; } });
@@ -1,4 +1,11 @@
1
- import { MediaPlugin } from "@udecode/plate-media";
2
- import { WysiwygContent } from "../../../types";
3
1
  export declare const ELEMENT_VIDEO_EMBED = "video";
4
- export declare const createVideoPlugin: <OP = MediaPlugin, OV extends import("@udecode/slate").Value = WysiwygContent, OE extends import("@udecode/plate-core").PlateEditor<OV> = import("@udecode/plate-core").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>;
2
+ /**
3
+ * Custom, as in Plate 20 – Plate's own `media_embed` uses a different node type. `transformUrl` and
4
+ * `rules` are inert; kept so the options object a consumer can read is unchanged.
5
+ */
6
+ export declare const createVideoPlugin: import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"video", {
7
+ rules: {
8
+ parser: (url: string) => import("@platejs/media").EmbedUrlData | undefined;
9
+ }[];
10
+ transformUrl: (url: string) => string;
11
+ }, {}, {}, {}>>;
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createVideoPlugin = exports.ELEMENT_VIDEO_EMBED = void 0;
4
- const plate_core_1 = require("@udecode/plate-core");
4
+ const react_1 = require("platejs/react");
5
5
  const utils_1 = require("../utils");
6
6
  exports.ELEMENT_VIDEO_EMBED = "video";
7
- exports.createVideoPlugin = (0, plate_core_1.createPluginFactory)({
7
+ /**
8
+ * Custom, as in Plate 20 – Plate's own `media_embed` uses a different node type. `transformUrl` and
9
+ * `rules` are inert; kept so the options object a consumer can read is unchanged.
10
+ */
11
+ exports.createVideoPlugin = (0, react_1.createPlatePlugin)({
8
12
  key: exports.ELEMENT_VIDEO_EMBED,
9
- isElement: true,
10
- isVoid: true,
13
+ node: { isElement: true, isVoid: true },
11
14
  options: {
15
+ rules: [{ parser: utils_1.parseVideoUrl }],
12
16
  transformUrl: utils_1.parseIframeUrl,
13
- rules: [
14
- {
15
- parser: utils_1.parseVideoUrl,
16
- },
17
- ],
18
17
  },
19
18
  });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const platejs_1 = require("platejs");
4
+ const create_button_plugin_1 = require("../../button/create-button-plugin");
5
+ const create_paragraph_plugin_1 = require("../../paragraph/create-paragraph-plugin");
6
+ const utils_1 = require("../utils");
7
+ const create_video_plugin_1 = require("./create-video-plugin");
8
+ const editor = (0, platejs_1.createSlateEditor)({
9
+ plugins: [(0, create_paragraph_plugin_1.createParagraphPlugin)(), create_video_plugin_1.createVideoPlugin, create_button_plugin_1.createButtonPlugin],
10
+ });
11
+ describe("video", () => {
12
+ it("registers a void element under the stored type", () => {
13
+ expect(editor.plugins.video.node.type).toBe("video");
14
+ expect(editor.plugins.video.node.isVoid).toBe(true);
15
+ });
16
+ // toMatchObject, not toEqual: Plate 53 adds sourceKind and sourceUrl, which nothing here reads.
17
+ it("still parses a youtube url into id, provider and embed url", () => {
18
+ expect((0, utils_1.parseVideoUrl)("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toMatchObject({
19
+ id: "dQw4w9WgXcQ",
20
+ provider: "youtube",
21
+ url: "https://www.youtube.com/embed/dQw4w9WgXcQ",
22
+ });
23
+ });
24
+ });
25
+ describe("button", () => {
26
+ it("registers a void element under the stored type", () => {
27
+ expect(editor.plugins.button.node.type).toBe("button");
28
+ expect(editor.plugins.button.node.isVoid).toBe(true);
29
+ });
30
+ });
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateVideo = void 0;
4
- const plate_common_1 = require("@udecode/plate-common");
5
- const updateVideo = (editor, url, embeddedUrl, provider, videoId, metaData) => (0, plate_common_1.setNodes)(editor, {
4
+ const updateVideo = (editor, url, embeddedUrl, provider, videoId, metaData) => editor.tf.setNodes({
6
5
  url,
7
6
  embeddedUrl,
8
7
  provider,
@@ -1,3 +1,8 @@
1
- import { ExitBreakPlugin } from "@udecode/plate-break";
2
- import { UxfEditor, WysiwygContent } from "../../types";
3
- export declare const createExitBreakPlugin: () => import("@udecode/plate-core").PlatePlugin<ExitBreakPlugin, WysiwygContent, UxfEditor>;
1
+ /**
2
+ * Plate 53 has no `options.rules` here; the two `mod` hotkeys are `shortcuts`. The third rule (Enter
3
+ * in an empty heading or quote) lives as `rules.break.empty` on those plugins.
4
+ */
5
+ export declare const createExitBreakPlugin: () => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"exitBreak", {}, {}, Record<"exitBreak", {
6
+ insert: (options: Omit<import("platejs").InsertExitBreakOptions, "reverse">) => true | undefined;
7
+ insertBefore: (options: Omit<import("platejs").InsertExitBreakOptions, "reverse">) => true | undefined;
8
+ }>, {}>>;
@@ -1,30 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExitBreakPlugin = void 0;
4
- const plate_break_1 = require("@udecode/plate-break");
5
- const types_1 = require("../blockquote/types");
6
- const constants_1 = require("../heading/constants");
7
- const createExitBreakPlugin = () => (0, plate_break_1.createExitBreakPlugin)({
8
- options: {
9
- rules: [
10
- {
11
- hotkey: "mod+enter",
12
- },
13
- {
14
- hotkey: "mod+shift+enter",
15
- before: true,
16
- },
17
- {
18
- hotkey: "enter",
19
- query: {
20
- start: true,
21
- end: true,
22
- allow: [...constants_1.KEYS_HEADING, types_1.BLOCKQUOTE_PLUGIN_KEY],
23
- },
24
- relative: true,
25
- level: 1,
26
- },
27
- ],
28
- },
4
+ const platejs_1 = require("platejs");
5
+ const react_1 = require("platejs/react");
6
+ /**
7
+ * Plate 53 has no `options.rules` here; the two `mod` hotkeys are `shortcuts`. The third rule (Enter
8
+ * in an empty heading or quote) lives as `rules.break.empty` on those plugins.
9
+ */
10
+ const createExitBreakPlugin = () => (0, react_1.toPlatePlugin)(platejs_1.ExitBreakPlugin).configure({
11
+ shortcuts: { insert: { keys: "mod+enter" }, insertBefore: { keys: "mod+shift+enter" } },
29
12
  });
30
13
  exports.createExitBreakPlugin = createExitBreakPlugin;
@@ -1,8 +1,17 @@
1
- import { HotkeyPlugin } from "@udecode/plate-common";
2
- import { WysiwygContent } from "../../types";
3
- export type HeadingPlugin = HotkeyPlugin;
4
1
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
5
2
  export interface HeadingsPluginOptions {
6
3
  disabledLevels?: HeadingLevel[];
7
4
  }
8
- export declare const createHeadingsPlugin: <OP = HeadingsPluginOptions, OV extends import("@udecode/slate").Value = WysiwygContent, OE extends import("@udecode/plate-core").PlateEditor<OV> = import("@udecode/plate-core").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>;
5
+ /**
6
+ * A wrapper plugin whose nested `plugins` are the enabled levels; a disabled level is left out, which
7
+ * is what makes `disabledLevels` work.
8
+ *
9
+ * `break.empty: "exit"` reproduces Plate 20's exit-break rule. Without it the inherited `splitReset`
10
+ * puts the new paragraph *before* the empty heading.
11
+ *
12
+ * No hotkeys, matching Plate 20 – its `mod+opt+N` condition tested an empty options object and never
13
+ * fired.
14
+ */
15
+ export declare const createHeadingsPlugin: (config?: {
16
+ options?: HeadingsPluginOptions;
17
+ }) => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"heading", {}, {}, {}, {}>>;
@@ -1,40 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHeadingsPlugin = void 0;
4
- const plate_common_1 = require("@udecode/plate-common");
4
+ const react_1 = require("@platejs/basic-nodes/react");
5
+ const react_2 = require("platejs/react");
5
6
  const constants_1 = require("./constants");
6
- exports.createHeadingsPlugin = (0, plate_common_1.createPluginFactory)({
7
- key: constants_1.HEADINGS_PLUGIN_KEY,
8
- then: (_editor, { options: { disabledLevels } = {} }) => {
9
- var _a;
10
- const plugins = [];
11
- for (let level = 1; level <= 6; level++) {
12
- if (disabledLevels === null || disabledLevels === void 0 ? void 0 : disabledLevels.find((e) => e === level)) {
13
- continue;
14
- }
15
- const key = constants_1.KEYS_HEADING[level - 1];
16
- const plugin = {
17
- key,
18
- isElement: true,
19
- deserializeHtml: {
20
- rules: [
21
- {
22
- validNodeName: `H${level}`,
23
- },
24
- ],
25
- },
26
- handlers: {
27
- onKeyDown: plate_common_1.onKeyDownToggleElement,
28
- },
29
- options: {},
30
- };
31
- if (level < 4 && ((_a = plugin.options) === null || _a === void 0 ? void 0 : _a.hotkey)) {
32
- plugin.options.hotkey = [`mod+opt+${level}`, `mod+shift+${level}`];
33
- }
34
- plugins.push(plugin);
35
- }
36
- return {
37
- plugins,
38
- };
39
- },
40
- });
7
+ const PLUGINS_BY_LEVEL = [react_1.H1Plugin, react_1.H2Plugin, react_1.H3Plugin, react_1.H4Plugin, react_1.H5Plugin, react_1.H6Plugin];
8
+ /**
9
+ * A wrapper plugin whose nested `plugins` are the enabled levels; a disabled level is left out, which
10
+ * is what makes `disabledLevels` work.
11
+ *
12
+ * `break.empty: "exit"` reproduces Plate 20's exit-break rule. Without it the inherited `splitReset`
13
+ * puts the new paragraph *before* the empty heading.
14
+ *
15
+ * No hotkeys, matching Plate 20 – its `mod+opt+N` condition tested an empty options object and never
16
+ * fired.
17
+ */
18
+ const createHeadingsPlugin = (config) => {
19
+ var _a, _b;
20
+ const disabledLevels = (_b = (_a = config === null || config === void 0 ? void 0 : config.options) === null || _a === void 0 ? void 0 : _a.disabledLevels) !== null && _b !== void 0 ? _b : [];
21
+ return (0, react_2.createPlatePlugin)({
22
+ key: constants_1.HEADINGS_PLUGIN_KEY,
23
+ plugins: PLUGINS_BY_LEVEL.filter((_, index) => !disabledLevels.includes((index + 1))).map((plugin) => plugin.configure({ rules: { break: { empty: "exit" } } })),
24
+ });
25
+ };
26
+ exports.createHeadingsPlugin = createHeadingsPlugin;
@@ -0,0 +1 @@
1
+ export {};