@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.
Files changed (245) hide show
  1. package/components.d.ts +7 -0
  2. package/components.js +34 -0
  3. package/config/icons-config.d.ts +2 -0
  4. package/config/icons-config.js +5 -0
  5. package/config/icons.d.ts +183 -0
  6. package/config/icons.js +51 -0
  7. package/create-all-plugins-with-ui.d.ts +64 -0
  8. package/create-all-plugins-with-ui.js +127 -0
  9. package/create-plugins-with-ui.d.ts +4 -0
  10. package/create-plugins-with-ui.js +47 -0
  11. package/hooks.d.ts +9 -0
  12. package/hooks.js +20 -0
  13. package/index.d.ts +6 -0
  14. package/index.js +38 -0
  15. package/package.json +3 -3
  16. package/plugins/blockquote/create-blockquote-plugin.d.ts +3 -0
  17. package/plugins/blockquote/create-blockquote-plugin.js +9 -0
  18. package/plugins/blockquote/types.d.ts +2 -0
  19. package/plugins/blockquote/types.js +6 -0
  20. package/plugins/button/constants.d.ts +2 -0
  21. package/plugins/button/constants.js +5 -0
  22. package/plugins/button/create-button-plugin.d.ts +2 -0
  23. package/plugins/button/create-button-plugin.js +11 -0
  24. package/plugins/button/index.d.ts +3 -0
  25. package/plugins/button/index.js +23 -0
  26. package/plugins/button/transforms/get-active-button.d.ts +2 -0
  27. package/plugins/button/transforms/get-active-button.js +9 -0
  28. package/plugins/button/transforms/index.d.ts +4 -0
  29. package/plugins/button/transforms/index.js +11 -0
  30. package/plugins/button/transforms/insert-button.d.ts +2 -0
  31. package/plugins/button/transforms/insert-button.js +16 -0
  32. package/plugins/button/transforms/is-button-active.d.ts +2 -0
  33. package/plugins/button/transforms/is-button-active.js +7 -0
  34. package/plugins/button/transforms/remove-selected-button.d.ts +2 -0
  35. package/plugins/button/transforms/remove-selected-button.js +13 -0
  36. package/plugins/button/transforms/update-button.d.ts +2 -0
  37. package/plugins/button/transforms/update-button.js +9 -0
  38. package/plugins/embedded/utils.d.ts +1 -0
  39. package/plugins/embedded/utils.js +7 -0
  40. package/plugins/embedded/video/create-video-plugin.d.ts +4 -0
  41. package/plugins/embedded/video/create-video-plugin.js +19 -0
  42. package/plugins/embedded/video/get-active-video.d.ts +2 -0
  43. package/plugins/embedded/video/get-active-video.js +9 -0
  44. package/plugins/embedded/video/insert-video.d.ts +2 -0
  45. package/plugins/embedded/video/insert-video.js +19 -0
  46. package/plugins/embedded/video/update-video.d.ts +2 -0
  47. package/plugins/embedded/video/update-video.js +12 -0
  48. package/plugins/exit-break/create-exit-break-plugin.d.ts +3 -0
  49. package/plugins/exit-break/create-exit-break-plugin.js +30 -0
  50. package/plugins/heading/constants.d.ts +8 -0
  51. package/plugins/heading/constants.js +11 -0
  52. package/plugins/heading/create-headings-plugin.d.ts +8 -0
  53. package/plugins/heading/create-headings-plugin.js +40 -0
  54. package/plugins/highlight/createHighlightPlugin.d.ts +3 -0
  55. package/plugins/highlight/createHighlightPlugin.js +27 -0
  56. package/plugins/highlight/types.d.ts +10 -0
  57. package/plugins/highlight/types.js +4 -0
  58. package/plugins/image/create-image-plugin.d.ts +6 -0
  59. package/plugins/image/create-image-plugin.js +105 -0
  60. package/plugins/image/hooks/use-image-handlers.d.ts +5 -0
  61. package/plugins/image/hooks/use-image-handlers.js +19 -0
  62. package/plugins/image/transforms/get-active-image.d.ts +2 -0
  63. package/plugins/image/transforms/get-active-image.js +9 -0
  64. package/plugins/image/transforms/insert-image.d.ts +3 -0
  65. package/plugins/image/transforms/insert-image.js +19 -0
  66. package/plugins/image/transforms/is-image-active.d.ts +2 -0
  67. package/plugins/image/transforms/is-image-active.js +7 -0
  68. package/plugins/image/transforms/remove-selected-image.d.ts +2 -0
  69. package/plugins/image/transforms/remove-selected-image.js +13 -0
  70. package/plugins/image/transforms/update-image.d.ts +3 -0
  71. package/plugins/image/transforms/update-image.js +12 -0
  72. package/plugins/image/types.d.ts +12 -0
  73. package/plugins/image/types.js +6 -0
  74. package/plugins/image/utils/is-image-url.d.ts +2 -0
  75. package/plugins/image/utils/is-image-url.js +135 -0
  76. package/plugins/image/with-image.d.ts +7 -0
  77. package/plugins/image/with-image.js +19 -0
  78. package/plugins/image/with-paste-image-url.d.ts +7 -0
  79. package/plugins/image/with-paste-image-url.js +36 -0
  80. package/plugins/image/with-paste-image.d.ts +7 -0
  81. package/plugins/image/with-paste-image.js +49 -0
  82. package/plugins/link/constants.d.ts +2 -0
  83. package/plugins/link/constants.js +6 -0
  84. package/plugins/link/create-link-plugin.d.ts +3 -0
  85. package/plugins/link/create-link-plugin.js +15 -0
  86. package/plugins/link/floating-link-wrapper.d.ts +11 -0
  87. package/plugins/link/floating-link-wrapper.js +26 -0
  88. package/plugins/link/hooks/index.d.ts +4 -0
  89. package/plugins/link/hooks/index.js +11 -0
  90. package/plugins/link/hooks/use-link-actions.d.ts +12 -0
  91. package/plugins/link/hooks/use-link-actions.js +48 -0
  92. package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +1 -0
  93. package/plugins/link/hooks/use-link-cancel-on-escape.js +5 -0
  94. package/plugins/link/hooks/use-link-submit-on-enter.d.ts +1 -0
  95. package/plugins/link/hooks/use-link-submit-on-enter.js +23 -0
  96. package/plugins/link/transforms/get-active-link.d.ts +3 -0
  97. package/plugins/link/transforms/get-active-link.js +17 -0
  98. package/plugins/link/transforms/insert-link.d.ts +2 -0
  99. package/plugins/link/transforms/insert-link.js +27 -0
  100. package/plugins/link/transforms/is-link-selected.d.ts +2 -0
  101. package/plugins/link/transforms/is-link-selected.js +15 -0
  102. package/plugins/link/transforms/submit-link.d.ts +8 -0
  103. package/plugins/link/transforms/submit-link.js +36 -0
  104. package/plugins/link/transforms/trigger-link-insert-or-edit.d.ts +2 -0
  105. package/plugins/link/transforms/trigger-link-insert-or-edit.js +6 -0
  106. package/plugins/link/transforms/unwrap-link.d.ts +2 -0
  107. package/plugins/link/transforms/unwrap-link.js +10 -0
  108. package/plugins/link/types.d.ts +5 -0
  109. package/plugins/link/types.js +2 -0
  110. package/plugins/list/constants.d.ts +4 -0
  111. package/plugins/list/constants.js +14 -0
  112. package/plugins/list/create-list-plugin.d.ts +4 -0
  113. package/plugins/list/create-list-plugin.js +16 -0
  114. package/plugins/mark-bold/create-bold-plugin.d.ts +3 -0
  115. package/plugins/mark-bold/create-bold-plugin.js +6 -0
  116. package/plugins/mark-bold/types.d.ts +2 -0
  117. package/plugins/mark-bold/types.js +6 -0
  118. package/plugins/mark-code/create-code-plugin.d.ts +3 -0
  119. package/plugins/mark-code/create-code-plugin.js +6 -0
  120. package/plugins/mark-code/types.d.ts +2 -0
  121. package/plugins/mark-code/types.js +6 -0
  122. package/plugins/mark-italic/create-italic-plugin.d.ts +3 -0
  123. package/plugins/mark-italic/create-italic-plugin.js +6 -0
  124. package/plugins/mark-italic/types.d.ts +2 -0
  125. package/plugins/mark-italic/types.js +6 -0
  126. package/plugins/mark-underline/create-underline-plugin.d.ts +3 -0
  127. package/plugins/mark-underline/create-underline-plugin.js +6 -0
  128. package/plugins/mark-underline/types.d.ts +2 -0
  129. package/plugins/mark-underline/types.js +6 -0
  130. package/plugins/node-id/add-ids-to-nodes.d.ts +2 -0
  131. package/plugins/node-id/add-ids-to-nodes.js +22 -0
  132. package/plugins/node-id/create-node-id-plugin.d.ts +3 -0
  133. package/plugins/node-id/create-node-id-plugin.js +6 -0
  134. package/plugins/paragraph/create-paragraph-plugin.d.ts +3 -0
  135. package/plugins/paragraph/create-paragraph-plugin.js +9 -0
  136. package/plugins/paragraph/types.d.ts +2 -0
  137. package/plugins/paragraph/types.js +6 -0
  138. package/plugins/reset-node/create-reset-node.d.ts +3 -0
  139. package/plugins/reset-node/create-reset-node.js +28 -0
  140. package/plugins/select-on-backspace/create-select-on-backspace-plugin.d.ts +3 -0
  141. package/plugins/select-on-backspace/create-select-on-backspace-plugin.js +14 -0
  142. package/plugins/soft-break/create-soft-break-plugin.d.ts +3 -0
  143. package/plugins/soft-break/create-soft-break-plugin.js +22 -0
  144. package/plugins/trailing-block/create-trailing-block-plugin.d.ts +3 -0
  145. package/plugins/trailing-block/create-trailing-block-plugin.js +6 -0
  146. package/serializers/serialize-to-plaintext.d.ts +2 -0
  147. package/serializers/serialize-to-plaintext.js +8 -0
  148. package/translations/cs.json +134 -0
  149. package/translations/de.json +134 -0
  150. package/translations/en.json +134 -0
  151. package/translations/sk.json +134 -0
  152. package/types.d.ts +118 -0
  153. package/types.js +2 -0
  154. package/ui/blockquote-element.d.ts +2 -0
  155. package/ui/blockquote-element.js +13 -0
  156. package/ui/bold-mark.d.ts +2 -0
  157. package/ui/bold-mark.js +13 -0
  158. package/ui/button/button-element.d.ts +2 -0
  159. package/ui/button/button-element.js +54 -0
  160. package/ui/button/index.d.ts +1 -0
  161. package/ui/button/index.js +5 -0
  162. package/ui/button/insert-button-modal-content.d.ts +8 -0
  163. package/ui/button/insert-button-modal-content.js +81 -0
  164. package/ui/code-mark.d.ts +2 -0
  165. package/ui/code-mark.js +13 -0
  166. package/ui/components/element/element-action-buttons.d.ts +9 -0
  167. package/ui/components/element/element-action-buttons.js +22 -0
  168. package/ui/components/element/element-with-action-buttons.d.ts +10 -0
  169. package/ui/components/element/element-with-action-buttons.js +17 -0
  170. package/ui/components/modal/modal-button-cancel.d.ts +9 -0
  171. package/ui/components/modal/modal-button-cancel.js +45 -0
  172. package/ui/components/modal/modal-button-submit.d.ts +6 -0
  173. package/ui/components/modal/modal-button-submit.js +12 -0
  174. package/ui/components/modal/modal-buttons.d.ts +11 -0
  175. package/ui/components/modal/modal-buttons.js +16 -0
  176. package/ui/components/modal/modal-content.d.ts +6 -0
  177. package/ui/components/modal/modal-content.js +14 -0
  178. package/ui/create-uxf-ui.d.ts +21 -0
  179. package/ui/create-uxf-ui.js +51 -0
  180. package/ui/floating-link.d.ts +2 -0
  181. package/ui/floating-link.js +110 -0
  182. package/ui/heading-elements.d.ts +7 -0
  183. package/ui/heading-elements.js +38 -0
  184. package/ui/highlight-mark.d.ts +3 -0
  185. package/ui/highlight-mark.js +13 -0
  186. package/ui/image/image-element.d.ts +2 -0
  187. package/ui/image/image-element.js +53 -0
  188. package/ui/image/insert-image-modal-content.d.ts +8 -0
  189. package/ui/image/insert-image-modal-content.js +89 -0
  190. package/ui/italic-mark.d.ts +2 -0
  191. package/ui/italic-mark.js +13 -0
  192. package/ui/link-element.d.ts +3 -0
  193. package/ui/link-element.js +14 -0
  194. package/ui/list-item-element.d.ts +2 -0
  195. package/ui/list-item-element.js +13 -0
  196. package/ui/list-ordered-element.d.ts +2 -0
  197. package/ui/list-ordered-element.js +13 -0
  198. package/ui/list-unordered-element.d.ts +2 -0
  199. package/ui/list-unordered-element.js +13 -0
  200. package/ui/paragraph-element.d.ts +2 -0
  201. package/ui/paragraph-element.js +13 -0
  202. package/ui/toolbar/buttons/button-toolbar-button.d.ts +10 -0
  203. package/ui/toolbar/buttons/button-toolbar-button.js +20 -0
  204. package/ui/toolbar/buttons/element-toolbar-button.d.ts +12 -0
  205. package/ui/toolbar/buttons/element-toolbar-button.js +25 -0
  206. package/ui/toolbar/buttons/image-toolbar-button.d.ts +10 -0
  207. package/ui/toolbar/buttons/image-toolbar-button.js +20 -0
  208. package/ui/toolbar/buttons/link-toolbar-button.d.ts +10 -0
  209. package/ui/toolbar/buttons/link-toolbar-button.js +29 -0
  210. package/ui/toolbar/buttons/list-toolbar-button.d.ts +13 -0
  211. package/ui/toolbar/buttons/list-toolbar-button.js +27 -0
  212. package/ui/toolbar/buttons/mark-toolbar-button.d.ts +13 -0
  213. package/ui/toolbar/buttons/mark-toolbar-button.js +25 -0
  214. package/ui/toolbar/buttons/modal-toolbar-button.d.ts +15 -0
  215. package/ui/toolbar/buttons/modal-toolbar-button.js +22 -0
  216. package/ui/toolbar/buttons/toolbar-button.d.ts +15 -0
  217. package/ui/toolbar/buttons/toolbar-button.js +35 -0
  218. package/ui/toolbar/buttons/undo-redo-button-group.d.ts +8 -0
  219. package/ui/toolbar/buttons/undo-redo-button-group.js +64 -0
  220. package/ui/toolbar/buttons/video-toolbar-button.d.ts +10 -0
  221. package/ui/toolbar/buttons/video-toolbar-button.js +20 -0
  222. package/ui/toolbar/toolbar.d.ts +3 -0
  223. package/ui/toolbar/toolbar.js +77 -0
  224. package/ui/toolbar/types.d.ts +8 -0
  225. package/ui/toolbar/types.js +2 -0
  226. package/ui/underline-mark.d.ts +2 -0
  227. package/ui/underline-mark.js +13 -0
  228. package/ui/utils.d.ts +2 -0
  229. package/ui/utils.js +13 -0
  230. package/ui/video/insert-video-modal-content.d.ts +8 -0
  231. package/ui/video/insert-video-modal-content.js +80 -0
  232. package/ui/video/video-element.d.ts +2 -0
  233. package/ui/video/video-element.js +55 -0
  234. package/utils/get-video-meta-data.d.ts +2 -0
  235. package/utils/get-video-meta-data.js +41 -0
  236. package/utils/url-helper.d.ts +7 -0
  237. package/utils/url-helper.js +15 -0
  238. package/utils/url-helper.test.d.ts +1 -0
  239. package/utils/url-helper.test.js +37 -0
  240. package/utils.d.ts +30 -0
  241. package/utils.js +88 -0
  242. package/wysiwyg-editor.d.ts +15 -0
  243. package/wysiwyg-editor.js +42 -0
  244. package/wysiwyg-editor.stories.d.ts +5 -0
  245. 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,3 @@
