@uxf/wysiwyg 11.128.2 → 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 +21 -53
  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
@@ -1,3 +1,22 @@
1
- import { NodeIdPlugin } from "@udecode/plate-node-id";
2
- import { UxfEditor, WysiwygContent } from "../../types";
3
- export declare const createNodeIdPlugin: () => import("@udecode/plate-core").PlatePlugin<NodeIdPlugin, WysiwygContent, UxfEditor>;
1
+ export declare const createNodeIdPlugin: () => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"nodeId", {
2
+ disableInsertOverrides?: boolean;
3
+ filterInline?: boolean;
4
+ filterText?: boolean;
5
+ idKey?: string;
6
+ initialValueIds?: false | "always" | "if-needed";
7
+ normalizeInitialValue?: boolean | null;
8
+ onDuplicateIdScan?: (stats: {
9
+ candidateCount: number;
10
+ duration: number;
11
+ existingCount: number;
12
+ visitedCount: number;
13
+ }) => void;
14
+ reuseId?: boolean;
15
+ idCreator?: () => any;
16
+ } & import("platejs").QueryNodeOptions, {}, {
17
+ nodeId: {
18
+ normalize: () => void;
19
+ };
20
+ } & Record<"nodeId", {
21
+ normalize(): void;
22
+ }>, {}>>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodeIdPlugin = void 0;
4
- const plate_node_id_1 = require("@udecode/plate-node-id");
5
- const createNodeIdPlugin = () => (0, plate_node_id_1.createNodeIdPlugin)();
4
+ const platejs_1 = require("platejs");
5
+ const react_1 = require("platejs/react");
6
+ const createNodeIdPlugin = () => (0, react_1.toPlatePlugin)(platejs_1.NodeIdPlugin);
6
7
  exports.createNodeIdPlugin = createNodeIdPlugin;
@@ -1,3 +1 @@
1
- import { HotkeyPlugin } from "@udecode/plate-core";
2
- import { UxfPlatePlugin } from "../../types";
3
- export declare const createParagraphPlugin: () => UxfPlatePlugin<HotkeyPlugin>;
1
+ export declare const createParagraphPlugin: () => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"p", {}, {}, {}, {}>>;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createParagraphPlugin = void 0;
4
- const plate_paragraph_1 = require("@udecode/plate-paragraph");
4
+ const platejs_1 = require("platejs");
5
+ const react_1 = require("platejs/react");
5
6
  const types_1 = require("./types");
6
- const createParagraphPlugin = () => (0, plate_paragraph_1.createParagraphPlugin)({
7
- type: types_1.PARAGRAPH_PLUGIN_TYPE,
8
- });
7
+ const createParagraphPlugin = () => (0, react_1.toPlatePlugin)(platejs_1.BaseParagraphPlugin).configure({ node: { type: types_1.PARAGRAPH_PLUGIN_TYPE } });
9
8
  exports.createParagraphPlugin = createParagraphPlugin;
@@ -1,2 +1,2 @@
1
- export declare const PARAGRAPH_PLUGIN_KEY = "p";
1
+ export declare const PARAGRAPH_PLUGIN_KEY: "p";
2
2
  export declare const PARAGRAPH_PLUGIN_TYPE = "paragraph";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PARAGRAPH_PLUGIN_TYPE = exports.PARAGRAPH_PLUGIN_KEY = void 0;
4
- const plate_paragraph_1 = require("@udecode/plate-paragraph");
5
- exports.PARAGRAPH_PLUGIN_KEY = plate_paragraph_1.ELEMENT_PARAGRAPH;
4
+ const platejs_1 = require("platejs");
5
+ exports.PARAGRAPH_PLUGIN_KEY = platejs_1.KEYS.p;
6
6
  exports.PARAGRAPH_PLUGIN_TYPE = "paragraph";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const platejs_1 = require("platejs");
