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