1
+ import { FileResponse } from "@uxf/core/types";
2
+ import { UxfEditor } from "../../../types";
3
+ export declare const updateImage: (editor: UxfEditor, file: FileResponse, alt?: string, caption?: string, source?: string, url?: string) => void;
@@ -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,2 @@
1
+ export declare const getImageExtension: (url: string) => string;
2
+ export declare const isImageUrl: (url: string) => boolean;
@@ -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,2 @@
1
+ export { ELEMENT_LINK } from "@udecode/plate-link";
2
+ export declare const LINK_PLUGIN_TYPE = "link";
@@ -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,3 @@
1
+ import { LinkPlugin } from "@udecode/plate-link";
2
+ import { UxfEditor, WysiwygContent } from "../../types";
3
+ export declare const createLinkPlugin: () => import("@udecode/plate-core").PlatePlugin<LinkPlugin, WysiwygContent, UxfEditor>;
@@ -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,4 @@
1
+ export { useFloatingLinkSelectors } from "@udecode/plate-link";
2
+ export { useLinkActions } from "./use-link-actions";
3
+ export { useLinkCancelOnEscape } from "./use-link-cancel-on-escape";
4
+ export { useLinkSubmitOnEnter } from "./use-link-submit-on-enter";
@@ -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,3 @@
1
+ import { TLinkElement } from "@udecode/plate-link";
2
+ import { UxfEditor } from "../../../types";
3
+ export declare const getActiveLink: (editor: UxfEditor) => TLinkElement | undefined;
@@ -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,2 @@
1
+ import { UxfEditor } from "../../../types";
2
+ export declare const insertLink: (editor: UxfEditor, url: string, text: string, target: "_blank" | "_self") => boolean;
@@ -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,2 @@
1
+ import { UxfEditor } from "../../../types";
2
+ export declare const isLinkSelected: (editor: UxfEditor) => boolean;
@@ -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;
@@ -0,0 +1,2 @@
1
+ import { UxfEditor } from "../../../types";
2
+ export declare const triggerLinkInsertOrEdit: (editor: UxfEditor, focused?: boolean) => void;