@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.
- package/README.md +9 -7
- package/create-all-plugins-with-ui.d.ts +78 -14
- package/create-all-plugins-with-ui.js +3 -5
- package/create-plugins-with-ui.d.ts +2 -2
- package/create-plugins-with-ui.js +25 -30
- package/data-format.test.d.ts +1 -0
- package/data-format.test.js +132 -0
- package/editor-smoke.test.d.ts +1 -0
- package/editor-smoke.test.js +9 -0
- package/hooks.d.ts +1971 -8
- package/hooks.js +18 -11
- package/package.json +15 -47
- package/plugins/blockquote/create-blockquote-plugin.d.ts +9 -3
- package/plugins/blockquote/create-blockquote-plugin.js +31 -3
- package/plugins/blockquote/create-blockquote-plugin.test.d.ts +1 -0
- package/plugins/blockquote/create-blockquote-plugin.test.js +55 -0
- package/plugins/blockquote/types.d.ts +1 -1
- package/plugins/blockquote/types.js +2 -2
- package/plugins/button/create-button-plugin.d.ts +1 -2
- package/plugins/button/create-button-plugin.js +3 -5
- package/plugins/button/transforms/is-button-active.js +1 -2
- package/plugins/button/transforms/update-button.js +1 -2
- package/plugins/constants.test.d.ts +1 -0
- package/plugins/constants.test.js +52 -0
- package/plugins/embedded/types.d.ts +6 -0
- package/plugins/embedded/types.js +2 -0
- package/plugins/embedded/utils.d.ts +2 -1
- package/plugins/embedded/utils.js +4 -4
- package/plugins/embedded/video/create-video-plugin.d.ts +10 -3
- package/plugins/embedded/video/create-video-plugin.js +8 -9
- package/plugins/embedded/video/create-video-plugin.test.d.ts +1 -0
- package/plugins/embedded/video/create-video-plugin.test.js +30 -0
- package/plugins/embedded/video/update-video.js +1 -2
- package/plugins/exit-break/create-exit-break-plugin.d.ts +8 -3
- package/plugins/exit-break/create-exit-break-plugin.js +8 -25
- package/plugins/heading/create-headings-plugin.d.ts +13 -4
- package/plugins/heading/create-headings-plugin.js +22 -36
- package/plugins/heading/create-headings-plugin.test.d.ts +1 -0
- package/plugins/heading/create-headings-plugin.test.js +42 -0
- package/plugins/highlight/createHighlightPlugin.d.ts +4 -2
- package/plugins/highlight/createHighlightPlugin.js +8 -21
- package/plugins/highlight/types.d.ts +1 -2
- package/plugins/image/create-image-plugin.d.ts +3 -3
- package/plugins/image/create-image-plugin.js +58 -91
- package/plugins/image/create-image-plugin.test.d.ts +1 -0
- package/plugins/image/create-image-plugin.test.js +33 -0
- package/plugins/image/transforms/is-image-active.js +1 -2
- package/plugins/image/transforms/update-image.js +1 -2
- package/plugins/image/types.d.ts +6 -3
- package/plugins/image/types.js +2 -2
- package/plugins/image/utils/is-image-url.js +2 -2
- package/plugins/image/with-paste-image-url.d.ts +5 -5
- package/plugins/image/with-paste-image-url.js +29 -25
- package/plugins/image/with-paste-image.d.ts +4 -7
- package/plugins/image/with-paste-image.js +41 -39
- package/plugins/link/constants.d.ts +1 -1
- package/plugins/link/constants.js +2 -2
- package/plugins/link/create-link-plugin.d.ts +38 -3
- package/plugins/link/create-link-plugin.js +9 -7
- package/plugins/link/create-link-plugin.test.d.ts +1 -0
- package/plugins/link/create-link-plugin.test.js +24 -0
- package/plugins/link/floating-link-wrapper.d.ts +14 -7
- package/plugins/link/floating-link-wrapper.js +46 -17
- package/plugins/link/hooks/index.d.ts +1 -1
- package/plugins/link/hooks/index.js +2 -2
- package/plugins/link/hooks/use-floating-link-selectors.d.ts +8 -0
- package/plugins/link/hooks/use-floating-link-selectors.js +21 -0
- package/plugins/link/hooks/use-link-actions.d.ts +991 -8
- package/plugins/link/hooks/use-link-actions.js +22 -19
- package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +1 -1
- package/plugins/link/hooks/use-link-cancel-on-escape.js +2 -2
- package/plugins/link/hooks/use-link-submit-on-enter.js +5 -5
- package/plugins/link/transforms/get-active-link.d.ts +1 -1
- package/plugins/link/transforms/get-active-link.js +3 -5
- package/plugins/link/transforms/insert-link.js +9 -9
- package/plugins/link/transforms/submit-link.d.ts +2 -3
- package/plugins/link/transforms/submit-link.js +13 -13
- package/plugins/link/transforms/trigger-link-insert-or-edit.js +2 -2
- package/plugins/link/transforms/unwrap-link.js +2 -2
- package/plugins/list/constants.d.ts +11 -3
- package/plugins/list/constants.js +14 -10
- package/plugins/list/create-list-plugin.d.ts +26 -4
- package/plugins/list/create-list-plugin.js +13 -12
- package/plugins/list/create-list-plugin.test.d.ts +1 -0
- package/plugins/list/create-list-plugin.test.js +20 -0
- package/plugins/mark-bold/create-bold-plugin.d.ts +3 -3
- package/plugins/mark-bold/create-bold-plugin.js +2 -2
- package/plugins/mark-bold/types.d.ts +2 -2
- package/plugins/mark-bold/types.js +3 -3
- package/plugins/mark-code/create-code-plugin.d.ts +7 -3
- package/plugins/mark-code/create-code-plugin.js +6 -2
- package/plugins/mark-code/types.d.ts +2 -2
- package/plugins/mark-code/types.js +3 -3
- package/plugins/mark-italic/create-italic-plugin.d.ts +3 -3
- package/plugins/mark-italic/create-italic-plugin.js +2 -2
- package/plugins/mark-italic/types.d.ts +2 -2
- package/plugins/mark-italic/types.js +3 -3
- package/plugins/mark-underline/create-underline-plugin.d.ts +3 -3
- package/plugins/mark-underline/create-underline-plugin.js +2 -2
- package/plugins/mark-underline/types.d.ts +2 -2
- package/plugins/mark-underline/types.js +3 -3
- package/plugins/marks.test.d.ts +1 -0
- package/plugins/marks.test.js +42 -0
- package/plugins/node-id/add-ids-to-nodes.d.ts +1 -1
- package/plugins/node-id/create-node-id-plugin.d.ts +22 -3
- package/plugins/node-id/create-node-id-plugin.js +3 -2
- package/plugins/paragraph/create-paragraph-plugin.d.ts +1 -3
- package/plugins/paragraph/create-paragraph-plugin.js +3 -4
- package/plugins/paragraph/types.d.ts +1 -1
- package/plugins/paragraph/types.js +2 -2
- package/plugins/structural.test.d.ts +1 -0
- package/plugins/structural.test.js +29 -0
- package/plugins/trailing-block/create-trailing-block-plugin.d.ts +13 -3
- package/plugins/trailing-block/create-trailing-block-plugin.js +8 -2
- package/serializers/serialize-to-plaintext.js +2 -2
- package/styles/styles.css +1 -0
- package/types.d.ts +23 -14
- package/ui/floating-link.js +28 -28
- package/ui/highlight-mark.d.ts +2 -3
- package/ui/highlight-mark.js +4 -1
- package/ui/link-element.js +6 -3
- package/ui/toolbar/buttons/button-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/element-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/image-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/link-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/link-toolbar-button.js +1 -1
- package/ui/toolbar/buttons/list-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/list-toolbar-button.js +3 -3
- package/ui/toolbar/buttons/mark-toolbar-button.d.ts +1 -1
- package/ui/toolbar/buttons/undo-redo-button-group.d.ts +1 -1
- package/ui/toolbar/buttons/video-toolbar-button.d.ts +1 -1
- package/ui/toolbar/types.d.ts +1 -1
- package/ui/utils.js +1 -1
- package/utils.d.ts +18 -19
- package/utils.js +31 -28
- package/utils.test.d.ts +1 -0
- package/utils.test.js +23 -0
- package/wysiwyg-editor.d.ts +2 -2
- package/wysiwyg-editor.js +29 -23
- package/wysiwyg-editor.test.js +111 -6
- package/plugins/image/with-image.d.ts +0 -7
- package/plugins/image/with-image.js +0 -19
- package/plugins/reset-node/create-reset-node.d.ts +0 -3
- package/plugins/reset-node/create-reset-node.js +0 -28
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.d.ts +0 -3
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.js +0 -14
- package/plugins/soft-break/create-soft-break-plugin.d.ts +0 -3
- package/plugins/soft-break/create-soft-break-plugin.js +0 -22
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
5
|
-
const
|
|
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
|
-
|
|
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
|
|
4
|
+
const platejs_1 = require("platejs");
|
|
5
|
+
const react_1 = require("platejs/react");
|
|
5
6
|
const types_1 = require("./types");
|
|
6
|
-
const createParagraphPlugin = () => (0,
|
|
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
|
|
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
|
|
5
|
-
exports.PARAGRAPH_PLUGIN_KEY =
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
5
|
-
const
|
|
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
|
|
4
|
+
const platejs_1 = require("platejs");
|
|
5
5
|
const serializeToPlaintext = (nodes, keepIndentation = true) => {
|
|
6
|
-
return nodes.map((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
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,
|
|
94
|
+
export type UiComponents = Partial<Record<string, NodeComponent>>;
|
|
93
95
|
export type WysiwygContent = WysiwygRootBlock[];
|
|
94
|
-
|
|
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> =
|
|
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 =
|
|
99
|
-
export type UxfEditor =
|
|
105
|
+
export type RenderAfterEditable = EditableSiblingComponent;
|
|
106
|
+
export type UxfEditor = TPlateEditor<WysiwygContent> & {
|
|
100
107
|
isDragging?: boolean;
|
|
101
108
|
};
|
|
102
|
-
|
|
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:
|
|
114
|
+
plugin: AnyWysiwygPlatePlugin;
|
|
105
115
|
component: ElementUiComponent<E> | LeafUiComponent;
|
|
106
116
|
}
|
|
107
117
|
/**
|
|
108
|
-
*
|
|
109
|
-
* @see https://
|
|
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:
|
|
122
|
+
plugin: AnyWysiwygPlatePlugin;
|
|
114
123
|
components: {
|
|
115
124
|
[key in C]: ElementUiComponent<E> | LeafUiComponent;
|
|
116
125
|
};
|
|
117
126
|
}
|
|
118
|
-
export type MyOverrideByKey =
|
|
127
|
+
export type MyOverrideByKey = Record<string, Partial<AnySlatePlugin>>;
|
package/ui/floating-link.js
CHANGED
|
@@ -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
|
|
38
|
-
const
|
|
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
|
|
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 (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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,
|
|
67
|
+
const id = (0, react_2.useId)();
|
|
68
68
|
// TODO FEB-139 - native html autoFocus breaks popover placement in insert mode
|
|
69
|
-
(0,
|
|
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,
|
|
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,
|
|
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 (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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,
|
|
115
|
-
return (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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;
|
package/ui/highlight-mark.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const HighlightMark: FC<HighlightLeafElementProps>;
|
|
1
|
+
import { LeafUiComponent } from "../types";
|
|
2
|
+
export declare const HighlightMark: LeafUiComponent;
|
package/ui/highlight-mark.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/ui/link-element.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
12
|
-
|
|
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;
|
|
@@ -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,
|
|
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,
|
|
29
|
+
(0, constants_1.toggleList)(editor, {
|
|
30
30
|
type,
|
|
31
31
|
});
|
|
32
32
|
};
|
package/ui/toolbar/types.d.ts
CHANGED
|
@@ -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 {
|
|
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) =>
|
|
7
|
-
|
|
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:
|
|
19
|
-
export declare const toggleNodeType: (editor: UxfEditor, options:
|
|
20
|
-
|
|
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 }:
|
|
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 };
|