@uxf/wysiwyg 11.72.3 → 11.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) 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 -18
  49. package/plugins/embedded/video/update-video.d.ts +0 -2
  50. package/plugins/embedded/video/update-video.js +0 -11
  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 -102
  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 -76
  239. package/ui/video/video-element.d.ts +0 -2
  240. package/ui/video/video-element.js +0 -55
  241. package/utils/url-helper.d.ts +0 -7
  242. package/utils/url-helper.js +0 -15
  243. package/utils/url-helper.test.d.ts +0 -1
  244. package/utils/url-helper.test.js +0 -37
  245. package/utils.d.ts +0 -30
  246. package/utils.js +0 -88
  247. package/wysiwyg-editor.d.ts +0 -17
  248. package/wysiwyg-editor.js +0 -44
  249. package/wysiwyg-editor.stories.d.ts +0 -5
  250. package/wysiwyg-editor.stories.js +0 -193
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VideoToolbarButton = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const hooks_1 = require("../../../hooks");
9
- const create_video_plugin_1 = require("../../../plugins/embedded/video/create-video-plugin");
10
- const context_1 = require("../../../translations/context");
11
- const insert_video_modal_content_1 = require("../../video/insert-video-modal-content");
12
- const modal_toolbar_button_1 = require("./modal-toolbar-button");
13
- const CLASS_NAME = "uxf-wysiwyg__toolbar-button";
14
- const VideoToolbarButton = (props) => {
15
- var _a, _b;
16
- const t = (0, context_1.useTranslation)();
17
- const editor = (0, hooks_1.useUxfPlateEditorState)(props.plateId);
18
- return (react_1.default.createElement(modal_toolbar_button_1.ModalToolbarButton, { Modal: react_1.default.createElement(insert_video_modal_content_1.InsertVideoModalContent, { editor: editor }), className: `${CLASS_NAME} ${CLASS_NAME}-video ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, editor: editor, iconName: (_b = props.iconName) !== null && _b !== void 0 ? _b : "youtube", pluginKey: create_video_plugin_1.ELEMENT_VIDEO_EMBED, tooltipText: t("wysiwyg:plugins.video.tooltip") }));
19
- };
20
- exports.VideoToolbarButton = VideoToolbarButton;
@@ -1,3 +0,0 @@
1
- import { FC } from "react";
2
- import { ToolbarProps } from "./types";
3
- export declare const Toolbar: FC<ToolbarProps>;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Toolbar = void 0;
7
- const button_group_1 = require("@uxf/ui/button-group");
8
- const react_1 = __importDefault(require("react"));
9
- const hooks_1 = require("../../hooks");
10
- const types_1 = require("../../plugins/blockquote/types");
11
- const button_1 = require("../../plugins/button");
12
- const create_video_plugin_1 = require("../../plugins/embedded/video/create-video-plugin");
13
- const constants_1 = require("../../plugins/heading/constants");
14
- const types_2 = require("../../plugins/highlight/types");
15
- const types_3 = require("../../plugins/image/types");
16
- const constants_2 = require("../../plugins/link/constants");
17
- const constants_3 = require("../../plugins/list/constants");
18
- const types_4 = require("../../plugins/mark-bold/types");
19
- const types_5 = require("../../plugins/mark-code/types");
20
- const types_6 = require("../../plugins/mark-italic/types");
21
- const types_7 = require("../../plugins/mark-underline/types");
22
- const context_1 = require("../../translations/context");
23
- const utils_1 = require("../../utils");
24
- const button_toolbar_button_1 = require("./buttons/button-toolbar-button");
25
- const element_toolbar_button_1 = require("./buttons/element-toolbar-button");
26
- const image_toolbar_button_1 = require("./buttons/image-toolbar-button");
27
- const link_toolbar_button_1 = require("./buttons/link-toolbar-button");
28
- const list_toolbar_button_1 = require("./buttons/list-toolbar-button");
29
- const mark_toolbar_button_1 = require("./buttons/mark-toolbar-button");
30
- const undo_redo_button_group_1 = require("./buttons/undo-redo-button-group");
31
- const video_toolbar_button_1 = require("./buttons/video-toolbar-button");
32
- const CLASS_NAME = "uxf-wysiwyg__toolbar";
33
- const BUTTON_GROUP_CLASS_NAME = `${CLASS_NAME}-button-group`;
34
- const Toolbar = (props) => {
35
- var _a;
36
- // eslint-disable-next-line react/destructuring-assignment
37
- const { customPluginsButtons, leftElement, plateId, rightElement, ...restProps } = props;
38
- const editor = (0, hooks_1.useUxfPlateEditorState)(props.plateId);
39
- const t = (0, context_1.useTranslation)();
40
- return (react_1.default.createElement("div", { ...restProps, className: `${CLASS_NAME} ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
41
- leftElement,
42
- react_1.default.createElement("div", { className: `${CLASS_NAME}-buttons` },
43
- (0, utils_1.isSomeOfPluginsEnabled)(editor, constants_1.KEYS_HEADING) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-headings` },
44
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h1", plateId: plateId, pluginKey: constants_1.ELEMENT_H1, tooltipText: t("wysiwyg:plugins.h1.tooltip") }),
45
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h2", plateId: plateId, pluginKey: constants_1.ELEMENT_H2, tooltipText: t("wysiwyg:plugins.h2.tooltip") }),
46
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h3", plateId: plateId, pluginKey: constants_1.ELEMENT_H3, tooltipText: t("wysiwyg:plugins.h3.tooltip") }),
47
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h4", plateId: plateId, pluginKey: constants_1.ELEMENT_H4, tooltipText: t("wysiwyg:plugins.h4.tooltip") }),
48
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h5", plateId: plateId, pluginKey: constants_1.ELEMENT_H5, tooltipText: t("wysiwyg:plugins.h5.tooltip") }),
49
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h6", plateId: plateId, pluginKey: constants_1.ELEMENT_H6, tooltipText: t("wysiwyg:plugins.h6.tooltip") }))),
50
- (0, utils_1.isSomeOfPluginsEnabled)(editor, [
51
- types_4.BOLD_PLUGIN_KEY,
52
- types_6.ITALIC_PLUGIN_KEY,
53
- types_7.UNDER_LINE_PLUGIN_KEY,
54
- types_5.CODE_PLUGIN_KEY,
55
- types_2.HIGHLIGHT_PLUGIN_KEY,
56
- ]) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-marks` },
57
- react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "bold", iconSize: 12, plateId: plateId, pluginKey: types_4.BOLD_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.bold.tooltip") }),
58
- react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "italic", iconSize: 12, plateId: plateId, pluginKey: types_6.ITALIC_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.italic.tooltip") }),
59
- react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "underline", iconSize: 14, plateId: plateId, pluginKey: types_7.UNDER_LINE_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.underline.tooltip") }),
60
- react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "code-simple", plateId: plateId, pluginKey: types_5.CODE_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.code.tooltip") }),
61
- react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "highlighter-line", iconSize: 19, plateId: plateId, pluginKey: types_2.HIGHLIGHT_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.highlight.tooltip") }))),
62
- (0, utils_1.isSomeOfPluginsEnabled)(editor, [types_1.BLOCKQUOTE_PLUGIN_KEY]) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-blocks` },
63
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "block-quote", plateId: plateId, pluginKey: types_1.BLOCKQUOTE_PLUGIN_KEY, tooltipText: t("wysiwyg:plugins.quote.tooltip") }))),
64
- (0, utils_1.isSomeOfPluginsEnabled)(editor, [constants_3.LIST_UNORDERED_TYPE, constants_3.LIST_ORDERED_TYPE]) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-lists` },
65
- react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { iconName: "ul", plateId: plateId, pluginKey: constants_3.LIST_UNORDERED_TYPE, tooltipText: t("wysiwyg:plugins.ul.tooltip") }),
66
- react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { iconName: "ol", plateId: plateId, pluginKey: constants_3.LIST_ORDERED_TYPE, tooltipText: t("wysiwyg:plugins.ol.tooltip") }))),
67
- (0, utils_1.isSomeOfPluginsEnabled)(editor, [constants_2.ELEMENT_LINK, button_1.PLUGIN_BUTTON_KEY]) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-clickables` },
68
- react_1.default.createElement(link_toolbar_button_1.LinkToolbarButton, { plateId: plateId }),
69
- react_1.default.createElement(button_toolbar_button_1.ButtonToolbarButton, { plateId: plateId }))),
70
- (0, utils_1.isSomeOfPluginsEnabled)(editor, [types_3.IMAGE_PLUGIN_KEY, create_video_plugin_1.ELEMENT_VIDEO_EMBED]) && (react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-media` },
71
- react_1.default.createElement(image_toolbar_button_1.ImageToolbarButton, { plateId: plateId }),
72
- react_1.default.createElement(video_toolbar_button_1.VideoToolbarButton, { plateId: plateId }))),
73
- customPluginsButtons,
74
- react_1.default.createElement(undo_redo_button_group_1.UndoRedoButtonGroup, { plateId: plateId })),
75
- rightElement));
76
- };
77
- exports.Toolbar = Toolbar;
@@ -1,8 +0,0 @@
1
- import { PlateId } from "@udecode/plate-core";
2
- import { HTMLAttributes, ReactNode } from "react";
3
- export interface ToolbarProps extends HTMLAttributes<HTMLDivElement> {
4
- customPluginsButtons?: ReactNode;
5
- leftElement?: ReactNode;
6
- plateId: PlateId;
7
- rightElement?: ReactNode;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import { LeafUiComponent } from "../types";
2
- export declare const UnderlineMark: LeafUiComponent;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UnderlineMark = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const CLASS_NAME = "uxf-wysiwyg__element";
9
- const UnderlineMark = (props) => {
10
- var _a;
11
- return (react_1.default.createElement("u", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-underline ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` }, props.children));
12
- };
13
- exports.UnderlineMark = UnderlineMark;
package/ui/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { UxfEditor } from "../types";
2
- export declare const closeModalWithFocus: (editor: UxfEditor) => void;
package/ui/utils.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.closeModalWithFocus = void 0;
4
- const modal_service_1 = require("@uxf/ui/modal/modal-service");
5
- const utils_1 = require("../utils");
6
- const closeModalWithFocus = (editor) => {
7
- var _a;
8
- (0, modal_service_1.closeModal)();
9
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10
- const selection = (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.prevSelection;
11
- (0, utils_1.focusEditor)(editor, selection);
12
- };
13
- exports.closeModalWithFocus = closeModalWithFocus;
@@ -1,8 +0,0 @@
1
- import { FC } from "react";
2
- import { UxfEditor, UxfVideoElement } from "../../types";
3
- interface InsertVideoModalContentProps {
4
- editor: UxfEditor;
5
- editedVideo?: UxfVideoElement;
6
- }
7
- export declare const InsertVideoModalContent: FC<InsertVideoModalContentProps>;
8
- export {};
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.InsertVideoModalContent = void 0;
27
- const text_input_1 = require("@uxf/ui/text-input");
28
- const react_1 = __importStar(require("react"));
29
- const utils_1 = require("../../plugins/embedded/utils");
30
- const insert_video_1 = require("../../plugins/embedded/video/insert-video");
31
- const update_video_1 = require("../../plugins/embedded/video/update-video");
32
- const context_1 = require("../../translations/context");
33
- const modal_buttons_1 = require("../components/modal/modal-buttons");
34
- const modal_content_1 = require("../components/modal/modal-content");
35
- const utils_2 = require("../utils");
36
- const CLASS_NAME = "uxf-wysiwyg__insert-modal-video";
37
- // eslint-disable-next-line react/destructuring-assignment
38
- const InsertVideoModalContent = ({ editor, editedVideo }) => {
39
- var _a;
40
- const t = (0, context_1.useTranslation)();
41
- const [url, setUrl] = (0, react_1.useState)((_a = editedVideo === null || editedVideo === void 0 ? void 0 : editedVideo.url) !== null && _a !== void 0 ? _a : "");
42
- const [embedUrl, setEmbedUrl] = (0, react_1.useState)(editedVideo
43
- ? { id: editedVideo.videoId, provider: editedVideo.provider, url: editedVideo.embeddedUrl }
44
- : undefined);
45
- const [error, setError] = (0, react_1.useState)();
46
- const onSubmit = (0, react_1.useCallback)((event) => {
47
- event.preventDefault();
48
- setEmbedUrl((0, utils_1.parseVideoUrl)(url));
49
- if (!((embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && embedUrl.provider && embedUrl.id)) {
50
- setError("Neplatná URL adresa.");
51
- return;
52
- }
53
- if (editedVideo) {
54
- (0, update_video_1.updateVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id);
55
- }
56
- else {
57
- (0, insert_video_1.insertVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id);
58
- }
59
- (0, utils_2.closeModalWithFocus)(editor);
60
- }, [editedVideo, editor, embedUrl, url]);
61
- const onChange = (0, react_1.useCallback)((v) => {
62
- setUrl(v);
63
- setError(undefined);
64
- setEmbedUrl((0, utils_1.parseVideoUrl)(v));
65
- }, []);
66
- const title = editedVideo ? t("wysiwyg:plugins.video.button-edit") : t("wysiwyg:plugins.video.button-insert");
67
- return (react_1.default.createElement(modal_content_1.ModalContent, { title: title },
68
- react_1.default.createElement("form", { className: `${CLASS_NAME}__form`, id: "insert-video-form", onSubmit: onSubmit },
69
- react_1.default.createElement("div", { className: `${CLASS_NAME}__form-inputs` },
70
- react_1.default.createElement(text_input_1.TextInput, { helperText: error, isInvalid: Boolean(error), label: t("wysiwyg:plugins.video.url-address.label"), name: "url-address", onChange: onChange, placeholder: t("wysiwyg:plugins.video.url-address.placeholder"), type: "text", value: url })),
71
- (embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && (react_1.default.createElement("div", { className: `${CLASS_NAME}__iframe-wrapper` },
72
- react_1.default.createElement("iframe", { className: `${CLASS_NAME}__iframe`, height: "100%", src: embedUrl.url, title: t("wysiwyg:plugins.video.iframe-title"), width: "100%" }))),
73
- react_1.default.createElement(modal_buttons_1.ModalButtons, { className: `${CLASS_NAME}__form-buttons`, editor: editor, submitText: title }),
74
- react_1.default.createElement("button", { hidden: true, type: "submit" }))));
75
- };
76
- exports.InsertVideoModalContent = InsertVideoModalContent;
@@ -1,2 +0,0 @@
1
- import { ElementUiComponent, UxfVideoElement } from "../../types";
2
- export declare const VideoElement: ElementUiComponent<UxfVideoElement>;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.VideoElement = void 0;
27
- const dialog_panel_1 = require("@uxf/ui/dialog/dialog-panel");
28
- const modal_service_1 = require("@uxf/ui/modal/modal-service");
29
- const react_1 = __importStar(require("react"));
30
- const hooks_1 = require("../../hooks");
31
- const get_active_video_1 = require("../../plugins/embedded/video/get-active-video");
32
- const context_1 = require("../../translations/context");
33
- const utils_1 = require("../../utils");
34
- const element_with_action_buttons_1 = require("../components/element/element-with-action-buttons");
35
- const insert_video_modal_content_1 = require("./insert-video-modal-content");
36
- const CLASS_NAME = "uxf-wysiwyg__element";
37
- const VideoElement = (props) => {
38
- var _a;
39
- const t = (0, context_1.useTranslation)();
40
- const selected = (0, hooks_1.useSelected)();
41
- const onEdit = (0, react_1.useCallback)(() => {
42
- (0, modal_service_1.openModal)({
43
- children: (react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
44
- react_1.default.createElement(insert_video_modal_content_1.InsertVideoModalContent, { editedVideo: (0, get_active_video_1.getActiveVideo)(props.editor), editor: props.editor }))),
45
- });
46
- }, [props.editor]);
47
- const onDelete = (0, react_1.useCallback)(() => {
48
- (0, utils_1.removeSelectedNode)(props.editor);
49
- }, [props.editor]);
50
- return (react_1.default.createElement("div", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-video ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
51
- react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-video__action-buttons`, isSelected: selected, onDelete: onDelete, onEdit: onEdit },
52
- react_1.default.createElement("iframe", { className: `${CLASS_NAME}-video__iframe`, src: props.element.embeddedUrl, tabIndex: -1, title: t("wysiwyg:plugins.video.iframe-title") })),
53
- props.children));
54
- };
55
- exports.VideoElement = VideoElement;
@@ -1,7 +0,0 @@
1
- declare function hasProtocol(value: string): RegExpMatchArray | null;
2
- declare function isValid(value: string): boolean;
3
- export declare const UrlHelper: {
4
- hasProtocol: typeof hasProtocol;
5
- isValid: typeof isValid;
6
- };
7
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UrlHelper = void 0;
4
- const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
5
- function hasProtocol(value) {
6
- return value.match(new RegExp("^(https?://)|(tel:)|(mailto:)(#)(.*)"));
7
- }
8
- const URL_PATTERN = new RegExp("(^(https?:\\/\\/)?([\\da-z.-]+)\\.([a-z.]{2,6})([\\/\\w .-]*)(.*)$)|(^tel:\\+?[0-9\\-() ]+$)|(^mailto:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$)|(^#.*$)");
9
- function isValid(value) {
10
- return (0, is_not_nil_1.isNotNil)(value.match(URL_PATTERN));
11
- }
12
- exports.UrlHelper = {
13
- hasProtocol,
14
- isValid,
15
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const url_helper_1 = require("./url-helper");
4
- describe("UrlHelper", () => {
5
- describe("hasProtocol", () => {
6
- it("should return true for valid URLs with http or https protocols", () => {
7
- expect(url_helper_1.UrlHelper.hasProtocol("https://example.com")).not.toBeNull();
8
- expect(url_helper_1.UrlHelper.hasProtocol("http://example.com")).not.toBeNull();
9
- });
10
- it("should return true for tel protocol", () => {
11
- expect(url_helper_1.UrlHelper.hasProtocol("tel:+1234567890")).not.toBeNull();
12
- });
13
- it("should return true for mailto protocol", () => {
14
- expect(url_helper_1.UrlHelper.hasProtocol("mailto:test@example.com")).toBeNull();
15
- });
16
- it("should return false for invalid URLs", () => {
17
- expect(url_helper_1.UrlHelper.hasProtocol("example.com")).toBeNull();
18
- expect(url_helper_1.UrlHelper.hasProtocol("ftp://example.com")).toBeNull();
19
- expect(url_helper_1.UrlHelper.hasProtocol("")).toBeNull();
20
- });
21
- });
22
- describe("isValid", () => {
23
- it("should return true for valid URLs", () => {
24
- expect(url_helper_1.UrlHelper.isValid("https://example.com")).toBe(true);
25
- expect(url_helper_1.UrlHelper.isValid("http://example.com")).toBe(true);
26
- expect(url_helper_1.UrlHelper.isValid("example.com")).toBe(true);
27
- expect(url_helper_1.UrlHelper.isValid("tel:+1234567890")).toBe(true);
28
- expect(url_helper_1.UrlHelper.isValid("mailto:test@example.com")).toBe(true);
29
- expect(url_helper_1.UrlHelper.isValid("#section")).toBe(true);
30
- });
31
- it("should return false for invalid URLs", () => {
32
- expect(url_helper_1.UrlHelper.isValid("ftp://example.com")).toBe(false);
33
- expect(url_helper_1.UrlHelper.isValid("mailto:invalid-email")).toBe(false);
34
- expect(url_helper_1.UrlHelper.isValid("")).toBe(false);
35
- });
36
- });
37
- });
package/utils.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import { ToggleNodeTypeOptions } from "@udecode/plate-core";
2
- import { FindNodeOptions, GetNodeEntriesOptions } from "@udecode/slate";
3
- import { ToggleMarkOptions } from "@udecode/slate-utils";
4
- import { Location } from "slate";
5
- import { UxfBlockElement, UxfEditor, WysiwygContent } from "./types";
6
- export declare const getUxfEditor: (editor: UxfEditor) => import("@udecode/plate-common").Modify<UxfEditor, {
7
- operations: import("@udecode/plate-common").TOperation<import("@udecode/plate-common").EElementOrText<WysiwygContent>>[];
8
- isInline: (element: import("@udecode/plate-common").TElement | import("./types").LicElement | import("./types").LiElement | import("./types").WysiwygRootBlock) => boolean;
9
- isVoid: (element: import("@udecode/plate-common").TElement | import("./types").LicElement | import("./types").LiElement | import("./types").WysiwygRootBlock) => boolean;
10
- normalizeNode: (entry: import("@udecode/plate-common").TNodeEntry<import("@udecode/plate-common").ENode<WysiwygContent>>) => void;
11
- apply: (operation: import("@udecode/plate-common").TOperation<import("@udecode/plate-common").EElementOrText<WysiwygContent>>) => void;
12
- getFragment: () => import("@udecode/plate-common").EElementOrText<WysiwygContent>[];
13
- insertFragment: (fragment: import("@udecode/plate-common").EElementOrText<WysiwygContent>[]) => void;
14
- insertNode: (node: import("@udecode/plate-common").EElementOrText<WysiwygContent> | import("@udecode/plate-common").EElementOrText<WysiwygContent>[]) => void;
15
- }>;
16
- export declare const getPluginOptions: <P = import("@udecode/plate-common").AnyObject>(editor: UxfEditor, pluginKey: string) => P;
17
- export declare const getPluginType: (editor: UxfEditor, key: string) => string;
18
- export declare const someNode: (editor: UxfEditor, options: FindNodeOptions<WysiwygContent>) => boolean;
19
- export declare const toggleNodeType: (editor: UxfEditor, options: ToggleNodeTypeOptions, editorNodesOptions?: Omit<GetNodeEntriesOptions<WysiwygContent>, "match"> | undefined) => void;
20
- export declare const focusEditor: (editor: UxfEditor, target?: Location | undefined) => void;
21
- export declare const isRangeInSingleText: (editor: UxfEditor) => boolean;
22
- export declare const isMarkActive: (editor: UxfEditor, type: string) => boolean;
23
- export declare const toggleMark: (editor: UxfEditor, { key, clear }: ToggleMarkOptions) => void;
24
- export declare const isPluginEnabled: (editor: UxfEditor, pluginKey: string) => boolean;
25
- export declare const isSomeOfPluginsEnabled: (editor: UxfEditor, pluginKeys: string[]) => boolean;
26
- export declare const getSelectedNode: (editor: UxfEditor) => UxfBlockElement | null;
27
- export declare const getActiveElement: <E extends UxfBlockElement = UxfBlockElement>(editor: UxfEditor, elementKey: string) => E | undefined;
28
- export declare const removeElement: (editor: UxfEditor, node: UxfBlockElement) => boolean;
29
- export declare const insertVoid: (editor: UxfEditor, node: UxfBlockElement) => void;
30
- export declare const removeSelectedNode: (editor: UxfEditor) => void;
package/utils.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSelectedNode = exports.insertVoid = exports.removeElement = exports.getActiveElement = exports.getSelectedNode = exports.isSomeOfPluginsEnabled = exports.isPluginEnabled = exports.toggleMark = exports.isMarkActive = exports.isRangeInSingleText = exports.focusEditor = exports.toggleNodeType = exports.someNode = exports.getPluginType = exports.getPluginOptions = exports.getUxfEditor = void 0;
4
- const plate_break_1 = require("@udecode/plate-break");
5
- const plate_common_1 = require("@udecode/plate-common");
6
- const plate_core_1 = require("@udecode/plate-core");
7
- const slate_1 = require("@udecode/slate");
8
- const slate_react_1 = require("@udecode/slate-react");
9
- const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
- const types_1 = require("./plugins/paragraph/types");
11
- const getUxfEditor = (editor) => (0, slate_1.getTEditor)(editor);
12
- exports.getUxfEditor = getUxfEditor;
13
- const getPluginOptions = (editor, pluginKey) => {
14
- return (0, plate_core_1.getPluginOptions)(editor, pluginKey);
15
- };
16
- exports.getPluginOptions = getPluginOptions;
17
- const getPluginType = (editor, key) => (0, plate_core_1.getPluginType)(editor, key);
18
- exports.getPluginType = getPluginType;
19
- const someNode = (editor, options) => (0, plate_common_1.someNode)(editor, options);
20
- exports.someNode = someNode;
21
- const toggleNodeType = (editor, options, editorNodesOptions) => (0, plate_core_1.toggleNodeType)(editor, options, editorNodesOptions);
22
- exports.toggleNodeType = toggleNodeType;
23
- const focusEditor = (editor, target) => (0, plate_common_1.focusEditor)(editor, target);
24
- exports.focusEditor = focusEditor;
25
- const isRangeInSingleText = (editor) => editor.selection ? (0, plate_common_1.isRangeInSingleText)(editor.selection) : false;
26
- exports.isRangeInSingleText = isRangeInSingleText;
27
- const isMarkActive = (editor, type) => (0, plate_common_1.isMarkActive)(editor, type) && (0, exports.isRangeInSingleText)(editor);
28
- exports.isMarkActive = isMarkActive;
29
- const toggleMark = (editor, { key, clear }) => (0, plate_common_1.toggleMark)(editor, { key, clear });
30
- exports.toggleMark = toggleMark;
31
- const isPluginEnabled = (editor, pluginKey) => editor.plugins.findIndex((plugin) => plugin.key === pluginKey) !== -1;
32
- exports.isPluginEnabled = isPluginEnabled;
33
- const isSomeOfPluginsEnabled = (editor, pluginKeys) => editor.plugins.some((plugin) => pluginKeys.includes(plugin.key));
34
- exports.isSomeOfPluginsEnabled = isSomeOfPluginsEnabled;
35
- const getSelectedNode = (editor) => {
36
- var _a;
37
- const selection = editor.selection;
38
- const firstAnchorPath = selection === null || selection === void 0 ? void 0 : selection.anchor.path.at(0);
39
- if ((0, is_not_nil_1.isNotNil)(firstAnchorPath)) {
40
- return (_a = editor.children.at(firstAnchorPath)) !== null && _a !== void 0 ? _a : null;
41
- }
42
- return null;
43
- };
44
- exports.getSelectedNode = getSelectedNode;
45
- const getActiveElement = (editor, elementKey) => {
46
- var _a;
47
- const entry = (0, slate_1.findNode)(editor, {
48
- match: {
49
- type: (0, exports.getPluginType)(editor, elementKey),
50
- },
51
- at: (_a = editor.selection) !== null && _a !== void 0 ? _a : undefined,
52
- });
53
- if (!entry) {
54
- return;
55
- }
56
- const [element] = entry;
57
- return element;
58
- };
59
- exports.getActiveElement = getActiveElement;
60
- const removeElement = (editor, node) => {
61
- var _a;
62
- const path = (0, slate_react_1.findNodePath)(editor, node);
63
- (0, slate_1.removeNodes)(editor, { at: path });
64
- (0, exports.focusEditor)(editor, (_a = editor.selection) !== null && _a !== void 0 ? _a : undefined);
65
- return true;
66
- };
67
- exports.removeElement = removeElement;
68
- const insertVoid = (editor, node) => {
69
- var _a;
70
- const selectedNode = (0, exports.getSelectedNode)(editor);
71
- if (!selectedNode) {
72
- (0, slate_1.insertNodes)(editor, node);
73
- }
74
- else {
75
- if (selectedNode.type !== types_1.PARAGRAPH_PLUGIN_TYPE || !(0, slate_1.isElementEmpty)(editor, selectedNode)) {
76
- (0, plate_break_1.exitBreak)(editor, {});
77
- }
78
- (0, slate_1.setNodes)(editor, node);
79
- }
80
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
81
- (0, exports.focusEditor)(editor, (_a = editor.selection) !== null && _a !== void 0 ? _a : editor.prevSelection);
82
- };
83
- exports.insertVoid = insertVoid;
84
- const removeSelectedNode = (editor) => {
85
- (0, slate_1.removeNodes)(editor);
86
- (0, exports.focusEditor)(editor);
87
- };
88
- exports.removeSelectedNode = removeSelectedNode;
@@ -1,17 +0,0 @@
1
- import { TEditableProps } from "@udecode/plate-core";
2
- import { FC, ReactNode } from "react";
3
- import { TranslationFunction } from "./translations/translations";
4
- import { UxfPlatePlugin, WysiwygContent } from "./types";
5
- export interface WysiwygEditorProps {
6
- className?: string;
7
- customPluginsToolbarButtons?: ReactNode;
8
- editableProps?: TEditableProps<WysiwygContent>;
9
- id: string;
10
- initialValue: WysiwygContent | undefined;
11
- onChange: (value: WysiwygContent) => void;
12
- plugins: UxfPlatePlugin[];
13
- t?: TranslationFunction;
14
- toolbarLeftElement?: ReactNode;
15
- toolbarRightElement?: ReactNode;
16
- }
17
- export declare const WysiwygEditor: FC<WysiwygEditorProps>;
package/wysiwyg-editor.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.WysiwygEditor = void 0;
8
- const plate_core_1 = require("@udecode/plate-core");
9
- const use_is_mounted_1 = require("@uxf/core-react/hooks/use-is-mounted");
10
- const classes_1 = require("@uxf/core/constants/classes");
11
- const loader_1 = require("@uxf/ui/loader");
12
- const react_1 = __importDefault(require("react"));
13
- const context_1 = require("./translations/context");
14
- const translations_1 = require("./translations/translations");
15
- const toolbar_1 = require("./ui/toolbar/toolbar");
16
- const CLASS_NAME = "uxf-wysiwyg";
17
- const Editor = (props) => {
18
- var _a, _b;
19
- const t = (0, context_1.useTranslation)();
20
- return (react_1.default.createElement(react_1.default.Fragment, null,
21
- react_1.default.createElement(toolbar_1.Toolbar, { customPluginsButtons: props.customPluginsToolbarButtons, leftElement: props.toolbarLeftElement, plateId: props.plateId, rightElement: props.toolbarRightElement }),
22
- react_1.default.createElement("div", { className: `${CLASS_NAME}__content` },
23
- react_1.default.createElement(plate_core_1.Plate, { editableProps: {
24
- autoFocus: false,
25
- placeholder: t("wysiwyg:common.placeholder"),
26
- readOnly: false,
27
- spellCheck: false,
28
- ...props.editableProps,
29
- className: `${CLASS_NAME}__editable ${(_b = (_a = props.editableProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""}`,
30
- }, id: props.plateId, normalizeInitialValue: true }))));
31
- };
32
- const WysiwygEditor = (props) => {
33
- var _a, _b, _c;
34
- const isMounted = (0, use_is_mounted_1.useIsMounted)();
35
- if (!isMounted) {
36
- return (react_1.default.createElement("div", { className: `${CLASS_NAME} ${CLASS_NAME}--${classes_1.CLASSES.IS_LOADING} ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
37
- react_1.default.createElement(loader_1.Loader, { className: `${CLASS_NAME}__loader` })));
38
- }
39
- return (react_1.default.createElement("div", { className: `${CLASS_NAME} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}` },
40
- react_1.default.createElement(context_1.TranslationContextProvider, { value: (_c = props.t) !== null && _c !== void 0 ? _c : translations_1.defaultTranslationFunction },
41
- react_1.default.createElement(plate_core_1.PlateProvider, { id: props.id, initialValue: props.initialValue, onChange: props.onChange, plugins: props.plugins },
42
- react_1.default.createElement(Editor, { customPluginsToolbarButtons: props.customPluginsToolbarButtons, editableProps: props.editableProps, plateId: props.id, toolbarLeftElement: props.toolbarLeftElement, toolbarRightElement: props.toolbarRightElement })))));
43
- };
44
- exports.WysiwygEditor = WysiwygEditor;
@@ -1,5 +0,0 @@
1
- import { WysiwygContent } from "@uxf/wysiwyg";
2
- import React from "react";
3
- export declare const initialValue: WysiwygContent;
4
- export declare function Playground(): React.JSX.Element;
5
- export declare function SelectedPlugins(): React.JSX.Element;