4
+ const create_exit_break_plugin_1 = require("./exit-break/create-exit-break-plugin");
5
+ const create_paragraph_plugin_1 = require("./paragraph/create-paragraph-plugin");
6
+ const create_trailing_block_plugin_1 = require("./trailing-block/create-trailing-block-plugin");
7
+ describe("exit break", () => {
8
+ it("keeps both historical hotkeys", () => {
9
+ const editor = (0, platejs_1.createSlateEditor)({ plugins: [(0, create_exit_break_plugin_1.createExitBreakPlugin)()] });
10
+ expect(editor.plugins.exitBreak.shortcuts).toEqual({
11
+ insert: { keys: "mod+enter" },
12
+ insertBefore: { keys: "mod+shift+enter" },
13
+ });
14
+ });
15
+ });
16
+ describe("trailing block", () => {
17
+ it("uses the stored paragraph type, not the bare plugin key", () => {
18
+ const editor = (0, platejs_1.createSlateEditor)({ plugins: [(0, create_paragraph_plugin_1.createParagraphPlugin)(), (0, create_trailing_block_plugin_1.createTrailingBlockPlugin)()] });
19
+ expect(editor.plugins.trailingBlock.options.type).toBe("paragraph");
20
+ });
21
+ it("appends a paragraph after a trailing non-paragraph block", () => {
22
+ const editor = (0, platejs_1.createSlateEditor)({
23
+ plugins: [(0, create_paragraph_plugin_1.createParagraphPlugin)(), (0, create_trailing_block_plugin_1.createTrailingBlockPlugin)()],
24
+ shouldNormalizeEditor: true,
25
+ value: [{ children: [{ text: "citace" }], type: "blockquote" }],
26
+ });
27
+ expect(editor.children.map((node) => node.type)).toEqual(["blockquote", "paragraph"]);
28
+ });
29
+ });
@@ -1,3 +1,13 @@
1
- import { TrailingBlockPlugin } from "@udecode/plate-trailing-block";
2
- import { UxfPlatePlugin } from "../../types";
3
- export declare const createTrailingBlockPlugin: () => UxfPlatePlugin<TrailingBlockPlugin>;
1
+ /**
2
+ * `.extend()`, not `.configure()`: the plugin's own extension resolves `type` to the bare `"p"` key
3
+ * and overwrites anything `.configure` passes. Extensions apply in order, so ours has to be last.
4
+ */
5
+ export declare const createTrailingBlockPlugin: () => import("platejs/react").PlatePlugin<import("platejs").PluginConfig<"trailingBlock", {
6
+ type: string;
7
+ } & {
8
+ type: string;
9
+ } & {
10
+ insert?: (editor: import("platejs").SlateEditor, options: import("platejs").TrailingBlockInsertOptions) => void;
11
+ level?: number;
12
+ type?: string;
13
+ } & import("platejs").QueryNodeOptions, {}, {}, {}>>;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTrailingBlockPlugin = void 0;
4
- const plate_trailing_block_1 = require("@udecode/plate-trailing-block");
5
- const createTrailingBlockPlugin = () => (0, plate_trailing_block_1.createTrailingBlockPlugin)();
4
+ const platejs_1 = require("platejs");
5
+ const react_1 = require("platejs/react");
6
+ const types_1 = require("../paragraph/types");
7
+ /**
8
+ * `.extend()`, not `.configure()`: the plugin's own extension resolves `type` to the bare `"p"` key
9
+ * and overwrites anything `.configure` passes. Extensions apply in order, so ours has to be last.
10
+ */
11
+ const createTrailingBlockPlugin = () => (0, react_1.toPlatePlugin)(platejs_1.TrailingBlockPlugin).extend(() => ({ options: { type: types_1.PARAGRAPH_PLUGIN_TYPE } }));
6
12
  exports.createTrailingBlockPlugin = createTrailingBlockPlugin;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeToPlaintext = void 0;
4
- const slate_1 = require("slate");
4
+ const platejs_1 = require("platejs");
5
5
  const serializeToPlaintext = (nodes, keepIndentation = true) => {
6
- return nodes.map((n) => slate_1.Node.string(n)).join(keepIndentation ? "\n" : " ");
6
+ return nodes.map((n) => platejs_1.NodeApi.string(n)).join(keepIndentation ? "\n" : " ");
7
7
  };
8
8
  exports.serializeToPlaintext = serializeToPlaintext;
package/styles/styles.css CHANGED
@@ -46,6 +46,7 @@
46
46
  }
47
47
 
