@uxf/wysiwyg 11.74.0 → 11.74.2
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/components.d.ts +7 -0
- package/components.js +34 -0
- package/config/icons-config.d.ts +2 -0
- package/config/icons-config.js +5 -0
- package/config/icons.d.ts +183 -0
- package/config/icons.js +51 -0
- package/create-all-plugins-with-ui.d.ts +64 -0
- package/create-all-plugins-with-ui.js +127 -0
- package/create-plugins-with-ui.d.ts +4 -0
- package/create-plugins-with-ui.js +47 -0
- package/hooks.d.ts +9 -0
- package/hooks.js +20 -0
- package/index.d.ts +6 -0
- package/index.js +38 -0
- package/package.json +3 -3
- package/plugins/blockquote/create-blockquote-plugin.d.ts +3 -0
- package/plugins/blockquote/create-blockquote-plugin.js +9 -0
- package/plugins/blockquote/types.d.ts +2 -0
- package/plugins/blockquote/types.js +6 -0
- package/plugins/button/constants.d.ts +2 -0
- package/plugins/button/constants.js +5 -0
- package/plugins/button/create-button-plugin.d.ts +2 -0
- package/plugins/button/create-button-plugin.js +11 -0
- package/plugins/button/index.d.ts +3 -0
- package/plugins/button/index.js +23 -0
- package/plugins/button/transforms/get-active-button.d.ts +2 -0
- package/plugins/button/transforms/get-active-button.js +9 -0
- package/plugins/button/transforms/index.d.ts +4 -0
- package/plugins/button/transforms/index.js +11 -0
- package/plugins/button/transforms/insert-button.d.ts +2 -0
- package/plugins/button/transforms/insert-button.js +16 -0
- package/plugins/button/transforms/is-button-active.d.ts +2 -0
- package/plugins/button/transforms/is-button-active.js +7 -0
- package/plugins/button/transforms/remove-selected-button.d.ts +2 -0
- package/plugins/button/transforms/remove-selected-button.js +13 -0
- package/plugins/button/transforms/update-button.d.ts +2 -0
- package/plugins/button/transforms/update-button.js +9 -0
- package/plugins/embedded/utils.d.ts +1 -0
- package/plugins/embedded/utils.js +7 -0
- package/plugins/embedded/video/create-video-plugin.d.ts +4 -0
- package/plugins/embedded/video/create-video-plugin.js +19 -0
- package/plugins/embedded/video/get-active-video.d.ts +2 -0
- package/plugins/embedded/video/get-active-video.js +9 -0
- package/plugins/embedded/video/insert-video.d.ts +2 -0
- package/plugins/embedded/video/insert-video.js +19 -0
- package/plugins/embedded/video/update-video.d.ts +2 -0
- package/plugins/embedded/video/update-video.js +12 -0
- package/plugins/exit-break/create-exit-break-plugin.d.ts +3 -0
- package/plugins/exit-break/create-exit-break-plugin.js +30 -0
- package/plugins/heading/constants.d.ts +8 -0
- package/plugins/heading/constants.js +11 -0
- package/plugins/heading/create-headings-plugin.d.ts +8 -0
- package/plugins/heading/create-headings-plugin.js +40 -0
- package/plugins/highlight/createHighlightPlugin.d.ts +3 -0
- package/plugins/highlight/createHighlightPlugin.js +27 -0
- package/plugins/highlight/types.d.ts +10 -0
- package/plugins/highlight/types.js +4 -0
- package/plugins/image/create-image-plugin.d.ts +6 -0
- package/plugins/image/create-image-plugin.js +105 -0
- package/plugins/image/hooks/use-image-handlers.d.ts +5 -0
- package/plugins/image/hooks/use-image-handlers.js +19 -0
- package/plugins/image/transforms/get-active-image.d.ts +2 -0
- package/plugins/image/transforms/get-active-image.js +9 -0
- package/plugins/image/transforms/insert-image.d.ts +3 -0
- package/plugins/image/transforms/insert-image.js +19 -0
- package/plugins/image/transforms/is-image-active.d.ts +2 -0
- package/plugins/image/transforms/is-image-active.js +7 -0
- package/plugins/image/transforms/remove-selected-image.d.ts +2 -0
- package/plugins/image/transforms/remove-selected-image.js +13 -0
- package/plugins/image/transforms/update-image.d.ts +3 -0
- package/plugins/image/transforms/update-image.js +12 -0
- package/plugins/image/types.d.ts +12 -0
- package/plugins/image/types.js +6 -0
- package/plugins/image/utils/is-image-url.d.ts +2 -0
- package/plugins/image/utils/is-image-url.js +135 -0
- package/plugins/image/with-image.d.ts +7 -0
- package/plugins/image/with-image.js +19 -0
- package/plugins/image/with-paste-image-url.d.ts +7 -0
- package/plugins/image/with-paste-image-url.js +36 -0
- package/plugins/image/with-paste-image.d.ts +7 -0
- package/plugins/image/with-paste-image.js +49 -0
- package/plugins/link/constants.d.ts +2 -0
- package/plugins/link/constants.js +6 -0
- package/plugins/link/create-link-plugin.d.ts +3 -0
- package/plugins/link/create-link-plugin.js +15 -0
- package/plugins/link/floating-link-wrapper.d.ts +11 -0
- package/plugins/link/floating-link-wrapper.js +26 -0
- package/plugins/link/hooks/index.d.ts +4 -0
- package/plugins/link/hooks/index.js +11 -0
- package/plugins/link/hooks/use-link-actions.d.ts +12 -0
- package/plugins/link/hooks/use-link-actions.js +48 -0
- package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +1 -0
- package/plugins/link/hooks/use-link-cancel-on-escape.js +5 -0
- package/plugins/link/hooks/use-link-submit-on-enter.d.ts +1 -0
- package/plugins/link/hooks/use-link-submit-on-enter.js +23 -0
- package/plugins/link/transforms/get-active-link.d.ts +3 -0
- package/plugins/link/transforms/get-active-link.js +17 -0
- package/plugins/link/transforms/insert-link.d.ts +2 -0
- package/plugins/link/transforms/insert-link.js +27 -0
- package/plugins/link/transforms/is-link-selected.d.ts +2 -0
- package/plugins/link/transforms/is-link-selected.js +15 -0
- package/plugins/link/transforms/submit-link.d.ts +8 -0
- package/plugins/link/transforms/submit-link.js +36 -0
- package/plugins/link/transforms/trigger-link-insert-or-edit.d.ts +2 -0
- package/plugins/link/transforms/trigger-link-insert-or-edit.js +6 -0
- package/plugins/link/transforms/unwrap-link.d.ts +2 -0
- package/plugins/link/transforms/unwrap-link.js +10 -0
- package/plugins/link/types.d.ts +5 -0
- package/plugins/link/types.js +2 -0
- package/plugins/list/constants.d.ts +4 -0
- package/plugins/list/constants.js +14 -0
- package/plugins/list/create-list-plugin.d.ts +4 -0
- package/plugins/list/create-list-plugin.js +16 -0
- package/plugins/mark-bold/create-bold-plugin.d.ts +3 -0
- package/plugins/mark-bold/create-bold-plugin.js +6 -0
- package/plugins/mark-bold/types.d.ts +2 -0
- package/plugins/mark-bold/types.js +6 -0
- package/plugins/mark-code/create-code-plugin.d.ts +3 -0
- package/plugins/mark-code/create-code-plugin.js +6 -0
- package/plugins/mark-code/types.d.ts +2 -0
- package/plugins/mark-code/types.js +6 -0
- package/plugins/mark-italic/create-italic-plugin.d.ts +3 -0
- package/plugins/mark-italic/create-italic-plugin.js +6 -0
- package/plugins/mark-italic/types.d.ts +2 -0
- package/plugins/mark-italic/types.js +6 -0
- package/plugins/mark-underline/create-underline-plugin.d.ts +3 -0
- package/plugins/mark-underline/create-underline-plugin.js +6 -0
- package/plugins/mark-underline/types.d.ts +2 -0
- package/plugins/mark-underline/types.js +6 -0
- package/plugins/node-id/add-ids-to-nodes.d.ts +2 -0
- package/plugins/node-id/add-ids-to-nodes.js +22 -0
- package/plugins/node-id/create-node-id-plugin.d.ts +3 -0
- package/plugins/node-id/create-node-id-plugin.js +6 -0
- package/plugins/paragraph/create-paragraph-plugin.d.ts +3 -0
- package/plugins/paragraph/create-paragraph-plugin.js +9 -0
- package/plugins/paragraph/types.d.ts +2 -0
- package/plugins/paragraph/types.js +6 -0
- package/plugins/reset-node/create-reset-node.d.ts +3 -0
- package/plugins/reset-node/create-reset-node.js +28 -0
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.d.ts +3 -0
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.js +14 -0
- package/plugins/soft-break/create-soft-break-plugin.d.ts +3 -0
- package/plugins/soft-break/create-soft-break-plugin.js +22 -0
- package/plugins/trailing-block/create-trailing-block-plugin.d.ts +3 -0
- package/plugins/trailing-block/create-trailing-block-plugin.js +6 -0
- package/serializers/serialize-to-plaintext.d.ts +2 -0
- package/serializers/serialize-to-plaintext.js +8 -0
- package/translations/cs.json +134 -0
- package/translations/de.json +134 -0
- package/translations/en.json +134 -0
- package/translations/sk.json +134 -0
- package/types.d.ts +118 -0
- package/types.js +2 -0
- package/ui/blockquote-element.d.ts +2 -0
- package/ui/blockquote-element.js +13 -0
- package/ui/bold-mark.d.ts +2 -0
- package/ui/bold-mark.js +13 -0
- package/ui/button/button-element.d.ts +2 -0
- package/ui/button/button-element.js +54 -0
- package/ui/button/index.d.ts +1 -0
- package/ui/button/index.js +5 -0
- package/ui/button/insert-button-modal-content.d.ts +8 -0
- package/ui/button/insert-button-modal-content.js +81 -0
- package/ui/code-mark.d.ts +2 -0
- package/ui/code-mark.js +13 -0
- package/ui/components/element/element-action-buttons.d.ts +9 -0
- package/ui/components/element/element-action-buttons.js +22 -0
- package/ui/components/element/element-with-action-buttons.d.ts +10 -0
- package/ui/components/element/element-with-action-buttons.js +17 -0
- package/ui/components/modal/modal-button-cancel.d.ts +9 -0
- package/ui/components/modal/modal-button-cancel.js +45 -0
- package/ui/components/modal/modal-button-submit.d.ts +6 -0
- package/ui/components/modal/modal-button-submit.js +12 -0
- package/ui/components/modal/modal-buttons.d.ts +11 -0
- package/ui/components/modal/modal-buttons.js +16 -0
- package/ui/components/modal/modal-content.d.ts +6 -0
- package/ui/components/modal/modal-content.js +14 -0
- package/ui/create-uxf-ui.d.ts +21 -0
- package/ui/create-uxf-ui.js +51 -0
- package/ui/floating-link.d.ts +2 -0
- package/ui/floating-link.js +110 -0
- package/ui/heading-elements.d.ts +7 -0
- package/ui/heading-elements.js +38 -0
- package/ui/highlight-mark.d.ts +3 -0
- package/ui/highlight-mark.js +13 -0
- package/ui/image/image-element.d.ts +2 -0
- package/ui/image/image-element.js +53 -0
- package/ui/image/insert-image-modal-content.d.ts +8 -0
- package/ui/image/insert-image-modal-content.js +89 -0
- package/ui/italic-mark.d.ts +2 -0
- package/ui/italic-mark.js +13 -0
- package/ui/link-element.d.ts +3 -0
- package/ui/link-element.js +14 -0
- package/ui/list-item-element.d.ts +2 -0
- package/ui/list-item-element.js +13 -0
- package/ui/list-ordered-element.d.ts +2 -0
- package/ui/list-ordered-element.js +13 -0
- package/ui/list-unordered-element.d.ts +2 -0
- package/ui/list-unordered-element.js +13 -0
- package/ui/paragraph-element.d.ts +2 -0
- package/ui/paragraph-element.js +13 -0
- package/ui/toolbar/buttons/button-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/button-toolbar-button.js +20 -0
- package/ui/toolbar/buttons/element-toolbar-button.d.ts +12 -0
- package/ui/toolbar/buttons/element-toolbar-button.js +25 -0
- package/ui/toolbar/buttons/image-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/image-toolbar-button.js +20 -0
- package/ui/toolbar/buttons/link-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/link-toolbar-button.js +29 -0
- package/ui/toolbar/buttons/list-toolbar-button.d.ts +13 -0
- package/ui/toolbar/buttons/list-toolbar-button.js +27 -0
- package/ui/toolbar/buttons/mark-toolbar-button.d.ts +13 -0
- package/ui/toolbar/buttons/mark-toolbar-button.js +25 -0
- package/ui/toolbar/buttons/modal-toolbar-button.d.ts +15 -0
- package/ui/toolbar/buttons/modal-toolbar-button.js +22 -0
- package/ui/toolbar/buttons/toolbar-button.d.ts +15 -0
- package/ui/toolbar/buttons/toolbar-button.js +35 -0
- package/ui/toolbar/buttons/undo-redo-button-group.d.ts +8 -0
- package/ui/toolbar/buttons/undo-redo-button-group.js +64 -0
- package/ui/toolbar/buttons/video-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/video-toolbar-button.js +20 -0
- package/ui/toolbar/toolbar.d.ts +3 -0
- package/ui/toolbar/toolbar.js +77 -0
- package/ui/toolbar/types.d.ts +8 -0
- package/ui/toolbar/types.js +2 -0
- package/ui/underline-mark.d.ts +2 -0
- package/ui/underline-mark.js +13 -0
- package/ui/utils.d.ts +2 -0
- package/ui/utils.js +13 -0
- package/ui/video/insert-video-modal-content.d.ts +8 -0
- package/ui/video/insert-video-modal-content.js +80 -0
- package/ui/video/video-element.d.ts +2 -0
- package/ui/video/video-element.js +55 -0
- package/utils/get-video-meta-data.d.ts +2 -0
- package/utils/get-video-meta-data.js +41 -0
- package/utils/url-helper.d.ts +7 -0
- package/utils/url-helper.js +15 -0
- package/utils/url-helper.test.d.ts +1 -0
- package/utils/url-helper.test.js +37 -0
- package/utils.d.ts +30 -0
- package/utils.js +88 -0
- package/wysiwyg-editor.d.ts +15 -0
- package/wysiwyg-editor.js +42 -0
- package/wysiwyg-editor.stories.d.ts +5 -0
- package/wysiwyg-editor.stories.js +193 -0
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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";
|
|
@@ -0,0 +1,135 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withPasteImage = void 0;
|
|
4
|
+
const plate_core_1 = require("@udecode/plate-core");
|
|
5
|
+
const insert_image_1 = require("./transforms/insert-image");
|
|
6
|
+
/**
|
|
7
|
+
* If image is pasted from clipboard, upload image and insert it.
|
|
8
|
+
*/
|
|
9
|
+
const withPasteImage = (editor, plugin) => {
|
|
10
|
+
const { options: { uploadImage, getImageUrl }, } = plugin;
|
|
11
|
+
const { insertData } = editor;
|
|
12
|
+
editor.insertData = async (dataTransfer) => {
|
|
13
|
+
const text = dataTransfer.getData("text/plain");
|
|
14
|
+
const { files, effectAllowed } = dataTransfer;
|
|
15
|
+
if (files.length > 0 && effectAllowed === "uninitialized") {
|
|
16
|
+
// effectAllowed prevents re-upload image on drag and drop
|
|
17
|
+
const injectedPlugins = (0, plate_core_1.getInjectedPlugins)(editor, plugin);
|
|
18
|
+
if (!(0, plate_core_1.pipeInsertDataQuery)(injectedPlugins, {
|
|
19
|
+
data: text,
|
|
20
|
+
dataTransfer,
|
|
21
|
+
})) {
|
|
22
|
+
return insertData(dataTransfer);
|
|
23
|
+
}
|
|
24
|
+
for (const file of Array.from(files)) {
|
|
25
|
+
const [mime] = file.type.split("/");
|
|
26
|
+
if (mime === "image") {
|
|
27
|
+
if (!uploadImage) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.log("Missing uploadImage function in image plugin options!");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line no-await-in-loop
|
|
33
|
+
const uploadedFile = await uploadImage(file);
|
|
34
|
+
if (!getImageUrl) {
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log("Missing getImageUrl function in image plugin options!");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(0, insert_image_1.insertImage)(editor, uploadedFile, undefined, undefined, undefined, getImageUrl(uploadedFile));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
insertData(dataTransfer);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return editor;
|
|
48
|
+
};
|
|
49
|
+
exports.withPasteImage = withPasteImage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LINK_PLUGIN_TYPE = exports.ELEMENT_LINK = void 0;
|
|
4
|
+
var plate_link_1 = require("@udecode/plate-link");
|
|
5
|
+
Object.defineProperty(exports, "ELEMENT_LINK", { enumerable: true, get: function () { return plate_link_1.ELEMENT_LINK; } });
|
|
6
|
+
exports.LINK_PLUGIN_TYPE = "link";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLinkPlugin = void 0;
|
|
4
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
5
|
+
const floating_link_1 = require("../../ui/floating-link");
|
|
6
|
+
const url_helper_1 = require("../../utils/url-helper");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const createLinkPlugin = () => (0, plate_link_1.createLinkPlugin)({
|
|
9
|
+
type: constants_1.LINK_PLUGIN_TYPE,
|
|
10
|
+
renderAfterEditable: floating_link_1.FloatingLink,
|
|
11
|
+
options: {
|
|
12
|
+
isUrl: url_helper_1.UrlHelper.isValid,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
exports.createLinkPlugin = createLinkPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTMLPropsAs } from "@udecode/plate-common";
|
|
2
|
+
import { UseVirtualFloatingOptions } from "@udecode/plate-floating";
|
|
3
|
+
export type FloatingLinkProps = HTMLPropsAs<"div"> & {
|
|
4
|
+
floatingOptions?: UseVirtualFloatingOptions;
|
|
5
|
+
};
|
|
6
|
+
export declare const FloatingLinkEditRoot: import("@udecode/plate-common").Component<FloatingLinkProps>;
|
|
7
|
+
export declare const FloatingLinkInsertRoot: import("@udecode/plate-common").Component<FloatingLinkProps>;
|
|
8
|
+
export declare const FloatingLinkWrapper: {
|
|
9
|
+
EditRoot: import("@udecode/plate-common").Component<FloatingLinkProps>;
|
|
10
|
+
InsertRoot: import("@udecode/plate-common").Component<FloatingLinkProps>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatingLinkWrapper = exports.FloatingLinkInsertRoot = exports.FloatingLinkEditRoot = void 0;
|
|
4
|
+
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
6
|
+
const tw_z_index_1 = require("@uxf/ui/tw-tokens/tw-z-index");
|
|
7
|
+
exports.FloatingLinkEditRoot = (0, plate_common_1.createComponentAs)((props) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const htmlProps = (0, plate_link_1.useFloatingLinkEdit)(props);
|
|
10
|
+
if (((_a = htmlProps.style) === null || _a === void 0 ? void 0 : _a.display) === "none") {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (0, plate_common_1.createElementAs)("div", { ...htmlProps, style: { ...htmlProps.style, zIndex: tw_z_index_1.twZIndex.modal } });
|
|
14
|
+
});
|
|
15
|
+
exports.FloatingLinkInsertRoot = (0, plate_common_1.createComponentAs)((props) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const htmlProps = (0, plate_link_1.useFloatingLinkInsert)(props);
|
|
18
|
+
if (((_a = htmlProps.style) === null || _a === void 0 ? void 0 : _a.display) === "none") {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (0, plate_common_1.createElementAs)("div", { ...htmlProps, style: { ...htmlProps.style, zIndex: tw_z_index_1.twZIndex.modal } });
|
|
22
|
+
});
|
|
23
|
+
exports.FloatingLinkWrapper = {
|
|
24
|
+
EditRoot: exports.FloatingLinkEditRoot,
|
|
25
|
+
InsertRoot: exports.FloatingLinkInsertRoot,
|
|
26
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLinkSubmitOnEnter = exports.useLinkCancelOnEscape = exports.useLinkActions = exports.useFloatingLinkSelectors = void 0;
|
|
4
|
+
var plate_link_1 = require("@udecode/plate-link");
|
|
5
|
+
Object.defineProperty(exports, "useFloatingLinkSelectors", { enumerable: true, get: function () { return plate_link_1.useFloatingLinkSelectors; } });
|
|
6
|
+
var use_link_actions_1 = require("./use-link-actions");
|
|
7
|
+
Object.defineProperty(exports, "useLinkActions", { enumerable: true, get: function () { return use_link_actions_1.useLinkActions; } });
|
|
8
|
+
var use_link_cancel_on_escape_1 = require("./use-link-cancel-on-escape");
|
|
9
|
+
Object.defineProperty(exports, "useLinkCancelOnEscape", { enumerable: true, get: function () { return use_link_cancel_on_escape_1.useLinkCancelOnEscape; } });
|
|
10
|
+
var use_link_submit_on_enter_1 = require("./use-link-submit-on-enter");
|
|
11
|
+
Object.defineProperty(exports, "useLinkSubmitOnEnter", { enumerable: true, get: function () { return use_link_submit_on_enter_1.useLinkSubmitOnEnter; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const useLinkActions: () => {
|
|
2
|
+
editor: unknown;
|
|
3
|
+
setUrl: (url: string) => void;
|
|
4
|
+
getUrl: string;
|
|
5
|
+
setText: (text: string) => void;
|
|
6
|
+
getText: string;
|
|
7
|
+
setTarget: (target: string | undefined) => void;
|
|
8
|
+
getTarget: string;
|
|
9
|
+
setAllValues: (url: string, text: string, target: string | undefined) => void;
|
|
10
|
+
getActiveLinkValue: () => import("@udecode/plate-link").TLinkElement | undefined;
|
|
11
|
+
isEditing: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLinkActions = void 0;
|
|
4
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
5
|
+
const hooks_1 = require("../../../hooks");
|
|
6
|
+
const get_active_link_1 = require("../transforms/get-active-link");
|
|
7
|
+
const use_link_cancel_on_escape_1 = require("./use-link-cancel-on-escape");
|
|
8
|
+
const use_link_submit_on_enter_1 = require("./use-link-submit-on-enter");
|
|
9
|
+
const useLinkActions = () => {
|
|
10
|
+
const editor = (0, hooks_1.useUxfEditorRef)();
|
|
11
|
+
(0, use_link_submit_on_enter_1.useLinkSubmitOnEnter)();
|
|
12
|
+
(0, use_link_cancel_on_escape_1.useLinkCancelOnEscape)();
|
|
13
|
+
const floatingLinkSelectors = (0, plate_link_1.useFloatingLinkSelectors)();
|
|
14
|
+
const setUrl = (url) => {
|
|
15
|
+
plate_link_1.floatingLinkActions.url(url);
|
|
16
|
+
plate_link_1.floatingLinkActions.isEditing(true);
|
|
17
|
+
};
|
|
18
|
+
const setText = (text) => {
|
|
19
|
+
plate_link_1.floatingLinkActions.text(text);
|
|
20
|
+
plate_link_1.floatingLinkActions.isEditing(true);
|
|
21
|
+
};
|
|
22
|
+
const setTarget = (target) => {
|
|
23
|
+
plate_link_1.floatingLinkActions.newTab(target === "_blank");
|
|
24
|
+
plate_link_1.floatingLinkActions.isEditing(true);
|
|
25
|
+
};
|
|
26
|
+
const setAllValues = (url, text, target) => {
|
|
27
|
+
setUrl(url);
|
|
28
|
+
setText(text);
|
|
29
|
+
setTarget(target);
|
|
30
|
+
plate_link_1.floatingLinkActions.isEditing(true);
|
|
31
|
+
// floatingLinkActions.show("edit", editor.id);
|
|
32
|
+
};
|
|
33
|
+
const getActiveLinkValue = () => (0, get_active_link_1.getActiveLink)(editor);
|
|
34
|
+
return {
|
|
35
|
+
editor: editor.current,
|
|
36
|
+
setUrl,
|
|
37
|
+
getUrl: floatingLinkSelectors.url(),
|
|
38
|
+
setText,
|
|
39
|
+
getText: floatingLinkSelectors.text(),
|
|
40
|
+
setTarget,
|
|
41
|
+
getTarget: floatingLinkSelectors.newTab() ? "_blank" : "_self",
|
|
42
|
+
setAllValues,
|
|
43
|
+
getActiveLinkValue,
|
|
44
|
+
// isLinkActive: linkActive,
|
|
45
|
+
isEditing: floatingLinkSelectors.isEditing(),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.useLinkActions = useLinkActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFloatingLinkEscape as useLinkCancelOnEscape } from "@udecode/plate-link";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLinkCancelOnEscape = void 0;
|
|
4
|
+
var plate_link_1 = require("@udecode/plate-link");
|
|
5
|
+
Object.defineProperty(exports, "useLinkCancelOnEscape", { enumerable: true, get: function () { return plate_link_1.useFloatingLinkEscape; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useLinkSubmitOnEnter: () => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLinkSubmitOnEnter = void 0;
|
|
4
|
+
const plate_core_1 = require("@udecode/plate-core");
|
|
5
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
6
|
+
const hooks_1 = require("../../../hooks");
|
|
7
|
+
const submit_link_1 = require("../transforms/submit-link");
|
|
8
|
+
const useLinkSubmitOnEnter = () => {
|
|
9
|
+
const editor = (0, hooks_1.useUxfEditorRef)();
|
|
10
|
+
const open = (0, plate_link_1.useFloatingLinkSelectors)().isEditing();
|
|
11
|
+
(0, plate_core_1.useHotkeys)("*", (e) => {
|
|
12
|
+
if (e.key !== "Enter") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if ((0, submit_link_1.submitLink)(editor)) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
enabled: open,
|
|
20
|
+
enableOnFormTags: ["INPUT"],
|
|
21
|
+
}, []);
|
|
22
|
+
};
|
|
23
|
+
exports.useLinkSubmitOnEnter = useLinkSubmitOnEnter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActiveLink = void 0;
|
|
4
|
+
const plate_core_1 = require("@udecode/plate-core");
|
|
5
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
6
|
+
const slate_1 = require("@udecode/slate");
|
|
7
|
+
const getActiveLink = (editor) => {
|
|
8
|
+
const entry = (0, slate_1.findNode)(editor, {
|
|
9
|
+
match: { type: (0, plate_core_1.getPluginType)(editor, plate_link_1.ELEMENT_LINK) },
|
|
10
|
+
});
|
|
11
|
+
if (!entry) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const [link] = entry;
|
|
15
|
+
return link;
|
|
16
|
+
};
|
|
17
|
+
exports.getActiveLink = getActiveLink;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertLink = void 0;
|
|
4
|
+
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
+
const plate_core_1 = require("@udecode/plate-core");
|
|
6
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
7
|
+
const insertLink = (editor, url, text, target) => {
|
|
8
|
+
if (!editor.selection) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const { isUrl, forceSubmit } = (0, plate_core_1.getPluginOptions)(editor, plate_link_1.ELEMENT_LINK);
|
|
12
|
+
const isValid = (isUrl === null || isUrl === void 0 ? void 0 : isUrl(url)) || forceSubmit;
|
|
13
|
+
if (!isValid) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
(0, plate_link_1.upsertLink)(editor, {
|
|
17
|
+
url,
|
|
18
|
+
text,
|
|
19
|
+
target,
|
|
20
|
+
skipValidation: true,
|
|
21
|
+
});
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
(0, plate_common_1.focusEditor)(editor, editor.selection || undefined);
|
|
24
|
+
}, 0);
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
exports.insertLink = insertLink;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLinkSelected = void 0;
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const isLinkSelected = (editor) => {
|
|
7
|
+
if (!editor.selection) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return ((0, utils_1.isRangeInSingleText)(editor) &&
|
|
11
|
+
(0, utils_1.someNode)(editor, {
|
|
12
|
+
match: { type: (0, utils_1.getPluginType)(editor, constants_1.LINK_PLUGIN_TYPE) },
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
exports.isLinkSelected = isLinkSelected;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PlateEditor } from "@udecode/plate-core";
|
|
2
|
+
import { Value } from "@udecode/slate";
|
|
3
|
+
/**
|
|
4
|
+
* Insert transforms if url is valid from store
|
|
5
|
+
* Text is url if empty.
|
|
6
|
+
* Focus editor.
|
|
7
|
+
*/
|
|
8
|
+
export declare const submitLink: <V extends Value>(editor: PlateEditor<V>) => true | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitLink = void 0;
|
|
4
|
+
const plate_common_1 = require("@udecode/plate-common");
|
|
5
|
+
const plate_core_1 = require("@udecode/plate-core");
|
|
6
|
+
const plate_link_1 = require("@udecode/plate-link");
|
|
7
|
+
/**
|
|
8
|
+
* Insert transforms if url is valid from store
|
|
9
|
+
* Text is url if empty.
|
|
10
|
+
* Focus editor.
|
|
11
|
+
*/
|
|
12
|
+
const submitLink = (editor) => {
|
|
13
|
+
if (!editor.selection) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { isUrl, forceSubmit } = (0, plate_core_1.getPluginOptions)(editor, plate_link_1.ELEMENT_LINK);
|
|
17
|
+
const url = plate_link_1.floatingLinkSelectors.url();
|
|
18
|
+
const isValid = (isUrl === null || isUrl === void 0 ? void 0 : isUrl(url)) || forceSubmit;
|
|
19
|
+
if (!isValid) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const text = plate_link_1.floatingLinkSelectors.text();
|
|
23
|
+
const target = plate_link_1.floatingLinkSelectors.newTab() ? "_blank" : "_self";
|
|
24
|
+
(0, plate_link_1.upsertLink)(editor, {
|
|
25
|
+
url,
|
|
26
|
+
text,
|
|
27
|
+
target,
|
|
28
|
+
skipValidation: true,
|
|
29
|
+
});
|
|
30
|
+
plate_link_1.floatingLinkActions.reset();
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
(0, plate_common_1.focusEditor)(editor, editor.selection || undefined);
|
|
33
|
+
}, 0);
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
exports.submitLink = submitLink;
|