@uxf/wysiwyg 13.0.3 → 14.1.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 (33) hide show
  1. package/hooks.js +21 -7
  2. package/package.json +8 -8
  3. package/plugins/image/create-image-plugin.js +6 -0
  4. package/plugins/image/image-upload-errors.test.d.ts +1 -0
  5. package/plugins/image/image-upload-errors.test.js +78 -0
  6. package/plugins/image/with-paste-image-url.js +24 -3
  7. package/plugins/link/floating-link-wrapper.js +111 -8
  8. package/plugins/link/hooks/use-floating-link-selectors.js +67 -7
  9. package/plugins/link/hooks/use-link-actions.js +127 -31
  10. package/plugins/link/hooks/use-link-submit-on-enter.js +58 -12
  11. package/ui/button/button-element.js +72 -48
  12. package/ui/button/insert-button-modal-content.js +183 -40
  13. package/ui/components/modal/modal-button-cancel.js +46 -44
  14. package/ui/floating-link.js +381 -46
  15. package/ui/image/image-element.js +72 -48
  16. package/ui/image/insert-image-modal-content.js +268 -45
  17. package/ui/paragraph-element.js +1 -1
  18. package/ui/paragraph-element.test.d.ts +1 -0
  19. package/ui/paragraph-element.test.js +15 -0
  20. package/ui/toolbar/buttons/button-toolbar-button.js +37 -2
  21. package/ui/toolbar/buttons/element-toolbar-button.js +53 -8
  22. package/ui/toolbar/buttons/image-toolbar-button.js +37 -2
  23. package/ui/toolbar/buttons/link-toolbar-button.js +53 -9
  24. package/ui/toolbar/buttons/list-toolbar-button.js +50 -9
  25. package/ui/toolbar/buttons/mark-toolbar-button.js +49 -9
  26. package/ui/toolbar/buttons/toolbar-button.js +59 -14
  27. package/ui/toolbar/buttons/undo-redo-button-group.js +132 -58
  28. package/ui/toolbar/buttons/video-toolbar-button.js +37 -2
  29. package/ui/toolbar/toolbar.js +162 -38
  30. package/ui/video/insert-video-modal-content.js +160 -36
  31. package/ui/video/video-element.js +83 -48
  32. package/wysiwyg-editor.js +187 -37
  33. package/wysiwyg-editor.stories.js +291 -121
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Toolbar = void 0;
7
+ const compiler_runtime_1 = require("react/compiler-runtime");
7
8
  const translations_1 = require("@uxf/core-react/translations");
8
9
  const button_group_1 = require("@uxf/ui/button-group");
9
10
  const react_1 = __importDefault(require("react"));
@@ -31,47 +32,170 @@ const undo_redo_button_group_1 = require("./buttons/undo-redo-button-group");
31
32
  const video_toolbar_button_1 = require("./buttons/video-toolbar-button");
32
33
  const CLASS_NAME = "uxf-wysiwyg__toolbar";
33
34
  const BUTTON_GROUP_CLASS_NAME = `${CLASS_NAME}-button-group`;