48
48
  &__editable {
49
+ outline: none; /* slate-react set this itself until 0.126; focus is shown by the wrapping input */
49
50
  overflow-wrap: anywhere !important; /* long links and texts wrap fix */
50
51
 
51
52
  > :first-child {
package/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { OverrideByKey, PlateEditor, PlateId, PlatePlugin, PlatePluginComponent, RenderAfterEditable as PlateRenderAfterEditable, PlateRenderElementProps, PlateRenderLeafProps, PluginOptions } from "@udecode/plate-core";
2
- import { TElement, TText } from "@udecode/slate";
3
1
  import { FileResponse } from "@uxf/core/types";
2
+ import { AnySlatePlugin, NodeComponent, TElement, TText } from "platejs";
3
+ import { AnyPlatePlugin, EditableSiblingComponent, PlateElementProps, PlateLeafProps, TPlateEditor } from "platejs/react";
4
4
  import { FC } from "react";
5
+ /** Plate 53 has no `PlateId`; kept as a name because it is part of this package's surface. */
6
+ export type PlateId = string;
5
7
  export type EmptyText = {
6
8
  text: "";
7
9
  };
@@ -89,30 +91,37 @@ export interface UxfButtonElement extends UxfBlockElement {
89
91
  children: [EmptyText];
90
92
  }
91
93
  export type WysiwygRootBlock = UxfParagraphElement | UxfBlockQuoteElement | UxfImageElement | UxfHeadingElement | UxfLinkElement | UxfUnorderedListElement | UxfOrderedListElement | UxfVideoElement | UxfButtonElement;
92
- export type UiComponents = Partial<Record<string, PlatePluginComponent>>;
94
+ export type UiComponents = Partial<Record<string, NodeComponent>>;
93
95
  export type WysiwygContent = WysiwygRootBlock[];
94
- export type RenderElementProps<E extends TElement = UxfBlockElement> = PlateRenderElementProps<WysiwygContent, E>;
96
+ /** `editor` is narrowed so components can pass `props.editor` to our transforms without a cast. */
97
+ export type RenderElementProps<E extends TElement = UxfBlockElement> = Omit<PlateElementProps<E>, "editor"> & {
98
+ editor: UxfEditor;
99
+ };
95
100
  export type ElementUiComponent<E extends TElement = UxfBlockElement> = FC<RenderElementProps<E>>;
96
- export type RenderLeafProps<L extends TText = RichText> = PlateRenderLeafProps<WysiwygContent, L>;
101
+ export type RenderLeafProps<L extends TText = RichText> = Omit<PlateLeafProps<L>, "editor"> & {
102
+ editor: UxfEditor;
103
+ };
97
104
  export type LeafUiComponent<L extends TText = RichText> = FC<RenderLeafProps<L>>;
98
- export type RenderAfterEditable = PlateRenderAfterEditable<WysiwygContent>;
99
- export type UxfEditor = PlateEditor<WysiwygContent> & {
105
+ export type RenderAfterEditable = EditableSiblingComponent;
106
+ export type UxfEditor = TPlateEditor<WysiwygContent> & {
100
107
  isDragging?: boolean;
101
108
  };
102
- export type UxfPlatePlugin<P = PluginOptions> = PlatePlugin<P, WysiwygContent, UxfEditor>;
109
+ /** Every plugin this package builds is a React plugin, so the list is one homogeneous type. */
110
+ export type AnyWysiwygPlatePlugin = AnyPlatePlugin;
111
+ /** Its Plate 20 type parameter is gone: no plugin type in Plate 53 is keyed on its options. */
112
+ export type UxfPlatePlugin = AnyWysiwygPlatePlugin;
103
113
  export interface WysiwygPlugin<E extends UxfBlockElement = UxfBlockElement> {
104
- plugin: UxfPlatePlugin;
114
+ plugin: AnyWysiwygPlatePlugin;
105
115
  component: ElementUiComponent<E> | LeafUiComponent;
106
116
  }
107
117
  /**
108
- * This is used when recursive plugin feature is used
109
- * @see https://plate.udecode.io/docs/plugins#plugins
110
- * E.g. Headings plugin
118
+ * For plugins that nest others, e.g. headings and lists.
119
+ * @see https://platejs.org/docs/plugin
111
120
  */
112
121
  export interface WysiwygRecursivePlugin<C extends string, E extends UxfBlockElement = UxfBlockElement> {
113
- plugin: UxfPlatePlugin;
122
+ plugin: AnyWysiwygPlatePlugin;
114
123
  components: {
115
124
  [key in C]: ElementUiComponent<E> | LeafUiComponent;
116
125
  };
117
126
  }
118
- export type MyOverrideByKey = OverrideByKey<WysiwygContent, UxfEditor>;
127
+ export type MyOverrideByKey = Record<string, Partial<AnySlatePlugin>>;
@@ -34,15 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FloatingLink = void 0;
37
- const plate_floating_1 = require("@udecode/plate-floating");
38
- const plate_link_1 = require("@udecode/plate-link");
37
+ const floating_1 = require("@platejs/floating");
38
+ const react_1 = require("@platejs/link/react");
39
39
  const translations_1 = require("@uxf/core-react/translations");
40
40
  const button_1 = require("@uxf/ui/button");
41
41
  const button_group_1 = require("@uxf/ui/button-group");
42
42
  const checkbox_input_1 = require("@uxf/ui/checkbox-input");
43
43
  const icon_1 = require("@uxf/ui/icon");
44
44
  const text_input_1 = require("@uxf/ui/text-input");
45
- const react_1 = __importStar(require("react"));
45
+ const react_2 = __importStar(require("react"));
46
46
  const hooks_1 = require("../hooks");
47
47
  const floating_link_wrapper_1 = require("../plugins/link/floating-link-wrapper");
48
48
  const hooks_2 = require("../plugins/link/hooks");
@@ -55,18 +55,18 @@ const Edit = () => {
55
55
  var _a, _b;
56
56
  const editor = (0, hooks_1.useUxfEditorRef)();
57
57
  const url = (_b = (_a = (0, get_active_link_1.getActiveLink)(editor)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : "";
58
- return (react_1.default.createElement(button_group_1.ButtonGroup, { className: EDIT_CLASS_NAME },
59
- react_1.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-edit`, isIconButton: true, onClick: () => (0, plate_link_1.triggerFloatingLinkEdit)(editor), variant: "secondary" },
60
- react_1.default.createElement(icon_1.Icon, { name: "edit", size: 15 })),
61
- react_1.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-open`, href: !url_helper_1.UrlHelper.hasProtocol(url) ? `https://${url}` : url, isIconButton: true, target: "_blank", variant: "secondary" },
62
- react_1.default.createElement(icon_1.Icon, { name: "open-link-in-new-tab", size: 15 })),
63
- react_1.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-delete`, isIconButton: true, onClick: () => (0, unwrap_link_1.removeLink)(editor), variant: "secondary" },
64
- react_1.default.createElement(icon_1.Icon, { name: "delete", size: 15 }))));
58
+ return (react_2.default.createElement(button_group_1.ButtonGroup, { className: EDIT_CLASS_NAME },
59
+ react_2.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-edit`, isIconButton: true, onClick: () => (0, react_1.triggerFloatingLinkEdit)(editor), variant: "secondary" },
60
+ react_2.default.createElement(icon_1.Icon, { name: "edit", size: 15 })),
61
+ react_2.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-open`, href: !url_helper_1.UrlHelper.hasProtocol(url) ? `https://${url}` : url, isIconButton: true, target: "_blank", variant: "secondary" },
62
+ react_2.default.createElement(icon_1.Icon, { name: "open-link-in-new-tab", size: 15 })),
63
+ react_2.default.createElement(button_1.Button, { className: `${EDIT_CLASS_NAME}__button ${EDIT_CLASS_NAME}__button-delete`, isIconButton: true, onClick: () => (0, unwrap_link_1.removeLink)(editor), variant: "secondary" },
64
+ react_2.default.createElement(icon_1.Icon, { name: "delete", size: 15 }))));
65
65
  };
