@uxf/wysiwyg 11.72.3 → 11.74.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 +3 -1
- package/package.json +3 -3
- package/translations/translations.d.ts +405 -5
- package/translations/translations.js +404 -4
- package/components.d.ts +0 -7
- package/components.js +0 -34
- package/config/icons-config.d.ts +0 -2
- package/config/icons-config.js +0 -5
- package/config/icons.d.ts +0 -183
- package/config/icons.js +0 -51
- package/create-all-plugins-with-ui.d.ts +0 -64
- package/create-all-plugins-with-ui.js +0 -127
- package/create-plugins-with-ui.d.ts +0 -4
- package/create-plugins-with-ui.js +0 -47
- package/hooks.d.ts +0 -9
- package/hooks.js +0 -20
- package/index.d.ts +0 -6
- package/index.js +0 -38
- package/plugins/blockquote/create-blockquote-plugin.d.ts +0 -3
- package/plugins/blockquote/create-blockquote-plugin.js +0 -9
- package/plugins/blockquote/types.d.ts +0 -2
- package/plugins/blockquote/types.js +0 -6
- package/plugins/button/constants.d.ts +0 -2
- package/plugins/button/constants.js +0 -5
- package/plugins/button/create-button-plugin.d.ts +0 -2
- package/plugins/button/create-button-plugin.js +0 -11
- package/plugins/button/index.d.ts +0 -3
- package/plugins/button/index.js +0 -23
- package/plugins/button/transforms/get-active-button.d.ts +0 -2
- package/plugins/button/transforms/get-active-button.js +0 -9
- package/plugins/button/transforms/index.d.ts +0 -4
- package/plugins/button/transforms/index.js +0 -11
- package/plugins/button/transforms/insert-button.d.ts +0 -2
- package/plugins/button/transforms/insert-button.js +0 -16
- package/plugins/button/transforms/is-button-active.d.ts +0 -2
- package/plugins/button/transforms/is-button-active.js +0 -7
- package/plugins/button/transforms/remove-selected-button.d.ts +0 -2
- package/plugins/button/transforms/remove-selected-button.js +0 -13
- package/plugins/button/transforms/update-button.d.ts +0 -2
- package/plugins/button/transforms/update-button.js +0 -9
- package/plugins/embedded/utils.d.ts +0 -1
- package/plugins/embedded/utils.js +0 -7
- package/plugins/embedded/video/create-video-plugin.d.ts +0 -4
- package/plugins/embedded/video/create-video-plugin.js +0 -19
- package/plugins/embedded/video/get-active-video.d.ts +0 -2
- package/plugins/embedded/video/get-active-video.js +0 -9
- package/plugins/embedded/video/insert-video.d.ts +0 -2
- package/plugins/embedded/video/insert-video.js +0 -18
- package/plugins/embedded/video/update-video.d.ts +0 -2
- package/plugins/embedded/video/update-video.js +0 -11
- package/plugins/exit-break/create-exit-break-plugin.d.ts +0 -3
- package/plugins/exit-break/create-exit-break-plugin.js +0 -30
- package/plugins/heading/constants.d.ts +0 -8
- package/plugins/heading/constants.js +0 -11
- package/plugins/heading/create-headings-plugin.d.ts +0 -8
- package/plugins/heading/create-headings-plugin.js +0 -40
- package/plugins/highlight/createHighlightPlugin.d.ts +0 -3
- package/plugins/highlight/createHighlightPlugin.js +0 -27
- package/plugins/highlight/types.d.ts +0 -10
- package/plugins/highlight/types.js +0 -4
- package/plugins/image/create-image-plugin.d.ts +0 -6
- package/plugins/image/create-image-plugin.js +0 -105
- package/plugins/image/hooks/use-image-handlers.d.ts +0 -5
- package/plugins/image/hooks/use-image-handlers.js +0 -19
- package/plugins/image/transforms/get-active-image.d.ts +0 -2
- package/plugins/image/transforms/get-active-image.js +0 -9
- package/plugins/image/transforms/insert-image.d.ts +0 -3
- package/plugins/image/transforms/insert-image.js +0 -19
- package/plugins/image/transforms/is-image-active.d.ts +0 -2
- package/plugins/image/transforms/is-image-active.js +0 -7
- package/plugins/image/transforms/remove-selected-image.d.ts +0 -2
- package/plugins/image/transforms/remove-selected-image.js +0 -13
- package/plugins/image/transforms/update-image.d.ts +0 -3
- package/plugins/image/transforms/update-image.js +0 -12
- package/plugins/image/types.d.ts +0 -12
- package/plugins/image/types.js +0 -6
- package/plugins/image/utils/is-image-url.d.ts +0 -2
- package/plugins/image/utils/is-image-url.js +0 -135
- package/plugins/image/with-image.d.ts +0 -7
- package/plugins/image/with-image.js +0 -19
- package/plugins/image/with-paste-image-url.d.ts +0 -7
- package/plugins/image/with-paste-image-url.js +0 -36
- package/plugins/image/with-paste-image.d.ts +0 -7
- package/plugins/image/with-paste-image.js +0 -49
- package/plugins/link/constants.d.ts +0 -2
- package/plugins/link/constants.js +0 -6
- package/plugins/link/create-link-plugin.d.ts +0 -3
- package/plugins/link/create-link-plugin.js +0 -15
- package/plugins/link/floating-link-wrapper.d.ts +0 -11
- package/plugins/link/floating-link-wrapper.js +0 -26
- package/plugins/link/hooks/index.d.ts +0 -4
- package/plugins/link/hooks/index.js +0 -11
- package/plugins/link/hooks/use-link-actions.d.ts +0 -12
- package/plugins/link/hooks/use-link-actions.js +0 -48
- package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +0 -1
- package/plugins/link/hooks/use-link-cancel-on-escape.js +0 -5
- package/plugins/link/hooks/use-link-submit-on-enter.d.ts +0 -1
- package/plugins/link/hooks/use-link-submit-on-enter.js +0 -23
- package/plugins/link/transforms/get-active-link.d.ts +0 -3
- package/plugins/link/transforms/get-active-link.js +0 -17
- package/plugins/link/transforms/insert-link.d.ts +0 -2
- package/plugins/link/transforms/insert-link.js +0 -27
- package/plugins/link/transforms/is-link-selected.d.ts +0 -2
- package/plugins/link/transforms/is-link-selected.js +0 -15
- package/plugins/link/transforms/submit-link.d.ts +0 -8
- package/plugins/link/transforms/submit-link.js +0 -36
- package/plugins/link/transforms/trigger-link-insert-or-edit.d.ts +0 -2
- package/plugins/link/transforms/trigger-link-insert-or-edit.js +0 -6
- package/plugins/link/transforms/unwrap-link.d.ts +0 -2
- package/plugins/link/transforms/unwrap-link.js +0 -10
- package/plugins/link/types.d.ts +0 -5
- package/plugins/link/types.js +0 -2
- package/plugins/list/constants.d.ts +0 -4
- package/plugins/list/constants.js +0 -14
- package/plugins/list/create-list-plugin.d.ts +0 -4
- package/plugins/list/create-list-plugin.js +0 -16
- package/plugins/mark-bold/create-bold-plugin.d.ts +0 -3
- package/plugins/mark-bold/create-bold-plugin.js +0 -6
- package/plugins/mark-bold/types.d.ts +0 -2
- package/plugins/mark-bold/types.js +0 -6
- package/plugins/mark-code/create-code-plugin.d.ts +0 -3
- package/plugins/mark-code/create-code-plugin.js +0 -6
- package/plugins/mark-code/types.d.ts +0 -2
- package/plugins/mark-code/types.js +0 -6
- package/plugins/mark-italic/create-italic-plugin.d.ts +0 -3
- package/plugins/mark-italic/create-italic-plugin.js +0 -6
- package/plugins/mark-italic/types.d.ts +0 -2
- package/plugins/mark-italic/types.js +0 -6
- package/plugins/mark-underline/create-underline-plugin.d.ts +0 -3
- package/plugins/mark-underline/create-underline-plugin.js +0 -6
- package/plugins/mark-underline/types.d.ts +0 -2
- package/plugins/mark-underline/types.js +0 -6
- package/plugins/node-id/add-ids-to-nodes.d.ts +0 -2
- package/plugins/node-id/add-ids-to-nodes.js +0 -22
- package/plugins/node-id/create-node-id-plugin.d.ts +0 -3
- package/plugins/node-id/create-node-id-plugin.js +0 -6
- package/plugins/paragraph/create-paragraph-plugin.d.ts +0 -3
- package/plugins/paragraph/create-paragraph-plugin.js +0 -9
- package/plugins/paragraph/types.d.ts +0 -2
- package/plugins/paragraph/types.js +0 -6
- 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
- package/plugins/trailing-block/create-trailing-block-plugin.d.ts +0 -3
- package/plugins/trailing-block/create-trailing-block-plugin.js +0 -6
- package/serializers/serialize-to-plaintext.d.ts +0 -2
- package/serializers/serialize-to-plaintext.js +0 -8
- package/translations/context.d.ts +0 -2
- package/translations/context.js +0 -9
- package/translations/cs.d.ts +0 -52
- package/translations/cs.js +0 -55
- package/translations/en.d.ts +0 -2
- package/translations/en.js +0 -55
- package/translations/sk.d.ts +0 -2
- package/translations/sk.js +0 -55
- package/types.d.ts +0 -102
- package/types.js +0 -2
- package/ui/blockquote-element.d.ts +0 -2
- package/ui/blockquote-element.js +0 -13
- package/ui/bold-mark.d.ts +0 -2
- package/ui/bold-mark.js +0 -13
- package/ui/button/button-element.d.ts +0 -2
- package/ui/button/button-element.js +0 -54
- package/ui/button/index.d.ts +0 -1
- package/ui/button/index.js +0 -5
- package/ui/button/insert-button-modal-content.d.ts +0 -8
- package/ui/button/insert-button-modal-content.js +0 -81
- package/ui/code-mark.d.ts +0 -2
- package/ui/code-mark.js +0 -13
- package/ui/components/element/element-action-buttons.d.ts +0 -9
- package/ui/components/element/element-action-buttons.js +0 -22
- package/ui/components/element/element-with-action-buttons.d.ts +0 -10
- package/ui/components/element/element-with-action-buttons.js +0 -17
- package/ui/components/modal/modal-button-cancel.d.ts +0 -9
- package/ui/components/modal/modal-button-cancel.js +0 -45
- package/ui/components/modal/modal-button-submit.d.ts +0 -6
- package/ui/components/modal/modal-button-submit.js +0 -12
- package/ui/components/modal/modal-buttons.d.ts +0 -11
- package/ui/components/modal/modal-buttons.js +0 -16
- package/ui/components/modal/modal-content.d.ts +0 -6
- package/ui/components/modal/modal-content.js +0 -14
- package/ui/create-uxf-ui.d.ts +0 -21
- package/ui/create-uxf-ui.js +0 -51
- package/ui/floating-link.d.ts +0 -2
- package/ui/floating-link.js +0 -110
- package/ui/heading-elements.d.ts +0 -7
- package/ui/heading-elements.js +0 -38
- package/ui/highlight-mark.d.ts +0 -3
- package/ui/highlight-mark.js +0 -13
- package/ui/image/image-element.d.ts +0 -2
- package/ui/image/image-element.js +0 -53
- package/ui/image/insert-image-modal-content.d.ts +0 -8
- package/ui/image/insert-image-modal-content.js +0 -87
- package/ui/italic-mark.d.ts +0 -2
- package/ui/italic-mark.js +0 -13
- package/ui/link-element.d.ts +0 -3
- package/ui/link-element.js +0 -14
- package/ui/list-item-element.d.ts +0 -2
- package/ui/list-item-element.js +0 -13
- package/ui/list-ordered-element.d.ts +0 -2
- package/ui/list-ordered-element.js +0 -13
- package/ui/list-unordered-element.d.ts +0 -2
- package/ui/list-unordered-element.js +0 -13
- package/ui/paragraph-element.d.ts +0 -2
- package/ui/paragraph-element.js +0 -13
- package/ui/toolbar/buttons/button-toolbar-button.d.ts +0 -10
- package/ui/toolbar/buttons/button-toolbar-button.js +0 -20
- package/ui/toolbar/buttons/element-toolbar-button.d.ts +0 -12
- package/ui/toolbar/buttons/element-toolbar-button.js +0 -25
- package/ui/toolbar/buttons/image-toolbar-button.d.ts +0 -10
- package/ui/toolbar/buttons/image-toolbar-button.js +0 -20
- package/ui/toolbar/buttons/link-toolbar-button.d.ts +0 -10
- package/ui/toolbar/buttons/link-toolbar-button.js +0 -29
- package/ui/toolbar/buttons/list-toolbar-button.d.ts +0 -13
- package/ui/toolbar/buttons/list-toolbar-button.js +0 -27
- package/ui/toolbar/buttons/mark-toolbar-button.d.ts +0 -13
- package/ui/toolbar/buttons/mark-toolbar-button.js +0 -25
- package/ui/toolbar/buttons/modal-toolbar-button.d.ts +0 -15
- package/ui/toolbar/buttons/modal-toolbar-button.js +0 -22
- package/ui/toolbar/buttons/toolbar-button.d.ts +0 -15
- package/ui/toolbar/buttons/toolbar-button.js +0 -35
- package/ui/toolbar/buttons/undo-redo-button-group.d.ts +0 -8
- package/ui/toolbar/buttons/undo-redo-button-group.js +0 -64
- package/ui/toolbar/buttons/video-toolbar-button.d.ts +0 -10
- package/ui/toolbar/buttons/video-toolbar-button.js +0 -20
- package/ui/toolbar/toolbar.d.ts +0 -3
- package/ui/toolbar/toolbar.js +0 -77
- package/ui/toolbar/types.d.ts +0 -8
- package/ui/toolbar/types.js +0 -2
- package/ui/underline-mark.d.ts +0 -2
- package/ui/underline-mark.js +0 -13
- package/ui/utils.d.ts +0 -2
- package/ui/utils.js +0 -13
- package/ui/video/insert-video-modal-content.d.ts +0 -8
- package/ui/video/insert-video-modal-content.js +0 -76
- package/ui/video/video-element.d.ts +0 -2
- package/ui/video/video-element.js +0 -55
- package/utils/url-helper.d.ts +0 -7
- package/utils/url-helper.js +0 -15
- package/utils/url-helper.test.d.ts +0 -1
- package/utils/url-helper.test.js +0 -37
- package/utils.d.ts +0 -30
- package/utils.js +0 -88
- package/wysiwyg-editor.d.ts +0 -17
- package/wysiwyg-editor.js +0 -44
- package/wysiwyg-editor.stories.d.ts +0 -5
- package/wysiwyg-editor.stories.js +0 -193
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
-
},
|
|
29
|
-
});
|
|
30
|
-
exports.createExitBreakPlugin = createExitBreakPlugin;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const ELEMENT_H1 = "h1";
|
|
2
|
-
export declare const ELEMENT_H2 = "h2";
|
|
3
|
-
export declare const ELEMENT_H3 = "h3";
|
|
4
|
-
export declare const ELEMENT_H4 = "h4";
|
|
5
|
-
export declare const ELEMENT_H5 = "h5";
|
|
6
|
-
export declare const ELEMENT_H6 = "h6";
|
|
7
|
-
export declare const KEYS_HEADING: string[];
|
|
8
|
-
export declare const HEADINGS_PLUGIN_KEY = "heading";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HEADINGS_PLUGIN_KEY = exports.KEYS_HEADING = exports.ELEMENT_H6 = exports.ELEMENT_H5 = exports.ELEMENT_H4 = exports.ELEMENT_H3 = exports.ELEMENT_H2 = exports.ELEMENT_H1 = void 0;
|
|
4
|
-
exports.ELEMENT_H1 = "h1";
|
|
5
|
-
exports.ELEMENT_H2 = "h2";
|
|
6
|
-
exports.ELEMENT_H3 = "h3";
|
|
7
|
-
exports.ELEMENT_H4 = "h4";
|
|
8
|
-
exports.ELEMENT_H5 = "h5";
|
|
9
|
-
exports.ELEMENT_H6 = "h6";
|
|
10
|
-
exports.KEYS_HEADING = [exports.ELEMENT_H1, exports.ELEMENT_H2, exports.ELEMENT_H3, exports.ELEMENT_H4, exports.ELEMENT_H5, exports.ELEMENT_H6];
|
|
11
|
-
exports.HEADINGS_PLUGIN_KEY = "heading";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HotkeyPlugin } from "@udecode/plate-common";
|
|
2
|
-
import { WysiwygContent } from "../../types";
|
|
3
|
-
export type HeadingPlugin = HotkeyPlugin;
|
|
4
|
-
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
-
export interface HeadingsPluginOptions {
|
|
6
|
-
disabledLevels?: HeadingLevel[];
|
|
7
|
-
}
|
|
8
|
-
export declare const createHeadingsPlugin: <OP = HeadingsPluginOptions, OV extends import("@udecode/plate-common").Value = WysiwygContent, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHeadingsPlugin = void 0;
|
|
4
|
-
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
-
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
|
-
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { WysiwygContent } from "../../types";
|
|
2
|
-
import { HighlightPluginOptions } from "./types";
|
|
3
|
-
export declare const createHighlightPlugin: (color?: HighlightPluginOptions["color"]) => import("@udecode/plate-common").PlatePlugin<HighlightPluginOptions, WysiwygContent, import("@udecode/plate-common").PlateEditor<WysiwygContent>>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHighlightPlugin = void 0;
|
|
4
|
-
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
-
const types_1 = require("./types");
|
|
6
|
-
const createHighlightPlugin = (color = "yellow") => (0, plate_common_1.createPluginFactory)({
|
|
7
|
-
key: types_1.HIGHLIGHT_PLUGIN_KEY,
|
|
8
|
-
isLeaf: true,
|
|
9
|
-
handlers: {
|
|
10
|
-
onKeyDown: plate_common_1.onKeyDownToggleMark,
|
|
11
|
-
},
|
|
12
|
-
deserializeHtml: {
|
|
13
|
-
rules: [
|
|
14
|
-
{
|
|
15
|
-
validNodeName: ["MARK"],
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
options: {
|
|
20
|
-
hotkey: "mod+shift+h",
|
|
21
|
-
color: color,
|
|
22
|
-
},
|
|
23
|
-
props: {
|
|
24
|
-
color: color,
|
|
25
|
-
},
|
|
26
|
-
})();
|
|
27
|
-
exports.createHighlightPlugin = createHighlightPlugin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ToggleMarkPlugin } from "@udecode/plate-core";
|
|
2
|
-
import { CSSProperties } from "react";
|
|
3
|
-
import { RenderLeafProps } from "../../types";
|
|
4
|
-
export declare const HIGHLIGHT_PLUGIN_KEY = "highlight";
|
|
5
|
-
export interface HighlightPluginOptions extends ToggleMarkPlugin {
|
|
6
|
-
color?: CSSProperties["color"];
|
|
7
|
-
}
|
|
8
|
-
export interface HighlightLeafElementProps extends RenderLeafProps {
|
|
9
|
-
color?: CSSProperties["color"];
|
|
10
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { WysiwygContent } from "../../types";
|
|
2
|
-
import { UxfImagePluginOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Enables support for images.
|
|
5
|
-
*/
|
|
6
|
-
export declare const createImagePlugin: <OP = UxfImagePluginOptions, 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,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createImagePlugin = void 0;
|
|
4
|
-
const plate_core_1 = require("@udecode/plate-core");
|
|
5
|
-
const insert_image_1 = require("./transforms/insert-image");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
|
-
const with_image_1 = require("./with-image");
|
|
8
|
-
/**
|
|
9
|
-
* Enables support for images.
|
|
10
|
-
*/
|
|
11
|
-
exports.createImagePlugin = (0, plate_core_1.createPluginFactory)({
|
|
12
|
-
key: types_1.IMAGE_PLUGIN_KEY,
|
|
13
|
-
type: types_1.IMAGE_PLUGIN_TYPE,
|
|
14
|
-
isElement: true,
|
|
15
|
-
isVoid: true,
|
|
16
|
-
withOverrides: with_image_1.withImage,
|
|
17
|
-
then: (editor, { options }) => ({
|
|
18
|
-
deserializeHtml: {
|
|
19
|
-
rules: [
|
|
20
|
-
{
|
|
21
|
-
validNodeName: "IMG",
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
// getNode: (el) => ({
|
|
25
|
-
// type,
|
|
26
|
-
// url: el.getAttribute("src"),
|
|
27
|
-
// }),
|
|
28
|
-
getNode: (el) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const url = (_a = el.getAttribute("src")) !== null && _a !== void 0 ? _a : "";
|
|
31
|
-
if (url) {
|
|
32
|
-
const request = new XMLHttpRequest();
|
|
33
|
-
request.open("GET", url, true);
|
|
34
|
-
request.responseType = "blob";
|
|
35
|
-
request.onload = () => {
|
|
36
|
-
const blob = request.response;
|
|
37
|
-
const file = new File([blob], "image-from-wysiwyg", {
|
|
38
|
-
type: blob.type,
|
|
39
|
-
});
|
|
40
|
-
if (!options.uploadImage) {
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
|
-
console.error("Missing uploadImage function in image plugin options!");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
options.uploadImage(file).then((response) => {
|
|
46
|
-
if (!options.getImageUrl) {
|
|
47
|
-
// eslint-disable-next-line no-console
|
|
48
|
-
console.error("Missing getImageUrl function in image plugin options!");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// async hack images will be at the end of the document :(
|
|
52
|
-
(0, insert_image_1.insertImage)(editor, response, undefined, undefined, undefined, options.getImageUrl(response));
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
request.onerror = () => console.error("Error receiving image.");
|
|
57
|
-
request.send();
|
|
58
|
-
// try {
|
|
59
|
-
// const imageResponse = await fetch(url, {
|
|
60
|
-
// mode: "cors",
|
|
61
|
-
// headers: {
|
|
62
|
-
// "Access-Control-Allow-Origin": "*",
|
|
63
|
-
// },
|
|
64
|
-
// });
|
|
65
|
-
// const blob = await imageResponse.blob();
|
|
66
|
-
// const file = new File([blob], "image-from-wysiwyg", {
|
|
67
|
-
// type: blob.type,
|
|
68
|
-
// });
|
|
69
|
-
// if (!options.uploadImage) {
|
|
70
|
-
// // eslint-disable-next-line no-console
|
|
71
|
-
// console.log("Missing uploadImage function in image plugin options!");
|
|
72
|
-
// return;
|
|
73
|
-
// }
|
|
74
|
-
//
|
|
75
|
-
// const fileResponse = await options.uploadImage(file);
|
|
76
|
-
//
|
|
77
|
-
// if (!options.getImageUrl) {
|
|
78
|
-
// // eslint-disable-next-line no-console
|
|
79
|
-
// console.log("Missing getImageUrl function in image plugin options!");
|
|
80
|
-
// return;
|
|
81
|
-
// }
|
|
82
|
-
// // async hack images will be at the end of the document :(
|
|
83
|
-
// insertImage(
|
|
84
|
-
// editor,
|
|
85
|
-
// fileResponse,
|
|
86
|
-
// undefined,
|
|
87
|
-
// undefined,
|
|
88
|
-
// undefined,
|
|
89
|
-
// options.getImageUrl(fileResponse),
|
|
90
|
-
// );
|
|
91
|
-
//
|
|
92
|
-
// return {
|
|
93
|
-
// type,
|
|
94
|
-
// file: fileResponse,
|
|
95
|
-
// url: options.getImageUrl(fileResponse),
|
|
96
|
-
// };
|
|
97
|
-
// } catch (e) {
|
|
98
|
-
// // eslint-disable-next-line no-console
|
|
99
|
-
// console.error("Image insert failed.");
|
|
100
|
-
// }
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useImageHandlers = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
const types_1 = require("../types");
|
|
6
|
-
const useImageHandlers = (editor) => {
|
|
7
|
-
const imagePluginOptions = (0, utils_1.getPluginOptions)(editor, types_1.IMAGE_PLUGIN_KEY);
|
|
8
|
-
if (!imagePluginOptions.uploadImage) {
|
|
9
|
-
throw new Error("Missing uploadImage function in image plugin options!");
|
|
10
|
-
}
|
|
11
|
-
if (!imagePluginOptions.getImageUrl) {
|
|
12
|
-
throw new Error("Missing getImageUrl function in image plugin options!");
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
uploadImage: imagePluginOptions.uploadImage,
|
|
16
|
-
getImageUrl: imagePluginOptions.getImageUrl,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.useImageHandlers = useImageHandlers;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getActiveImage = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
const types_1 = require("../types");
|
|
6
|
-
const getActiveImage = (editor) => {
|
|
7
|
-
return (0, utils_1.getActiveElement)(editor, types_1.IMAGE_PLUGIN_KEY);
|
|
8
|
-
};
|
|
9
|
-
exports.getActiveImage = getActiveImage;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.insertImage = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
const types_1 = require("../types");
|
|
6
|
-
const insertImage = (editor, file, alt, caption, source, url) => {
|
|
7
|
-
const text = { text: "" };
|
|
8
|
-
const image = {
|
|
9
|
-
type: types_1.IMAGE_PLUGIN_TYPE,
|
|
10
|
-
children: [text],
|
|
11
|
-
file,
|
|
12
|
-
alt,
|
|
13
|
-
caption,
|
|
14
|
-
source,
|
|
15
|
-
url: url,
|
|
16
|
-
};
|
|
17
|
-
(0, utils_1.insertVoid)(editor, image);
|
|
18
|
-
};
|
|
19
|
-
exports.insertImage = insertImage;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isImageActive = void 0;
|
|
4
|
-
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
-
const get_active_image_1 = require("./get-active-image");
|
|
6
|
-
const isImageActive = (editor) => Boolean((0, get_active_image_1.getActiveImage)(editor) && (0, plate_common_1.isRangeInSameBlock)(editor));
|
|
7
|
-
exports.isImageActive = isImageActive;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeSelectedImage = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
const get_active_image_1 = require("./get-active-image");
|
|
6
|
-
const removeSelectedImage = (editor) => {
|
|
7
|
-
const activeImage = (0, get_active_image_1.getActiveImage)(editor);
|
|
8
|
-
if (!activeImage) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return (0, utils_1.removeElement)(editor, activeImage);
|
|
12
|
-
};
|
|
13
|
-
exports.removeSelectedImage = removeSelectedImage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateImage = void 0;
|
|
4
|
-
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
-
const updateImage = (editor, file, alt, caption, source, url) => (0, plate_common_1.setNodes)(editor, {
|
|
6
|
-
file,
|
|
7
|
-
alt,
|
|
8
|
-
caption,
|
|
9
|
-
source,
|
|
10
|
-
url,
|
|
11
|
-
});
|
|
12
|
-
exports.updateImage = updateImage;
|
package/plugins/image/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MediaPlugin } from "@udecode/plate-media";
|
|
2
|
-
import { FileResponse } from "@uxf/core/types";
|
|
3
|
-
export declare const IMAGE_PLUGIN_KEY = "img";
|
|
4
|
-
export declare const IMAGE_PLUGIN_TYPE = "image";
|
|
5
|
-
export type GetImageUrlHandler = (file: FileResponse) => string;
|
|
6
|
-
export type ImageUploadHandler = (file: File) => Promise<FileResponse>;
|
|
7
|
-
export interface UxfImagePluginOptions extends MediaPlugin {
|
|
8
|
-
uploadImage?: ImageUploadHandler;
|
|
9
|
-
getImageUrl?: GetImageUrlHandler;
|
|
10
|
-
disableUploadOnPasteImageUrl?: boolean;
|
|
11
|
-
disableUploadOnPasteImage?: boolean;
|
|
12
|
-
}
|
package/plugins/image/types.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IMAGE_PLUGIN_TYPE = exports.IMAGE_PLUGIN_KEY = void 0;
|
|
4
|
-
const plate_media_1 = require("@udecode/plate-media");
|
|
5
|
-
exports.IMAGE_PLUGIN_KEY = plate_media_1.ELEMENT_IMAGE;
|
|
6
|
-
exports.IMAGE_PLUGIN_TYPE = "image";
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isImageUrl = exports.getImageExtension = void 0;
|
|
4
|
-
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
-
const imageExtensions = [
|
|
6
|
-
"ase",
|
|
7
|
-
"art",
|
|
8
|
-
"bmp",
|
|
9
|
-
"blp",
|
|
10
|
-
"cd5",
|
|
11
|
-
"cit",
|
|
12
|
-
"cpt",
|
|
13
|
-
"cr2",
|
|
14
|
-
"cut",
|
|
15
|
-
"dds",
|
|
16
|
-
"dib",
|
|
17
|
-
"djvu",
|
|
18
|
-
"egt",
|
|
19
|
-
"exif",
|
|
20
|
-
"gif",
|
|
21
|
-
"gpl",
|
|
22
|
-
"grf",
|
|
23
|
-
"icns",
|
|
24
|
-
"ico",
|
|
25
|
-
"iff",
|
|
26
|
-
"jng",
|
|
27
|
-
"jpeg",
|
|
28
|
-
"jpg",
|
|
29
|
-
"jfif",
|
|
30
|
-
"jp2",
|
|
31
|
-
"jps",
|
|
32
|
-
"lbm",
|
|
33
|
-
"max",
|
|
34
|
-
"miff",
|
|
35
|
-
"mng",
|
|
36
|
-
"msp",
|
|
37
|
-
"nitf",
|
|
38
|
-
"ota",
|
|
39
|
-
"pbm",
|
|
40
|
-
"pc1",
|
|
41
|
-
"pc2",
|
|
42
|
-
"pc3",
|
|
43
|
-
"pcf",
|
|
44
|
-
"pcx",
|
|
45
|
-
"pdn",
|
|
46
|
-
"pgm",
|
|
47
|
-
"PI1",
|
|
48
|
-
"PI2",
|
|
49
|
-
"PI3",
|
|
50
|
-
"pict",
|
|
51
|
-
"pct",
|
|
52
|
-
"pnm",
|
|
53
|
-
"pns",
|
|
54
|
-
"ppm",
|
|
55
|
-
"psb",
|
|
56
|
-
"psd",
|
|
57
|
-
"pdd",
|
|
58
|
-
"psp",
|
|
59
|
-
"px",
|
|
60
|
-
"pxm",
|
|
61
|
-
"pxr",
|
|
62
|
-
"qfx",
|
|
63
|
-
"raw",
|
|
64
|
-
"rle",
|
|
65
|
-
"sct",
|
|
66
|
-
"sgi",
|
|
67
|
-
"rgb",
|
|
68
|
-
"int",
|
|
69
|
-
"bw",
|
|
70
|
-
"tga",
|
|
71
|
-
"tiff",
|
|
72
|
-
"tif",
|
|
73
|
-
"vtf",
|
|
74
|
-
"xbm",
|
|
75
|
-
"xcf",
|
|
76
|
-
"xpm",
|
|
77
|
-
"3dv",
|
|
78
|
-
"amf",
|
|
79
|
-
"ai",
|
|
80
|
-
"awg",
|
|
81
|
-
"cgm",
|
|
82
|
-
"cdr",
|
|
83
|
-
"cmx",
|
|
84
|
-
"dxf",
|
|
85
|
-
"e2d",
|
|
86
|
-
"egt",
|
|
87
|
-
"eps",
|
|
88
|
-
"fs",
|
|
89
|
-
"gbr",
|
|
90
|
-
"odg",
|
|
91
|
-
"svg",
|
|
92
|
-
"stl",
|
|
93
|
-
"vrml",
|
|
94
|
-
"x3d",
|
|
95
|
-
"sxd",
|
|
96
|
-
"v2d",
|
|
97
|
-
"vnd",
|
|
98
|
-
"wmf",
|
|
99
|
-
"emf",
|
|
100
|
-
"art",
|
|
101
|
-
"xar",
|
|
102
|
-
"png",
|
|
103
|
-
"webp",
|
|
104
|
-
"jxr",
|
|
105
|
-
"hdp",
|
|
106
|
-
"wdp",
|
|
107
|
-
"cur",
|
|
108
|
-
"ecw",
|
|
109
|
-
"iff",
|
|
110
|
-
"lbm",
|
|
111
|
-
"liff",
|
|
112
|
-
"nrrd",
|
|
113
|
-
"pam",
|
|
114
|
-
"pcx",
|
|
115
|
-
"pgf",
|
|
116
|
-
"sgi",
|
|
117
|
-
"rgb",
|
|
118
|
-
"rgba",
|
|
119
|
-
"bw",
|
|
120
|
-
"int",
|
|
121
|
-
"inta",
|
|
122
|
-
"sid",
|
|
123
|
-
"ras",
|
|
124
|
-
"sun",
|
|
125
|
-
"tga",
|
|
126
|
-
];
|
|
127
|
-
const getImageExtension = (url) => new URL(url).pathname.split(".").pop();
|
|
128
|
-
exports.getImageExtension = getImageExtension;
|
|
129
|
-
const isImageUrl = (url) => {
|
|
130
|
-
if (!(0, plate_common_1.isUrl)(url)) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
return imageExtensions.includes((0, exports.getImageExtension)(url));
|
|
134
|
-
};
|
|
135
|
-
exports.isImageUrl = isImageUrl;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WithPlatePlugin } from "@udecode/plate-core";
|
|
2
|
-
import { UxfEditor, WysiwygContent } from "../../types";
|
|
3
|
-
import { UxfImagePluginOptions } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* @see withPasteImageUrl
|
|
6
|
-
*/
|
|
7
|
-
export declare const withImage: (editor: UxfEditor, plugin: WithPlatePlugin<UxfImagePluginOptions, WysiwygContent, UxfEditor>) => UxfEditor;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withImage = void 0;
|
|
4
|
-
const with_paste_image_1 = require("./with-paste-image");
|
|
5
|
-
const with_paste_image_url_1 = require("./with-paste-image-url");
|
|
6
|
-
/**
|
|
7
|
-
* @see withPasteImageUrl
|
|
8
|
-
*/
|
|
9
|
-
const withImage = (editor, plugin) => {
|
|
10
|
-
const { options: { disableUploadOnPasteImage, disableUploadOnPasteImageUrl }, } = plugin;
|
|
11
|
-
if (!disableUploadOnPasteImage) {
|
|
12
|
-
editor = (0, with_paste_image_1.withPasteImage)(editor, plugin);
|
|
13
|
-
}
|
|
14
|
-
if (!disableUploadOnPasteImageUrl) {
|
|
15
|
-
editor = (0, with_paste_image_url_1.withPasteImageUrl)(editor, plugin);
|
|
16
|
-
}
|
|
17
|
-
return editor;
|
|
18
|
-
};
|
|
19
|
-
exports.withImage = withImage;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WithPlatePlugin } from "@udecode/plate-core";
|
|
2
|
-
import { UxfEditor, WysiwygContent } from "../../types";
|
|
3
|
-
import { UxfImagePluginOptions } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* If inserted text is image url, upload image and insert it instead.
|
|
6
|
-
*/
|
|
7
|
-
export declare const withPasteImageUrl: (editor: UxfEditor, plugin: WithPlatePlugin<UxfImagePluginOptions, WysiwygContent, UxfEditor>) => UxfEditor;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withPasteImageUrl = void 0;
|
|
4
|
-
const insert_image_1 = require("./transforms/insert-image");
|
|
5
|
-
const is_image_url_1 = require("./utils/is-image-url");
|
|
6
|
-
/**
|
|
7
|
-
* If inserted text is image url, upload image and insert it instead.
|
|
8
|
-
*/
|
|
9
|
-
const withPasteImageUrl = (editor, plugin) => {
|
|
10
|
-
const { insertData } = editor;
|
|
11
|
-
const { options: { uploadImage, getImageUrl }, } = plugin;
|
|
12
|
-
editor.insertData = async (dataTransfer) => {
|
|
13
|
-
const text = dataTransfer.getData("text/plain");
|
|
14
|
-
if ((0, is_image_url_1.isImageUrl)(text)) {
|
|
15
|
-
const imageResponse = await fetch(text, { mode: "cors" });
|
|
16
|
-
const blob = await imageResponse.blob();
|
|
17
|
-
const file = new File([blob], "image-from-wysiwyg." + (0, is_image_url_1.getImageExtension)(text), { type: blob.type });
|
|
18
|
-
if (!uploadImage) {
|
|
19
|
-
// eslint-disable-next-line no-console
|
|
20
|
-
console.log("Missing uploadImage function in image plugin options!");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const fileResponse = await uploadImage(file);
|
|
24
|
-
if (!getImageUrl) {
|
|
25
|
-
// eslint-disable-next-line no-console
|
|
26
|
-
console.log("Missing getImageUrl function in image plugin options!");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
(0, insert_image_1.insertImage)(editor, fileResponse, "", "", "", getImageUrl(fileResponse));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
insertData(dataTransfer);
|
|
33
|
-
};
|
|
34
|
-
return editor;
|
|
35
|
-
};
|
|
36
|
-
exports.withPasteImageUrl = withPasteImageUrl;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WithPlatePlugin } from "@udecode/plate-core";
|
|
2
|
-
import { UxfEditor, WysiwygContent } from "../../types";
|
|
3
|
-
import { UxfImagePluginOptions } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* If image is pasted from clipboard, upload image and insert it.
|
|
6
|
-
*/
|
|
7
|
-
export declare const withPasteImage: (editor: UxfEditor, plugin: WithPlatePlugin<UxfImagePluginOptions, WysiwygContent, UxfEditor>) => UxfEditor;
|