34
- const Toolbar = (props) => {
35
+ const Toolbar = props => {
35
36
  var _a;
36
- // eslint-disable-next-line react/destructuring-assignment
37
- const { customPluginsButtons, leftElement, plateId, rightElement, ...restProps } = props;
37
+ const $ = (0, compiler_runtime_1.c)(45);
38
+ let customPluginsButtons;
39
+ let leftElement;
40
+ let plateId;
41
+ let restProps;
42
+ let rightElement;
43
+ if ($[0] !== props) {
44
+ ({
45
+ customPluginsButtons,
46
+ leftElement,
47
+ plateId,
48
+ rightElement,
49
+ ...restProps
50
+ } = props);
51
+ $[0] = props;
52
+ $[1] = customPluginsButtons;
53
+ $[2] = leftElement;
54
+ $[3] = plateId;
55
+ $[4] = restProps;
56
+ $[5] = rightElement;
57
+ }
58
+ else {
59
+ customPluginsButtons = $[1];
60
+ leftElement = $[2];
61
+ plateId = $[3];
62
+ restProps = $[4];
63
+ rightElement = $[5];
64
+ }
38
65
  const editor = (0, hooks_1.useUxfPlateEditorState)(props.plateId);
39
66
  const t = (0, translations_1.useUxfTranslation)();
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("uxf-wysiwyg:plugins.headings.h1.tooltip") }),
45
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h2", plateId: plateId, pluginKey: constants_1.ELEMENT_H2, tooltipText: t("uxf-wysiwyg:plugins.headings.h2.tooltip") }),
46
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h3", plateId: plateId, pluginKey: constants_1.ELEMENT_H3, tooltipText: t("uxf-wysiwyg:plugins.headings.h3.tooltip") }),
47
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h4", plateId: plateId, pluginKey: constants_1.ELEMENT_H4, tooltipText: t("uxf-wysiwyg:plugins.headings.h4.tooltip") }),
48
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h5", plateId: plateId, pluginKey: constants_1.ELEMENT_H5, tooltipText: t("uxf-wysiwyg:plugins.headings.h5.tooltip") }),
49
- react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h6", plateId: plateId, pluginKey: constants_1.ELEMENT_H6, tooltipText: t("uxf-wysiwyg:plugins.headings.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("uxf-wysiwyg:plugins.formatting.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("uxf-wysiwyg:plugins.formatting.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("uxf-wysiwyg:plugins.formatting.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("uxf-wysiwyg:plugins.formatting.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("uxf-wysiwyg:plugins.formatting.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("uxf-wysiwyg:plugins.blocks.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("uxf-wysiwyg:plugins.lists.ul.tooltip") }),
66
- react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { iconName: "ol", plateId: plateId, pluginKey: constants_3.LIST_ORDERED_TYPE, tooltipText: t("uxf-wysiwyg:plugins.lists.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 }))),
67
+ const t0 = `${CLASS_NAME} ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`;
68
+ let t1;
69
+ if ($[6] !== editor || $[7] !== plateId || $[8] !== t) {
70
+ t1 = (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` },
71
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h1", plateId: plateId, pluginKey: constants_1.ELEMENT_H1, tooltipText: t("uxf-wysiwyg:plugins.headings.h1.tooltip") }),
72
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h2", plateId: plateId, pluginKey: constants_1.ELEMENT_H2, tooltipText: t("uxf-wysiwyg:plugins.headings.h2.tooltip") }),
73
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h3", plateId: plateId, pluginKey: constants_1.ELEMENT_H3, tooltipText: t("uxf-wysiwyg:plugins.headings.h3.tooltip") }),
74
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h4", plateId: plateId, pluginKey: constants_1.ELEMENT_H4, tooltipText: t("uxf-wysiwyg:plugins.headings.h4.tooltip") }),
75
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h5", plateId: plateId, pluginKey: constants_1.ELEMENT_H5, tooltipText: t("uxf-wysiwyg:plugins.headings.h5.tooltip") }),
76
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "h6", plateId: plateId, pluginKey: constants_1.ELEMENT_H6, tooltipText: t("uxf-wysiwyg:plugins.headings.h6.tooltip") }));
77
+ $[6] = editor;
78
+ $[7] = plateId;
79
+ $[8] = t;
80
+ $[9] = t1;
81
+ }
82
+ else {
83
+ t1 = $[9];
84
+ }
85
+ let t2;
86
+ if ($[10] !== editor || $[11] !== plateId || $[12] !== t) {
87
+ t2 = (0, utils_1.isSomeOfPluginsEnabled)(editor, [types_4.BOLD_PLUGIN_KEY, types_6.ITALIC_PLUGIN_KEY, types_7.UNDER_LINE_PLUGIN_KEY, types_5.CODE_PLUGIN_KEY, types_2.HIGHLIGHT_PLUGIN_KEY]) && react_1.default.createElement(button_group_1.ButtonGroup, { className: `${BUTTON_GROUP_CLASS_NAME} ${BUTTON_GROUP_CLASS_NAME}-marks` },
88
+ react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "bold", iconSize: 12, plateId: plateId, pluginKey: types_4.BOLD_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.formatting.bold.tooltip") }),
89
+ react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "italic", iconSize: 12, plateId: plateId, pluginKey: types_6.ITALIC_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.formatting.italic.tooltip") }),
90
+ react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "underline", iconSize: 14, plateId: plateId, pluginKey: types_7.UNDER_LINE_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.formatting.underline.tooltip") }),
91
+ react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "code-simple", plateId: plateId, pluginKey: types_5.CODE_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.formatting.code.tooltip") }),
92
+ react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { iconName: "highlighter-line", iconSize: 19, plateId: plateId, pluginKey: types_2.HIGHLIGHT_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.formatting.highlight.tooltip") }));
93
+ $[10] = editor;
94
+ $[11] = plateId;
95
+ $[12] = t;
96
+ $[13] = t2;
97
+ }
98
+ else {
99
+ t2 = $[13];
100
+ }
101
+ let t3;
102
+ if ($[14] !== editor || $[15] !== plateId || $[16] !== t) {
103
+ t3 = (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` },
104
+ react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { iconName: "block-quote", plateId: plateId, pluginKey: types_1.BLOCKQUOTE_PLUGIN_KEY, tooltipText: t("uxf-wysiwyg:plugins.blocks.quote.tooltip") }));
105
+ $[14] = editor;
106
+ $[15] = plateId;
107
+ $[16] = t;
108
+ $[17] = t3;
109
+ }
110
+ else {
111
+ t3 = $[17];
112
+ }
113
+ let t4;
114
+ if ($[18] !== editor || $[19] !== plateId || $[20] !== t) {
115
+ t4 = (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` },
116
+ react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { iconName: "ul", plateId: plateId, pluginKey: constants_3.LIST_UNORDERED_TYPE, tooltipText: t("uxf-wysiwyg:plugins.lists.ul.tooltip") }),
117
+ react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { iconName: "ol", plateId: plateId, pluginKey: constants_3.LIST_ORDERED_TYPE, tooltipText: t("uxf-wysiwyg:plugins.lists.ol.tooltip") }));
118
+ $[18] = editor;
119
+ $[19] = plateId;
120
+ $[20] = t;
121
+ $[21] = t4;
122
+ }
123
+ else {
124
+ t4 = $[21];
125
+ }
126
+ let t5;
127
+ if ($[22] !== editor || $[23] !== plateId) {
128
+ t5 = (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` },
129
+ react_1.default.createElement(link_toolbar_button_1.LinkToolbarButton, { plateId: plateId }),
130
+ react_1.default.createElement(button_toolbar_button_1.ButtonToolbarButton, { plateId: plateId }));
131
+ $[22] = editor;
132
+ $[23] = plateId;
133
+ $[24] = t5;
134
+ }
135
+ else {
136
+ t5 = $[24];
137
+ }
138
+ let t6;
139
+ if ($[25] !== editor || $[26] !== plateId) {
140
+ t6 = (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` },
141
+ react_1.default.createElement(image_toolbar_button_1.ImageToolbarButton, { plateId: plateId }),
142
+ react_1.default.createElement(video_toolbar_button_1.VideoToolbarButton, { plateId: plateId }));
143
+ $[25] = editor;
144
+ $[26] = plateId;
145
+ $[27] = t6;
146
+ }
147
+ else {
148
+ t6 = $[27];
149
+ }
150
+ let t7;
151
+ if ($[28] !== plateId) {
152
+ t7 = react_1.default.createElement(undo_redo_button_group_1.UndoRedoButtonGroup, { plateId: plateId });
153
+ $[28] = plateId;
154
+ $[29] = t7;
155
+ }
156
+ else {
157
+ t7 = $[29];
158
+ }
159
+ let t8;
160
+ if ($[30] !== customPluginsButtons || $[31] !== t1 || $[32] !== t2 || $[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7) {
161
+ t8 = react_1.default.createElement("div", { className: `${CLASS_NAME}-buttons` },
162
+ t1,
163
+ t2,
164
+ t3,
165
+ t4,
166
+ t5,
167
+ t6,
73
168
  customPluginsButtons,
74
- react_1.default.createElement(undo_redo_button_group_1.UndoRedoButtonGroup, { plateId: plateId })),
75
- rightElement));
169
+ t7);
170
+ $[30] = customPluginsButtons;
171
+ $[31] = t1;
172
+ $[32] = t2;
173
+ $[33] = t3;
174
+ $[34] = t4;
175
+ $[35] = t5;
176
+ $[36] = t6;
177
+ $[37] = t7;
178
+ $[38] = t8;
179
+ }
180
+ else {
181
+ t8 = $[38];
182
+ }
183
+ let t9;
184
+ if ($[39] !== leftElement || $[40] !== restProps || $[41] !== rightElement || $[42] !== t0 || $[43] !== t8) {
185
+ t9 = react_1.default.createElement("div", { ...restProps, className: t0 },
186
+ leftElement,
187
+ t8,
188
+ rightElement);
189
+ $[39] = leftElement;
190
+ $[40] = restProps;
191
+ $[41] = rightElement;
192
+ $[42] = t0;
193
+ $[43] = t8;
194
+ $[44] = t9;
195
+ }
196
+ else {
197
+ t9 = $[44];
198
+ }
199
+ return t9;
76
200
  };
77
201
  exports.Toolbar = Toolbar;
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.InsertVideoModalContent = void 0;
37
+ const compiler_runtime_1 = require("react/compiler-runtime");
37
38
  const translations_1 = require("@uxf/core-react/translations");
38
39
  const text_input_1 = require("@uxf/ui/text-input");
39
40
  const react_1 = __importStar(require("react"));
@@ -46,45 +47,168 @@ const modal_content_1 = require("../components/modal/modal-content");
46
47
  const utils_2 = require("../utils");
47
48
  const CLASS_NAME = "uxf-wysiwyg__insert-modal-video";
48
49
  // eslint-disable-next-line react/destructuring-assignment
49
- const InsertVideoModalContent = ({ editor, editedVideo }) => {
50
+ const InsertVideoModalContent = t0 => {
50
51
  var _a;
52
+ const $ = (0, compiler_runtime_1.c)(37);
53
+ const { editor, editedVideo } = t0;
51
54
  const t = (0, translations_1.useUxfTranslation)();
52
55
  const [url, setUrl] = (0, react_1.useState)((_a = editedVideo === null || editedVideo === void 0 ? void 0 : editedVideo.url) !== null && _a !== void 0 ? _a : "");
53
- const [embedUrl, setEmbedUrl] = (0, react_1.useState)(editedVideo
54
- ? { id: editedVideo.videoId, provider: editedVideo.provider, url: editedVideo.embeddedUrl }
55
- : undefined);
56
+ let t1;
57
+ if ($[0] !== editedVideo) {
58
+ t1 = editedVideo ? {
59
+ id: editedVideo.videoId,
60
+ provider: editedVideo.provider,
61
+ url: editedVideo.embeddedUrl
62
+ } : undefined;
63
+ $[0] = editedVideo;
64
+ $[1] = t1;
65
+ }
66
+ else {
67
+ t1 = $[1];
68
+ }
69
+ const [embedUrl, setEmbedUrl] = (0, react_1.useState)(t1);
56
70
  const [error, setError] = (0, react_1.useState)();
57
- const onSubmit = (0, react_1.useCallback)(async (event) => {
58
- event.preventDefault();
59
- setEmbedUrl((0, utils_1.parseVideoUrl)(url));
60
- if (!((embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && embedUrl.provider && embedUrl.id)) {
61
- setError(t("uxf-wysiwyg:plugins.video.url-address.invalid"));
62
- return;
63
- }
64
- const metaData = await (0, get_video_meta_data_1.getVideoMetaData)(embedUrl.provider, embedUrl.id);
65
- if (editedVideo) {
66
- (0, update_video_1.updateVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
67
- }
68
- else {
69
- (0, insert_video_1.insertVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
70
- }
71
- (0, utils_2.closeModalWithFocus)(editor);
72
- }, [editedVideo, editor, embedUrl, url, t]);
73
- const onChange = (0, react_1.useCallback)((v) => {
74
- setUrl(v);
75
- setError(undefined);
76
- setEmbedUrl((0, utils_1.parseVideoUrl)(v));
77
- }, []);
78
- const title = editedVideo
79
- ? t("uxf-wysiwyg:plugins.video.button-edit")
80
- : t("uxf-wysiwyg:plugins.video.button-insert");
81
- return (react_1.default.createElement(modal_content_1.ModalContent, { title: title },
82
- react_1.default.createElement("form", { className: `${CLASS_NAME}__form`, id: "insert-video-form", onSubmit: onSubmit },
83
- react_1.default.createElement("div", { className: `${CLASS_NAME}__form-inputs` },
84
- react_1.default.createElement(text_input_1.TextInput, { helperText: error, isInvalid: Boolean(error), label: t("uxf-wysiwyg:plugins.video.url-address.label"), name: "url-address", onChange: onChange, placeholder: t("uxf-wysiwyg:plugins.video.url-address.placeholder"), type: "text", value: url })),
85
- (embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && (react_1.default.createElement("div", { className: `${CLASS_NAME}__iframe-wrapper` },
86
- react_1.default.createElement("iframe", { className: `${CLASS_NAME}__iframe`, height: "100%", src: embedUrl.url, title: t("uxf-wysiwyg:plugins.video.iframe-title"), width: "100%" }))),
87
- react_1.default.createElement(modal_buttons_1.ModalButtons, { className: `${CLASS_NAME}__form-buttons`, editor: editor, submitText: title }),
88
- react_1.default.createElement("button", { hidden: true, type: "submit" }))));
71
+ let t2;
72
+ if ($[2] !== editedVideo || $[3] !== editor || $[4] !== embedUrl || $[5] !== t || $[6] !== url) {
73
+ t2 = async (event) => {
74
+ event.preventDefault();
75
+ setEmbedUrl((0, utils_1.parseVideoUrl)(url));
76
+ if (!((embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && embedUrl.provider && embedUrl.id)) {
77
+ setError(t("uxf-wysiwyg:plugins.video.url-address.invalid"));
78
+ return;
79
+ }
80
+ const metaData = await (0, get_video_meta_data_1.getVideoMetaData)(embedUrl.provider, embedUrl.id);
81
+ if (editedVideo) {
82
+ (0, update_video_1.updateVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
83
+ }
84
+ else {
85
+ (0, insert_video_1.insertVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
86
+ }
87
+ (0, utils_2.closeModalWithFocus)(editor);
88
+ };
89
+ $[2] = editedVideo;
90
+ $[3] = editor;
91
+ $[4] = embedUrl;
92
+ $[5] = t;
93
+ $[6] = url;
94
+ $[7] = t2;
95
+ }
96
+ else {
97
+ t2 = $[7];
98
+ }
99
+ const onSubmit = t2;
100
+ let t3;
101
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
102
+ t3 = v => {
103
+ setUrl(v);
104
+ setError(undefined);
105
+ setEmbedUrl((0, utils_1.parseVideoUrl)(v));
106
+ };
107
+ $[8] = t3;
108
+ }
109
+ else {
110
+ t3 = $[8];
111
+ }
112
+ const onChange = t3;
113
+ let t4;
114
+ if ($[9] !== editedVideo || $[10] !== t) {
115
+ t4 = editedVideo ? t("uxf-wysiwyg:plugins.video.button-edit") : t("uxf-wysiwyg:plugins.video.button-insert");
116
+ $[9] = editedVideo;
117
+ $[10] = t;
118
+ $[11] = t4;
119
+ }
120
+ else {
121
+ t4 = $[11];
122
+ }
123
+ const title = t4;
124
+ const t5 = Boolean(error);
125
+ let t6;
126
+ if ($[12] !== t) {
127
+ t6 = t("uxf-wysiwyg:plugins.video.url-address.label");
128
+ $[12] = t;
129
+ $[13] = t6;
130
+ }
131
+ else {
132
+ t6 = $[13];
133
+ }
134
+ let t7;
135
+ if ($[14] !== t) {
136
+ t7 = t("uxf-wysiwyg:plugins.video.url-address.placeholder");
137
+ $[14] = t;
138
+ $[15] = t7;
139
+ }
140
+ else {
141
+ t7 = $[15];
142
+ }
143
+ let t8;
144
+ if ($[16] !== error || $[17] !== t5 || $[18] !== t6 || $[19] !== t7 || $[20] !== url) {
145
+ t8 = react_1.default.createElement("div", { className: `${CLASS_NAME}__form-inputs` },
146
+ react_1.default.createElement(text_input_1.TextInput, { helperText: error, isInvalid: t5, label: t6, name: "url-address", onChange: onChange, placeholder: t7, type: "text", value: url }));
147
+ $[16] = error;
148
+ $[17] = t5;
149
+ $[18] = t6;
150
+ $[19] = t7;
151
+ $[20] = url;
152
+ $[21] = t8;
153
+ }
154
+ else {
155
+ t8 = $[21];
156
+ }
157
+ let t9;
158
+ if ($[22] !== embedUrl || $[23] !== t) {
159
+ t9 = (embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && react_1.default.createElement("div", { className: `${CLASS_NAME}__iframe-wrapper` },
160
+ react_1.default.createElement("iframe", { className: `${CLASS_NAME}__iframe`, height: "100%", src: embedUrl.url, title: t("uxf-wysiwyg:plugins.video.iframe-title"), width: "100%" }));
161
+ $[22] = embedUrl;
162
+ $[23] = t;
163
+ $[24] = t9;
164
+ }
165
+ else {
166
+ t9 = $[24];
167
+ }
168
+ let t10;
169
+ if ($[25] !== editor || $[26] !== title) {
170
+ t10 = react_1.default.createElement(modal_buttons_1.ModalButtons, { className: `${CLASS_NAME}__form-buttons`, editor: editor, submitText: title });
171
+ $[25] = editor;
172
+ $[26] = title;
173
+ $[27] = t10;
174
+ }
175
+ else {
176
+ t10 = $[27];
177
+ }
178
+ let t11;
179
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
180
+ t11 = react_1.default.createElement("button", { hidden: true, type: "submit" });
181
+ $[28] = t11;
182
+ }
183
+ else {
184
+ t11 = $[28];
185
+ }
186
+ let t12;
187
+ if ($[29] !== onSubmit || $[30] !== t10 || $[31] !== t8 || $[32] !== t9) {
188
+ t12 = react_1.default.createElement("form", { className: `${CLASS_NAME}__form`, id: "insert-video-form", onSubmit: onSubmit },
189
+ t8,
190
+ t9,
191
+ t10,
192
+ t11);
193
+ $[29] = onSubmit;
194
+ $[30] = t10;
195
+ $[31] = t8;
196
+ $[32] = t9;
197
+ $[33] = t12;
198
+ }
199
+ else {
200
+ t12 = $[33];
201
+ }
202
+ let t13;
203
+ if ($[34] !== t12 || $[35] !== title) {
204
+ t13 = react_1.default.createElement(modal_content_1.ModalContent, { title: title }, t12);
205
+ $[34] = t12;
206
+ $[35] = title;
207
+ $[36] = t13;
208
+ }
209
+ else {
210
+ t13 = $[36];
211
+ }
212
+ return t13;
89
213
  };
90
214
  exports.InsertVideoModalContent = InsertVideoModalContent;
@@ -1,66 +1,101 @@
1
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.VideoElement = void 0;
7
+ const compiler_runtime_1 = require("react/compiler-runtime");
37
8
  const translations_1 = require("@uxf/core-react/translations");
38
9
  const dialog_panel_1 = require("@uxf/ui/dialog/dialog-panel");
39
10
  const modal_service_1 = require("@uxf/ui/modal/modal-service");
40
- const react_1 = __importStar(require("react"));
11
+ const react_1 = __importDefault(require("react"));
41
12
  const hooks_1 = require("../../hooks");
42
13
  const get_active_video_1 = require("../../plugins/embedded/video/get-active-video");
43
14
  const utils_1 = require("../../utils");
44
15
  const element_with_action_buttons_1 = require("../components/element/element-with-action-buttons");
45
16
  const insert_video_modal_content_1 = require("./insert-video-modal-content");
46
17
  const CLASS_NAME = "uxf-wysiwyg__element";
47
- const VideoElement = (props) => {
18
+ const VideoElement = props => {
48
19
  var _a;
20
+ const $ = (0, compiler_runtime_1.c)(19);
49
21
  const t = (0, translations_1.useUxfTranslation)();
50
22
  const isSelected = (0, hooks_1.useSelected)();
51
- const onEdit = (0, react_1.useCallback)(() => {
52
- (0, modal_service_1.openModal)({
53
- children: (react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
54
- react_1.default.createElement(insert_video_modal_content_1.InsertVideoModalContent, { editedVideo: (0, get_active_video_1.getActiveVideo)(props.editor), editor: props.editor }))),
55
- });
56
- }, [props.editor]);
57
- const onDelete = (0, react_1.useCallback)(() => {
58
- (0, utils_1.removeSelectedNode)(props.editor);
59
- }, [props.editor]);
23
+ let t0;
24
+ if ($[0] !== props.editor) {
25
+ t0 = () => {
26
+ (0, modal_service_1.openModal)({
27
+ children: react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
28
+ react_1.default.createElement(insert_video_modal_content_1.InsertVideoModalContent, { editedVideo: (0, get_active_video_1.getActiveVideo)(props.editor), editor: props.editor }))
29
+ });
30
+ };
31
+ $[0] = props.editor;
32
+ $[1] = t0;
33
+ }
34
+ else {
35
+ t0 = $[1];
36
+ }
37
+ const onEdit = t0;
38
+ let t1;
39
+ if ($[2] !== props.editor) {
40
+ t1 = () => {
41
+ (0, utils_1.removeSelectedNode)(props.editor);
42
+ };
43
+ $[2] = props.editor;
44
+ $[3] = t1;
45
+ }
46
+ else {
47
+ t1 = $[3];
48
+ }
49
+ const onDelete = t1;
60
50
  const element = props.element;
61
- return (react_1.default.createElement("div", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-video ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
62
- react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-video__action-buttons`, isSelected: isSelected, onDelete: onDelete, onEdit: onEdit },
63
- react_1.default.createElement("iframe", { className: `${CLASS_NAME}-video__iframe`, src: element.embeddedUrl, tabIndex: -1, title: t("uxf-wysiwyg:plugins.video.iframe-title") })),
64
- props.children));
51
+ const t2 = props.attributes;
52
+ const t3 = `${CLASS_NAME} ${CLASS_NAME}-video ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`;
53
+ const t4 = element.embeddedUrl;
54
+ let t5;
55
+ if ($[4] !== t) {
56
+ t5 = t("uxf-wysiwyg:plugins.video.iframe-title");
57
+ $[4] = t;
58
+ $[5] = t5;
59
+ }
60
+ else {
61
+ t5 = $[5];
62
+ }
63
+ let t6;
64
+ if ($[6] !== element.embeddedUrl || $[7] !== t5) {
65
+ t6 = react_1.default.createElement("iframe", { className: `${CLASS_NAME}-video__iframe`, src: t4, tabIndex: -1, title: t5 });
66
+ $[6] = element.embeddedUrl;
67
+ $[7] = t5;
68
+ $[8] = t6;
69
+ }
70
+ else {
71
+ t6 = $[8];
72
+ }
73
+ let t7;
74
+ if ($[9] !== isSelected || $[10] !== onDelete || $[11] !== onEdit || $[12] !== t6) {
75
+ t7 = react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-video__action-buttons`, isSelected: isSelected, onDelete: onDelete, onEdit: onEdit }, t6);
76
+ $[9] = isSelected;
77
+ $[10] = onDelete;
78
+ $[11] = onEdit;
79
+ $[12] = t6;
80
+ $[13] = t7;
81
+ }
82
+ else {
83
+ t7 = $[13];
84
+ }
85
+ let t8;
86
+ if ($[14] !== props.attributes || $[15] !== props.children || $[16] !== t3 || $[17] !== t7) {
87
+ t8 = react_1.default.createElement("div", { ...t2, className: t3 },
88
+ t7,
89
+ props.children);
90
+ $[14] = props.attributes;
91
+ $[15] = props.children;
92
+ $[16] = t3;
93
+ $[17] = t7;
94
+ $[18] = t8;
95
+ }
96
+ else {
97
+ t8 = $[18];
98
+ }
99
+ return t8;
65
100
  };
66
101
  exports.VideoElement = VideoElement;