66
66
  function useInsertLinkFormAutoFocus() {
67
- const id = (0, react_1.useId)();
67
+ const id = (0, react_2.useId)();
68
68
  // TODO FEB-139 - native html autoFocus breaks popover placement in insert mode
69
- (0, react_1.useEffect)(() => {
69
+ (0, react_2.useEffect)(() => {
70
70
  let timer;
71
71
  const firstInput = document.querySelector(`#${CSS.escape(id)}`);
72
72
  if (firstInput instanceof HTMLElement) {
@@ -83,7 +83,7 @@ const Insert = () => {
83
83
  const t = (0, translations_1.useUxfTranslation)();
84
84
  const linkActions = (0, hooks_2.useLinkActions)();
85
85
  const editor = (0, hooks_1.useUxfEditorRef)();
86
- const [isSubmitted, setIsSubmitted] = (0, react_1.useState)(false);
86
+ const [isSubmitted, setIsSubmitted] = (0, react_2.useState)(false);
87
87
  const firstInputId = useInsertLinkFormAutoFocus();
88
88
  const onSubmit = (e) => {
89
89
  e.preventDefault();
@@ -92,29 +92,29 @@ const Insert = () => {
92
92
  if (!linkActions.getUrl || !url_helper_1.UrlHelper.isValid(linkActions.getUrl)) {
93
93
  return;
94
94
  }
95
- (0, plate_link_1.submitFloatingLink)(editor);
95
+ (0, react_1.submitFloatingLink)(editor);
96
96
  };
97
97
  const emptyUrl = isSubmitted && !linkActions.getUrl;
98
98
  const invalidUrl = isSubmitted && !url_helper_1.UrlHelper.isValid(linkActions.getUrl);
99
- return (react_1.default.createElement("div", { className: INSERT_CLASS_NAME },
100
- react_1.default.createElement("form", { className: `${INSERT_CLASS_NAME}__form`, id: "insert-link-form", onSubmit: onSubmit },
101
- react_1.default.createElement("div", { className: `${INSERT_CLASS_NAME}__form-inputs` },
102
- react_1.default.createElement(text_input_1.TextInput, { helperText: emptyUrl
99
+ return (react_2.default.createElement("div", { className: INSERT_CLASS_NAME },
100
+ react_2.default.createElement("form", { className: `${INSERT_CLASS_NAME}__form`, id: "insert-link-form", onSubmit: onSubmit },
101
+ react_2.default.createElement("div", { className: `${INSERT_CLASS_NAME}__form-inputs` },
102
+ react_2.default.createElement(text_input_1.TextInput, { helperText: emptyUrl
103
103
  ? t("uxf-wysiwyg:plugins.link.url-address.required")
104
104
  : invalidUrl
105
105
  ? t("uxf-wysiwyg:plugins.link.url-address.invalid")
106
106
  : undefined, hiddenLabel: true, id: firstInputId, isInvalid: emptyUrl || invalidUrl, isRequired: true, label: t("uxf-wysiwyg:plugins.link.url-address.label"), leftAddon: t("uxf-wysiwyg:plugins.link.url-address.label"), name: "url-address", onChange: linkActions.setUrl, placeholder: t("uxf-wysiwyg:plugins.link.url-address.placeholder"), value: linkActions.getUrl }),
107
- react_1.default.createElement(text_input_1.TextInput, { hiddenLabel: true, label: t("uxf-wysiwyg:plugins.link.link-text.label"), leftAddon: t("uxf-wysiwyg:plugins.link.link-text.label"), name: "link-text", onChange: linkActions.setText, placeholder: t("uxf-wysiwyg:plugins.link.link-text.placeholder"), value: linkActions.getText }),
108
- react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: t("uxf-wysiwyg:plugins.link.open-in-new-tab"), name: "open-in-new-tab", onChange: (checked) => linkActions.setTarget(checked ? "_blank" : "_self"), value: linkActions.getTarget === "_blank" })),
109
- react_1.default.createElement("div", { className: `${INSERT_CLASS_NAME}__form-buttons` },
110
- react_1.default.createElement(button_1.Button, { className: `${INSERT_CLASS_NAME}__form-submit-button`, type: "submit" }, t("uxf-wysiwyg:plugins.link.button-save"))),
111
- react_1.default.createElement("button", { hidden: true, type: "submit" }))));
107
+ react_2.default.createElement(text_input_1.TextInput, { hiddenLabel: true, label: t("uxf-wysiwyg:plugins.link.link-text.label"), leftAddon: t("uxf-wysiwyg:plugins.link.link-text.label"), name: "link-text", onChange: linkActions.setText, placeholder: t("uxf-wysiwyg:plugins.link.link-text.placeholder"), value: linkActions.getText }),
108
+ react_2.default.createElement(checkbox_input_1.CheckboxInput, { label: t("uxf-wysiwyg:plugins.link.open-in-new-tab"), name: "open-in-new-tab", onChange: (checked) => linkActions.setTarget(checked ? "_blank" : "_self"), value: linkActions.getTarget === "_blank" })),
109
+ react_2.default.createElement("div", { className: `${INSERT_CLASS_NAME}__form-buttons` },
110
+ react_2.default.createElement(button_1.Button, { className: `${INSERT_CLASS_NAME}__form-submit-button`, type: "submit" }, t("uxf-wysiwyg:plugins.link.button-save"))),
111
+ react_2.default.createElement("button", { hidden: true, type: "submit" }))));
112
112
  };
113
113
  const FloatingLink = () => {
114
- const isEditing = (0, plate_link_1.useFloatingLinkSelectors)().isEditing();
115
- return (react_1.default.createElement(plate_floating_1.FloatingPortal, null,
116
- react_1.default.createElement(floating_link_wrapper_1.FloatingLinkWrapper.InsertRoot, null,
117
- react_1.default.createElement(Insert, null)),
118
- react_1.default.createElement(floating_link_wrapper_1.FloatingLinkWrapper.EditRoot, null, !isEditing ? react_1.default.createElement(Edit, null) : react_1.default.createElement(Insert, null))));
114
+ const isEditing = (0, hooks_2.useFloatingLinkSelectors)().isEditing();
115
+ return (react_2.default.createElement(floating_1.FloatingPortal, null,
116
+ react_2.default.createElement(floating_link_wrapper_1.FloatingLinkWrapper.InsertRoot, null,
117
+ react_2.default.createElement(Insert, null)),
118
+ react_2.default.createElement(floating_link_wrapper_1.FloatingLinkWrapper.EditRoot, null, !isEditing ? react_2.default.createElement(Edit, null) : react_2.default.createElement(Insert, null))));
119
119
  };
120
120
  exports.FloatingLink = FloatingLink;
@@ -1,3 +1,2 @@
1
- import { FC } from "react";
2
- import { HighlightLeafElementProps } from "../plugins/highlight/types";
3
- export declare const HighlightMark: FC<HighlightLeafElementProps>;
1
+ import { LeafUiComponent } from "../types";
2
+ export declare const HighlightMark: LeafUiComponent;
@@ -8,6 +8,9 @@ const react_1 = __importDefault(require("react"));
8
8
  const CLASS_NAME = "uxf-wysiwyg__element";
9
9
  const HighlightMark = (props) => {
10
10
  var _a;
11
- return (react_1.default.createElement("mark", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-highlight ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: { "--highlight-color": props.color } }, props.children));
11
+ // Not `node.props`: Plate 53 spreads those onto the DOM element as attributes rather than passing
12
+ // them to the component, so the colour has to come from the plugin's own options.
13
+ const color = props.getOptions().color;
14
+ return (react_1.default.createElement("mark", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-highlight ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: { "--highlight-color": color } }, props.children));
12
15
  };
13
16
  exports.HighlightMark = HighlightMark;
@@ -4,11 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LinkElement = void 0;
7
- const react_1 = __importDefault(require("react"));
7
+ const react_1 = require("@platejs/link/react");
8
+ const react_2 = __importDefault(require("react"));
8
9
  const CLASS_NAME = "uxf-wysiwyg__element";
9
10
  const LinkElement = (props) => {
10
11
  var _a;
11
- return (react_1.default.createElement("span", null,
12
- react_1.default.createElement("a", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-link ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, ...props.nodeProps }, props.children)));
12
+ // Plate 53 drops the `nodeProps` prop; the href/target pair comes from the plugin api, sanitised.
13
+ const linkAttributes = props.editor.getApi(react_1.LinkPlugin).link.getAttributes(props.element);
14
+ return (react_2.default.createElement("span", null,
15
+ react_2.default.createElement("a", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-link ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, ...linkAttributes }, props.children)));
13
16
  };
14
17
  exports.LinkElement = LinkElement;
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface ButtonToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName?: IconName;
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface ElementToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName: IconName;
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface ImageToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName?: IconName;
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface LinkToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName?: IconName;
@@ -21,7 +21,7 @@ const LinkToolbarButton = (props) => {
21
21
  const onMouseDown = () => {
22
22
  var _a;
23
23
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
- (0, utils_1.focusEditor)(editor, (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.prevSelection);
24
+ (0, utils_1.focusEditor)(editor, (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.dom.prevSelection);
25
25
  (0, trigger_link_insert_or_edit_1.triggerLinkInsertOrEdit)(editor, true);
26
26
  };
27
27
  return (react_1.default.createElement(toolbar_button_1.ToolbarButton, { className: `${CLASS_NAME} ${CLASS_NAME}-link ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, editor: editor, iconName: (_b = props.iconName) !== null && _b !== void 0 ? _b : "link", isActive: isLink, onMouseDown: onMouseDown, pluginKey: constants_1.ELEMENT_LINK, tooltipText: t("uxf-wysiwyg:plugins.link.tooltip") }));
@@ -1,7 +1,7 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
4
3
  import { LIST_ORDERED_TYPE, LIST_UNORDERED_TYPE } from "../../../plugins/list/constants";
4
+ import { PlateId } from "../../../types";
5
5
  interface ListToolbarButtonProps {
6
6
  className?: string;
7
7
  iconName: IconName;
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ListToolbarButton = void 0;
7
- const plate_list_1 = require("@udecode/plate-list");
8
7
  const is_nil_1 = require("@uxf/core/utils/is-nil");
9
8
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
9
  const react_1 = __importDefault(require("react"));
11
10
  const hooks_1 = require("../../../hooks");
11
+ const constants_1 = require("../../../plugins/list/constants");
12
12
  const utils_1 = require("../../../utils");
13
13
  const toolbar_button_1 = require("./toolbar-button");
14
14
  const CLASS_NAME = "uxf-wysiwyg__toolbar-button";
15
15
  function getIsListElementActive(editor, type) {
16
- const res = (0, is_not_nil_1.isNotNil)(editor.selection) ? (0, plate_list_1.getListItemEntry)(editor) : undefined;
16
+ const res = (0, is_not_nil_1.isNotNil)(editor.selection) ? (0, constants_1.getListItemEntry)(editor) : undefined;
17
17
  if ((0, is_nil_1.isNil)(res)) {
18
18
  return false;
19
19
  }
@@ -26,7 +26,7 @@ const ListToolbarButton = (props) => {
26
26
  const type = (0, utils_1.getPluginType)(editor, props.pluginKey);
27
27
  const isActive = getIsListElementActive(editor, type);
28
28
  const onMouseDown = () => {
29
- (0, plate_list_1.toggleList)(editor, {
29
+ (0, constants_1.toggleList)(editor, {
30
30
  type,
31
31
  });
32
32
  };
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface LeafToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName: IconName;
@@ -1,5 +1,5 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { FC } from "react";
2
+ import { PlateId } from "../../../types";
3
3
  interface Props {
4
4
  className?: string;
5
5
  plateId: PlateId;
@@ -1,6 +1,6 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { IconName } from "@uxf/ui/icon/types";
3
2
  import { FC } from "react";
3
+ import { PlateId } from "../../../types";
4
4
  interface EmbedMediaToolbarButtonProps {
5
5
  className?: string;
6
6
  iconName?: IconName;
@@ -1,5 +1,5 @@
1
- import { PlateId } from "@udecode/plate-core";
2
1
  import { HTMLAttributes, ReactNode } from "react";
2
+ import { PlateId } from "../../types";
3
3
  export interface ToolbarProps extends HTMLAttributes<HTMLDivElement> {
4
4
  customPluginsButtons?: ReactNode;
5
5
  leftElement?: ReactNode;
package/ui/utils.js CHANGED
@@ -7,7 +7,7 @@ const closeModalWithFocus = (editor) => {
7
7
  var _a;
8
8
  (0, modal_service_1.closeModal)();
9
9
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10
- const selection = (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.prevSelection;
10
+ const selection = (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.dom.prevSelection;
11
11
  (0, utils_1.focusEditor)(editor, selection);
12
12
  };
13
13
  exports.closeModalWithFocus = closeModalWithFocus;
package/utils.d.ts CHANGED
@@ -1,26 +1,24 @@
1
- import { PluginOptions, ToggleNodeTypeOptions } from "@udecode/plate-core";
2
- import { FindNodeOptions, GetNodeEntriesOptions } from "@udecode/slate";
3
- import { ToggleMarkOptions } from "@udecode/slate-utils";
4
- import { Location } from "slate";
1
+ import { At, EditorNodesOptions, QueryNodeOptions, TElement } from "platejs";
5
2
  import { UxfBlockElement, UxfEditor, WysiwygContent } from "./types";
6
- export declare const getUxfEditor: (editor: UxfEditor) => import("@udecode/utils").Modify<UxfEditor, {
7
- operations: import("@udecode/slate").TOperation<import("@udecode/slate").EElementOrText<WysiwygContent>>[];
8
- isInline: (element: import("@udecode/slate").TElement | import("./types").LicElement | import("./types").LiElement | import("./types").WysiwygRootBlock) => boolean;
9
- isVoid: (element: import("@udecode/slate").TElement | import("./types").LicElement | import("./types").LiElement | import("./types").WysiwygRootBlock) => boolean;
10
- normalizeNode: (entry: import("@udecode/slate").TNodeEntry<import("@udecode/slate").ENode<WysiwygContent>>) => void;
11
- apply: (operation: import("@udecode/slate").TOperation<import("@udecode/slate").EElementOrText<WysiwygContent>>) => void;
12
- getFragment: () => import("@udecode/slate").EElementOrText<WysiwygContent>[];
13
- insertFragment: (fragment: import("@udecode/slate").EElementOrText<WysiwygContent>[]) => void;
14
- insertNode: (node: import("@udecode/slate").EElementOrText<WysiwygContent> | import("@udecode/slate").EElementOrText<WysiwygContent>[]) => void;
15
- }>;
16
- export declare const getPluginOptions: <P = PluginOptions>(editor: UxfEditor, pluginKey: string) => P;
3
+ export declare const getUxfEditor: (editor: UxfEditor) => UxfEditor;
4
+ export declare const getPluginOptions: <P = object>(editor: UxfEditor, pluginKey: string) => P;
17
5
  export declare const getPluginType: (editor: UxfEditor, key: string) => string;
18
- export declare const someNode: (editor: UxfEditor, options: FindNodeOptions<WysiwygContent>) => boolean;
19
- export declare const toggleNodeType: (editor: UxfEditor, options: ToggleNodeTypeOptions, editorNodesOptions?: Omit<GetNodeEntriesOptions<WysiwygContent>, "match"> | undefined) => void;
20
- export declare const focusEditor: (editor: UxfEditor, target?: Location | undefined) => void;
6
+ export declare const someNode: (editor: UxfEditor, options: EditorNodesOptions<WysiwygContent>) => boolean;
7
+ export declare const toggleNodeType: (editor: UxfEditor, options: {
8
+ activeType?: string;
9
+ inactiveType?: string;
10
+ }, editorNodesOptions?: Omit<EditorNodesOptions<WysiwygContent>, "match">) => void;
11
+ export declare const focusEditor: (editor: UxfEditor, target?: At) => void;
21
12
  export declare const isRangeInSingleText: (editor: UxfEditor) => boolean;
22
13
  export declare const isMarkActive: (editor: UxfEditor, type: string) => boolean;
23
- export declare const toggleMark: (editor: UxfEditor, { key, clear }: ToggleMarkOptions) => void;
14
+ export declare const toggleMark: (editor: UxfEditor, { key, clear }: {
15
+ key: string;
16
+ clear?: string[] | string;
17
+ }) => void;
18
+ /**
19
+ * `editor.plugins` is a keyed record in Plate 53, not the array it was in Plate 20. Both helpers gate
20
+ * every toolbar button, so indexing it as an array here would hide the whole toolbar.
21
+ */
24
22
  export declare const isPluginEnabled: (editor: UxfEditor, pluginKey: string) => boolean;
25
23
  export declare const isSomeOfPluginsEnabled: (editor: UxfEditor, pluginKeys: string[]) => boolean;
26
24
  export declare const getSelectedNode: (editor: UxfEditor) => UxfBlockElement | null;
@@ -28,3 +26,4 @@ export declare const getActiveElement: <E extends UxfBlockElement = UxfBlockElem
28
26
  export declare const removeElement: (editor: UxfEditor, node: UxfBlockElement) => boolean;
29
27
  export declare const insertVoid: (editor: UxfEditor, node: UxfBlockElement) => void;
30
28
  export declare const removeSelectedNode: (editor: UxfEditor) => void;
29
+ export type { QueryNodeOptions, TElement };