@uxf/wysiwyg 11.74.0 → 11.74.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.d.ts +7 -0
- package/components.js +34 -0
- package/config/icons-config.d.ts +2 -0
- package/config/icons-config.js +5 -0
- package/config/icons.d.ts +183 -0
- package/config/icons.js +51 -0
- package/create-all-plugins-with-ui.d.ts +64 -0
- package/create-all-plugins-with-ui.js +127 -0
- package/create-plugins-with-ui.d.ts +4 -0
- package/create-plugins-with-ui.js +47 -0
- package/hooks.d.ts +9 -0
- package/hooks.js +20 -0
- package/index.d.ts +6 -0
- package/index.js +38 -0
- package/package.json +3 -3
- package/plugins/blockquote/create-blockquote-plugin.d.ts +3 -0
- package/plugins/blockquote/create-blockquote-plugin.js +9 -0
- package/plugins/blockquote/types.d.ts +2 -0
- package/plugins/blockquote/types.js +6 -0
- package/plugins/button/constants.d.ts +2 -0
- package/plugins/button/constants.js +5 -0
- package/plugins/button/create-button-plugin.d.ts +2 -0
- package/plugins/button/create-button-plugin.js +11 -0
- package/plugins/button/index.d.ts +3 -0
- package/plugins/button/index.js +23 -0
- package/plugins/button/transforms/get-active-button.d.ts +2 -0
- package/plugins/button/transforms/get-active-button.js +9 -0
- package/plugins/button/transforms/index.d.ts +4 -0
- package/plugins/button/transforms/index.js +11 -0
- package/plugins/button/transforms/insert-button.d.ts +2 -0
- package/plugins/button/transforms/insert-button.js +16 -0
- package/plugins/button/transforms/is-button-active.d.ts +2 -0
- package/plugins/button/transforms/is-button-active.js +7 -0
- package/plugins/button/transforms/remove-selected-button.d.ts +2 -0
- package/plugins/button/transforms/remove-selected-button.js +13 -0
- package/plugins/button/transforms/update-button.d.ts +2 -0
- package/plugins/button/transforms/update-button.js +9 -0
- package/plugins/embedded/utils.d.ts +1 -0
- package/plugins/embedded/utils.js +7 -0
- package/plugins/embedded/video/create-video-plugin.d.ts +4 -0
- package/plugins/embedded/video/create-video-plugin.js +19 -0
- package/plugins/embedded/video/get-active-video.d.ts +2 -0
- package/plugins/embedded/video/get-active-video.js +9 -0
- package/plugins/embedded/video/insert-video.d.ts +2 -0
- package/plugins/embedded/video/insert-video.js +19 -0
- package/plugins/embedded/video/update-video.d.ts +2 -0
- package/plugins/embedded/video/update-video.js +12 -0
- package/plugins/exit-break/create-exit-break-plugin.d.ts +3 -0
- package/plugins/exit-break/create-exit-break-plugin.js +30 -0
- package/plugins/heading/constants.d.ts +8 -0
- package/plugins/heading/constants.js +11 -0
- package/plugins/heading/create-headings-plugin.d.ts +8 -0
- package/plugins/heading/create-headings-plugin.js +40 -0
- package/plugins/highlight/createHighlightPlugin.d.ts +3 -0
- package/plugins/highlight/createHighlightPlugin.js +27 -0
- package/plugins/highlight/types.d.ts +10 -0
- package/plugins/highlight/types.js +4 -0
- package/plugins/image/create-image-plugin.d.ts +6 -0
- package/plugins/image/create-image-plugin.js +105 -0
- package/plugins/image/hooks/use-image-handlers.d.ts +5 -0
- package/plugins/image/hooks/use-image-handlers.js +19 -0
- package/plugins/image/transforms/get-active-image.d.ts +2 -0
- package/plugins/image/transforms/get-active-image.js +9 -0
- package/plugins/image/transforms/insert-image.d.ts +3 -0
- package/plugins/image/transforms/insert-image.js +19 -0
- package/plugins/image/transforms/is-image-active.d.ts +2 -0
- package/plugins/image/transforms/is-image-active.js +7 -0
- package/plugins/image/transforms/remove-selected-image.d.ts +2 -0
- package/plugins/image/transforms/remove-selected-image.js +13 -0
- package/plugins/image/transforms/update-image.d.ts +3 -0
- package/plugins/image/transforms/update-image.js +12 -0
- package/plugins/image/types.d.ts +12 -0
- package/plugins/image/types.js +6 -0
- package/plugins/image/utils/is-image-url.d.ts +2 -0
- package/plugins/image/utils/is-image-url.js +135 -0
- package/plugins/image/with-image.d.ts +7 -0
- package/plugins/image/with-image.js +19 -0
- package/plugins/image/with-paste-image-url.d.ts +7 -0
- package/plugins/image/with-paste-image-url.js +36 -0
- package/plugins/image/with-paste-image.d.ts +7 -0
- package/plugins/image/with-paste-image.js +49 -0
- package/plugins/link/constants.d.ts +2 -0
- package/plugins/link/constants.js +6 -0
- package/plugins/link/create-link-plugin.d.ts +3 -0
- package/plugins/link/create-link-plugin.js +15 -0
- package/plugins/link/floating-link-wrapper.d.ts +11 -0
- package/plugins/link/floating-link-wrapper.js +26 -0
- package/plugins/link/hooks/index.d.ts +4 -0
- package/plugins/link/hooks/index.js +11 -0
- package/plugins/link/hooks/use-link-actions.d.ts +12 -0
- package/plugins/link/hooks/use-link-actions.js +48 -0
- package/plugins/link/hooks/use-link-cancel-on-escape.d.ts +1 -0
- package/plugins/link/hooks/use-link-cancel-on-escape.js +5 -0
- package/plugins/link/hooks/use-link-submit-on-enter.d.ts +1 -0
- package/plugins/link/hooks/use-link-submit-on-enter.js +23 -0
- package/plugins/link/transforms/get-active-link.d.ts +3 -0
- package/plugins/link/transforms/get-active-link.js +17 -0
- package/plugins/link/transforms/insert-link.d.ts +2 -0
- package/plugins/link/transforms/insert-link.js +27 -0
- package/plugins/link/transforms/is-link-selected.d.ts +2 -0
- package/plugins/link/transforms/is-link-selected.js +15 -0
- package/plugins/link/transforms/submit-link.d.ts +8 -0
- package/plugins/link/transforms/submit-link.js +36 -0
- package/plugins/link/transforms/trigger-link-insert-or-edit.d.ts +2 -0
- package/plugins/link/transforms/trigger-link-insert-or-edit.js +6 -0
- package/plugins/link/transforms/unwrap-link.d.ts +2 -0
- package/plugins/link/transforms/unwrap-link.js +10 -0
- package/plugins/link/types.d.ts +5 -0
- package/plugins/link/types.js +2 -0
- package/plugins/list/constants.d.ts +4 -0
- package/plugins/list/constants.js +14 -0
- package/plugins/list/create-list-plugin.d.ts +4 -0
- package/plugins/list/create-list-plugin.js +16 -0
- package/plugins/mark-bold/create-bold-plugin.d.ts +3 -0
- package/plugins/mark-bold/create-bold-plugin.js +6 -0
- package/plugins/mark-bold/types.d.ts +2 -0
- package/plugins/mark-bold/types.js +6 -0
- package/plugins/mark-code/create-code-plugin.d.ts +3 -0
- package/plugins/mark-code/create-code-plugin.js +6 -0
- package/plugins/mark-code/types.d.ts +2 -0
- package/plugins/mark-code/types.js +6 -0
- package/plugins/mark-italic/create-italic-plugin.d.ts +3 -0
- package/plugins/mark-italic/create-italic-plugin.js +6 -0
- package/plugins/mark-italic/types.d.ts +2 -0
- package/plugins/mark-italic/types.js +6 -0
- package/plugins/mark-underline/create-underline-plugin.d.ts +3 -0
- package/plugins/mark-underline/create-underline-plugin.js +6 -0
- package/plugins/mark-underline/types.d.ts +2 -0
- package/plugins/mark-underline/types.js +6 -0
- package/plugins/node-id/add-ids-to-nodes.d.ts +2 -0
- package/plugins/node-id/add-ids-to-nodes.js +22 -0
- package/plugins/node-id/create-node-id-plugin.d.ts +3 -0
- package/plugins/node-id/create-node-id-plugin.js +6 -0
- package/plugins/paragraph/create-paragraph-plugin.d.ts +3 -0
- package/plugins/paragraph/create-paragraph-plugin.js +9 -0
- package/plugins/paragraph/types.d.ts +2 -0
- package/plugins/paragraph/types.js +6 -0
- package/plugins/reset-node/create-reset-node.d.ts +3 -0
- package/plugins/reset-node/create-reset-node.js +28 -0
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.d.ts +3 -0
- package/plugins/select-on-backspace/create-select-on-backspace-plugin.js +14 -0
- package/plugins/soft-break/create-soft-break-plugin.d.ts +3 -0
- package/plugins/soft-break/create-soft-break-plugin.js +22 -0
- package/plugins/trailing-block/create-trailing-block-plugin.d.ts +3 -0
- package/plugins/trailing-block/create-trailing-block-plugin.js +6 -0
- package/serializers/serialize-to-plaintext.d.ts +2 -0
- package/serializers/serialize-to-plaintext.js +8 -0
- package/translations/cs.json +134 -0
- package/translations/de.json +134 -0
- package/translations/en.json +134 -0
- package/translations/sk.json +134 -0
- package/types.d.ts +118 -0
- package/types.js +2 -0
- package/ui/blockquote-element.d.ts +2 -0
- package/ui/blockquote-element.js +13 -0
- package/ui/bold-mark.d.ts +2 -0
- package/ui/bold-mark.js +13 -0
- package/ui/button/button-element.d.ts +2 -0
- package/ui/button/button-element.js +54 -0
- package/ui/button/index.d.ts +1 -0
- package/ui/button/index.js +5 -0
- package/ui/button/insert-button-modal-content.d.ts +8 -0
- package/ui/button/insert-button-modal-content.js +81 -0
- package/ui/code-mark.d.ts +2 -0
- package/ui/code-mark.js +13 -0
- package/ui/components/element/element-action-buttons.d.ts +9 -0
- package/ui/components/element/element-action-buttons.js +22 -0
- package/ui/components/element/element-with-action-buttons.d.ts +10 -0
- package/ui/components/element/element-with-action-buttons.js +17 -0
- package/ui/components/modal/modal-button-cancel.d.ts +9 -0
- package/ui/components/modal/modal-button-cancel.js +45 -0
- package/ui/components/modal/modal-button-submit.d.ts +6 -0
- package/ui/components/modal/modal-button-submit.js +12 -0
- package/ui/components/modal/modal-buttons.d.ts +11 -0
- package/ui/components/modal/modal-buttons.js +16 -0
- package/ui/components/modal/modal-content.d.ts +6 -0
- package/ui/components/modal/modal-content.js +14 -0
- package/ui/create-uxf-ui.d.ts +21 -0
- package/ui/create-uxf-ui.js +51 -0
- package/ui/floating-link.d.ts +2 -0
- package/ui/floating-link.js +110 -0
- package/ui/heading-elements.d.ts +7 -0
- package/ui/heading-elements.js +38 -0
- package/ui/highlight-mark.d.ts +3 -0
- package/ui/highlight-mark.js +13 -0
- package/ui/image/image-element.d.ts +2 -0
- package/ui/image/image-element.js +53 -0
- package/ui/image/insert-image-modal-content.d.ts +8 -0
- package/ui/image/insert-image-modal-content.js +89 -0
- package/ui/italic-mark.d.ts +2 -0
- package/ui/italic-mark.js +13 -0
- package/ui/link-element.d.ts +3 -0
- package/ui/link-element.js +14 -0
- package/ui/list-item-element.d.ts +2 -0
- package/ui/list-item-element.js +13 -0
- package/ui/list-ordered-element.d.ts +2 -0
- package/ui/list-ordered-element.js +13 -0
- package/ui/list-unordered-element.d.ts +2 -0
- package/ui/list-unordered-element.js +13 -0
- package/ui/paragraph-element.d.ts +2 -0
- package/ui/paragraph-element.js +13 -0
- package/ui/toolbar/buttons/button-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/button-toolbar-button.js +20 -0
- package/ui/toolbar/buttons/element-toolbar-button.d.ts +12 -0
- package/ui/toolbar/buttons/element-toolbar-button.js +25 -0
- package/ui/toolbar/buttons/image-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/image-toolbar-button.js +20 -0
- package/ui/toolbar/buttons/link-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/link-toolbar-button.js +29 -0
- package/ui/toolbar/buttons/list-toolbar-button.d.ts +13 -0
- package/ui/toolbar/buttons/list-toolbar-button.js +27 -0
- package/ui/toolbar/buttons/mark-toolbar-button.d.ts +13 -0
- package/ui/toolbar/buttons/mark-toolbar-button.js +25 -0
- package/ui/toolbar/buttons/modal-toolbar-button.d.ts +15 -0
- package/ui/toolbar/buttons/modal-toolbar-button.js +22 -0
- package/ui/toolbar/buttons/toolbar-button.d.ts +15 -0
- package/ui/toolbar/buttons/toolbar-button.js +35 -0
- package/ui/toolbar/buttons/undo-redo-button-group.d.ts +8 -0
- package/ui/toolbar/buttons/undo-redo-button-group.js +64 -0
- package/ui/toolbar/buttons/video-toolbar-button.d.ts +10 -0
- package/ui/toolbar/buttons/video-toolbar-button.js +20 -0
- package/ui/toolbar/toolbar.d.ts +3 -0
- package/ui/toolbar/toolbar.js +77 -0
- package/ui/toolbar/types.d.ts +8 -0
- package/ui/toolbar/types.js +2 -0
- package/ui/underline-mark.d.ts +2 -0
- package/ui/underline-mark.js +13 -0
- package/ui/utils.d.ts +2 -0
- package/ui/utils.js +13 -0
- package/ui/video/insert-video-modal-content.d.ts +8 -0
- package/ui/video/insert-video-modal-content.js +80 -0
- package/ui/video/video-element.d.ts +2 -0
- package/ui/video/video-element.js +55 -0
- package/utils/get-video-meta-data.d.ts +2 -0
- package/utils/get-video-meta-data.js +41 -0
- package/utils/url-helper.d.ts +7 -0
- package/utils/url-helper.js +15 -0
- package/utils/url-helper.test.d.ts +1 -0
- package/utils/url-helper.test.js +37 -0
- package/utils.d.ts +30 -0
- package/utils.js +88 -0
- package/wysiwyg-editor.d.ts +15 -0
- package/wysiwyg-editor.js +42 -0
- package/wysiwyg-editor.stories.d.ts +5 -0
- package/wysiwyg-editor.stories.js +193 -0
|
@@ -0,0 +1,80 @@
|
|
|
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 translations_1 = require("@uxf/core-react/translations");
|
|
28
|
+
const text_input_1 = require("@uxf/ui/text-input");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const utils_1 = require("../../plugins/embedded/utils");
|
|
31
|
+
const insert_video_1 = require("../../plugins/embedded/video/insert-video");
|
|
32
|
+
const update_video_1 = require("../../plugins/embedded/video/update-video");
|
|
33
|
+
const get_video_meta_data_1 = require("../../utils/get-video-meta-data");
|
|
34
|
+
const modal_buttons_1 = require("../components/modal/modal-buttons");
|
|
35
|
+
const modal_content_1 = require("../components/modal/modal-content");
|
|
36
|
+
const utils_2 = require("../utils");
|
|
37
|
+
const CLASS_NAME = "uxf-wysiwyg__insert-modal-video";
|
|
38
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
39
|
+
const InsertVideoModalContent = ({ editor, editedVideo }) => {
|
|
40
|
+
var _a;
|
|
41
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
42
|
+
const [url, setUrl] = (0, react_1.useState)((_a = editedVideo === null || editedVideo === void 0 ? void 0 : editedVideo.url) !== null && _a !== void 0 ? _a : "");
|
|
43
|
+
const [embedUrl, setEmbedUrl] = (0, react_1.useState)(editedVideo
|
|
44
|
+
? { id: editedVideo.videoId, provider: editedVideo.provider, url: editedVideo.embeddedUrl }
|
|
45
|
+
: undefined);
|
|
46
|
+
const [error, setError] = (0, react_1.useState)();
|
|
47
|
+
const onSubmit = (0, react_1.useCallback)(async (event) => {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
setEmbedUrl((0, utils_1.parseVideoUrl)(url));
|
|
50
|
+
if (!((embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && embedUrl.provider && embedUrl.id)) {
|
|
51
|
+
setError(t("uxf-wysiwyg:plugins.video.url-address.invalid"));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const metaData = await (0, get_video_meta_data_1.getVideoMetaData)(embedUrl.provider, embedUrl.id);
|
|
55
|
+
if (editedVideo) {
|
|
56
|
+
(0, update_video_1.updateVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
(0, insert_video_1.insertVideo)(editor, url, embedUrl.url, embedUrl.provider, embedUrl.id, metaData);
|
|
60
|
+
}
|
|
61
|
+
(0, utils_2.closeModalWithFocus)(editor);
|
|
62
|
+
}, [editedVideo, editor, embedUrl, url, t]);
|
|
63
|
+
const onChange = (0, react_1.useCallback)((v) => {
|
|
64
|
+
setUrl(v);
|
|
65
|
+
setError(undefined);
|
|
66
|
+
setEmbedUrl((0, utils_1.parseVideoUrl)(v));
|
|
67
|
+
}, []);
|
|
68
|
+
const title = editedVideo
|
|
69
|
+
? t("uxf-wysiwyg:plugins.video.button-edit")
|
|
70
|
+
: t("uxf-wysiwyg:plugins.video.button-insert");
|
|
71
|
+
return (react_1.default.createElement(modal_content_1.ModalContent, { title: title },
|
|
72
|
+
react_1.default.createElement("form", { className: `${CLASS_NAME}__form`, id: "insert-video-form", onSubmit: onSubmit },
|
|
73
|
+
react_1.default.createElement("div", { className: `${CLASS_NAME}__form-inputs` },
|
|
74
|
+
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 })),
|
|
75
|
+
(embedUrl === null || embedUrl === void 0 ? void 0 : embedUrl.url) && (react_1.default.createElement("div", { className: `${CLASS_NAME}__iframe-wrapper` },
|
|
76
|
+
react_1.default.createElement("iframe", { className: `${CLASS_NAME}__iframe`, height: "100%", src: embedUrl.url, title: t("uxf-wysiwyg:plugins.video.iframe-title"), width: "100%" }))),
|
|
77
|
+
react_1.default.createElement(modal_buttons_1.ModalButtons, { className: `${CLASS_NAME}__form-buttons`, editor: editor, submitText: title }),
|
|
78
|
+
react_1.default.createElement("button", { hidden: true, type: "submit" }))));
|
|
79
|
+
};
|
|
80
|
+
exports.InsertVideoModalContent = InsertVideoModalContent;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 translations_1 = require("@uxf/core-react/translations");
|
|
28
|
+
const dialog_panel_1 = require("@uxf/ui/dialog/dialog-panel");
|
|
29
|
+
const modal_service_1 = require("@uxf/ui/modal/modal-service");
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const hooks_1 = require("../../hooks");
|
|
32
|
+
const get_active_video_1 = require("../../plugins/embedded/video/get-active-video");
|
|
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, translations_1.useUxfTranslation)();
|
|
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("uxf-wysiwyg:plugins.video.iframe-title") })),
|
|
53
|
+
props.children));
|
|
54
|
+
};
|
|
55
|
+
exports.VideoElement = VideoElement;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVideoMetaData = getVideoMetaData;
|
|
4
|
+
function getOembedEndpoint(provider, id) {
|
|
5
|
+
switch (provider) {
|
|
6
|
+
case "youtube":
|
|
7
|
+
return `https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${id}&format=json`;
|
|
8
|
+
case "vimeo":
|
|
9
|
+
return `https://vimeo.com/api/oembed.json?url=https://vimeo.com/${id}`;
|
|
10
|
+
default:
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function getVideoMetaData(provider, id) {
|
|
15
|
+
const endpoint = getOembedEndpoint(provider, id);
|
|
16
|
+
if (endpoint === null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return fetch(endpoint)
|
|
20
|
+
.then((res) => res.json())
|
|
21
|
+
.then((data) => ({
|
|
22
|
+
authorName: data.author_name,
|
|
23
|
+
authorUrl: data.author_url,
|
|
24
|
+
width: data.width,
|
|
25
|
+
height: data.height,
|
|
26
|
+
description: data.description,
|
|
27
|
+
duration: data.duration,
|
|
28
|
+
uploadDate: data.upload_date,
|
|
29
|
+
thumbnail: {
|
|
30
|
+
width: data.thumbnail_width,
|
|
31
|
+
height: data.thumbnail_height,
|
|
32
|
+
url: data.thumbnail_url,
|
|
33
|
+
},
|
|
34
|
+
title: data.title,
|
|
35
|
+
}))
|
|
36
|
+
.catch((e) => {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.error(e);
|
|
39
|
+
return null;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TEditableProps } from "@udecode/plate-core";
|
|
2
|
+
import { FC, ReactNode } from "react";
|
|
3
|
+
import { UxfPlatePlugin, WysiwygContent } from "./types";
|
|
4
|
+
export interface WysiwygEditorProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
customPluginsToolbarButtons?: ReactNode;
|
|
7
|
+
editableProps?: TEditableProps<WysiwygContent>;
|
|
8
|
+
id: string;
|
|
9
|
+
initialValue: WysiwygContent | undefined;
|
|
10
|
+
onChange: (value: WysiwygContent) => void;
|
|
11
|
+
plugins: UxfPlatePlugin[];
|
|
12
|
+
toolbarLeftElement?: ReactNode;
|
|
13
|
+
toolbarRightElement?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const WysiwygEditor: FC<WysiwygEditorProps>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 translations_1 = require("@uxf/core-react/translations");
|
|
11
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
12
|
+
const loader_1 = require("@uxf/ui/loader");
|
|
13
|
+
const react_1 = __importDefault(require("react"));
|
|
14
|
+
const toolbar_1 = require("./ui/toolbar/toolbar");
|
|
15
|
+
const CLASS_NAME = "uxf-wysiwyg";
|
|
16
|
+
const Editor = (props) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
19
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
20
|
+
react_1.default.createElement(toolbar_1.Toolbar, { customPluginsButtons: props.customPluginsToolbarButtons, leftElement: props.toolbarLeftElement, plateId: props.plateId, rightElement: props.toolbarRightElement }),
|
|
21
|
+
react_1.default.createElement("div", { className: `${CLASS_NAME}__content` },
|
|
22
|
+
react_1.default.createElement(plate_core_1.Plate, { editableProps: {
|
|
23
|
+
autoFocus: false,
|
|
24
|
+
placeholder: t("uxf-wysiwyg:common.placeholder"),
|
|
25
|
+
readOnly: false,
|
|
26
|
+
spellCheck: false,
|
|
27
|
+
...props.editableProps,
|
|
28
|
+
className: `${CLASS_NAME}__editable ${(_b = (_a = props.editableProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""}`,
|
|
29
|
+
}, id: props.plateId, normalizeInitialValue: true }))));
|
|
30
|
+
};
|
|
31
|
+
const WysiwygEditor = (props) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const isMounted = (0, use_is_mounted_1.useIsMounted)();
|
|
34
|
+
if (!isMounted) {
|
|
35
|
+
return (react_1.default.createElement("div", { className: `${CLASS_NAME} ${CLASS_NAME}--${classes_1.CLASSES.IS_LOADING} ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
|
|
36
|
+
react_1.default.createElement(loader_1.Loader, { className: `${CLASS_NAME}__loader` })));
|
|
37
|
+
}
|
|
38
|
+
return (react_1.default.createElement("div", { className: `${CLASS_NAME} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}` },
|
|
39
|
+
react_1.default.createElement(plate_core_1.PlateProvider, { id: props.id, initialValue: props.initialValue, onChange: props.onChange, plugins: props.plugins },
|
|
40
|
+
react_1.default.createElement(Editor, { customPluginsToolbarButtons: props.customPluginsToolbarButtons, editableProps: props.editableProps, plateId: props.id, toolbarLeftElement: props.toolbarLeftElement, toolbarRightElement: props.toolbarRightElement }))));
|
|
41
|
+
};
|
|
42
|
+
exports.WysiwygEditor = WysiwygEditor;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.initialValue = void 0;
|
|
28
|
+
exports.Playground = Playground;
|
|
29
|
+
exports.SelectedPlugins = SelectedPlugins;
|
|
30
|
+
const show_1 = require("@uxf/core-react/components/show");
|
|
31
|
+
const use_is_mounted_1 = require("@uxf/core-react/hooks/use-is-mounted");
|
|
32
|
+
const wysiwyg_1 = require("@uxf/wysiwyg");
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
34
|
+
exports.initialValue = [
|
|
35
|
+
{
|
|
36
|
+
type: "h1",
|
|
37
|
+
id: "mnlt6",
|
|
38
|
+
children: [{ text: "Nadpis H1" }],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "h2",
|
|
42
|
+
id: "feu6s",
|
|
43
|
+
children: [{ text: "Nadpis H2" }],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "h3",
|
|
47
|
+
id: "i9cb4",
|
|
48
|
+
children: [{ text: "Nadpis H3" }],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "h4",
|
|
52
|
+
id: "967c7",
|
|
53
|
+
children: [{ text: "Nadpis H4" }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "h5",
|
|
57
|
+
id: "4kyki",
|
|
58
|
+
children: [{ text: "Nadpis H5" }],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: "h6",
|
|
62
|
+
id: "ximag",
|
|
63
|
+
children: [{ text: "Nadpis H6" }],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "paragraph",
|
|
67
|
+
id: "xnws3",
|
|
68
|
+
children: [
|
|
69
|
+
{ text: "Toto je odstavec. " },
|
|
70
|
+
{ type: "link", id: "j4bh1", url: "https://uxf.cz", target: "_blank", children: [{ text: "uxf.cz" }] },
|
|
71
|
+
{ text: " " },
|
|
72
|
+
{ text: "tučné ", bold: true },
|
|
73
|
+
{ text: "kurzíva ", italic: true },
|
|
74
|
+
{ text: "podtržení", underline: true },
|
|
75
|
+
{ text: " kód", code: true },
|
|
76
|
+
{ text: " " },
|
|
77
|
+
{ text: "zvýraznění", highlight: true },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "blockquote",
|
|
82
|
+
id: "imx33",
|
|
83
|
+
children: [{ text: "Toto je citace." }],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: "ul",
|
|
87
|
+
id: "aq7rl",
|
|
88
|
+
children: [
|
|
89
|
+
{
|
|
90
|
+
type: "li",
|
|
91
|
+
id: "b8ljb",
|
|
92
|
+
children: [
|
|
93
|
+
{
|
|
94
|
+
type: "lic",
|
|
95
|
+
id: "az5v2",
|
|
96
|
+
children: [{ text: "Položka nečíslovaného seznamu" }],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: "li",
|
|
102
|
+
id: "nq1e3",
|
|
103
|
+
children: [{ type: "lic", id: "dp5er", children: [{ text: "Druhá položka" }] }],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "ol",
|
|
109
|
+
id: "hioy1",
|
|
110
|
+
children: [
|
|
111
|
+
{
|
|
112
|
+
type: "li",
|
|
113
|
+
id: "wm2vd",
|
|
114
|
+
children: [{ type: "lic", id: "q5ynx", children: [{ text: "Položka číslovaného seznamu" }] }],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: "li",
|
|
118
|
+
id: "5qjr0",
|
|
119
|
+
children: [{ type: "lic", id: "8u41x", children: [{ text: "Druhá položka" }] }],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: "paragraph",
|
|
125
|
+
id: "9013p",
|
|
126
|
+
children: [
|
|
127
|
+
{
|
|
128
|
+
text: "Pokud vypneš nějaký plugin, zobrazení je nefunkční, ale v JSONu pořád je, protože je v initial values.",
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
function Playground() {
|
|
134
|
+
const [value, setValue] = (0, react_1.useState)(exports.initialValue);
|
|
135
|
+
const plugins = (0, wysiwyg_1.createPluginsWithUi)([
|
|
136
|
+
(0, wysiwyg_1.createHeadingsPluginWithUi)({ disabledLevels: [1] }),
|
|
137
|
+
(0, wysiwyg_1.createBoldPluginWithUi)(),
|
|
138
|
+
(0, wysiwyg_1.createImagePluginWithUi)({
|
|
139
|
+
uploadImage: async (file) => ({
|
|
140
|
+
id: 1,
|
|
141
|
+
name: URL.createObjectURL(file),
|
|
142
|
+
extension: ".ext",
|
|
143
|
+
namespace: "wysiwyg",
|
|
144
|
+
uuid: "this-should-be-some-random-uuid",
|
|
145
|
+
}),
|
|
146
|
+
getImageUrl: (file) => file.name,
|
|
147
|
+
}),
|
|
148
|
+
(0, wysiwyg_1.createHighlightPluginWithUi)("red"),
|
|
149
|
+
]);
|
|
150
|
+
const isMounted = (0, use_is_mounted_1.useIsMounted)();
|
|
151
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
152
|
+
react_1.default.createElement(wysiwyg_1.WysiwygEditor, { id: "editor", initialValue: exports.initialValue, onChange: setValue, plugins: plugins }),
|
|
153
|
+
react_1.default.createElement("div", { className: "relative mt-4" },
|
|
154
|
+
react_1.default.createElement("div", { "aria-hidden": "true", className: "absolute inset-0 flex items-center" },
|
|
155
|
+
react_1.default.createElement("div", { className: "w-full border-t border-gray-300" })),
|
|
156
|
+
react_1.default.createElement("div", { className: "relative flex justify-center" },
|
|
157
|
+
react_1.default.createElement("span", { className: "bg-white px-2 text-sm text-gray-500" }, "Value"))),
|
|
158
|
+
react_1.default.createElement(show_1.Show, { when: isMounted },
|
|
159
|
+
react_1.default.createElement("pre", null,
|
|
160
|
+
react_1.default.createElement("code", null, JSON.stringify(value, null, " "))))));
|
|
161
|
+
}
|
|
162
|
+
function SelectedPlugins() {
|
|
163
|
+
const _initialValues = [
|
|
164
|
+
{ type: "paragraph", id: "mnlt6", children: [{ text: "Použití pouze vybraných pluginů" }] },
|
|
165
|
+
];
|
|
166
|
+
const [value, setValue] = (0, react_1.useState)(_initialValues);
|
|
167
|
+
const plugins = (0, wysiwyg_1.createPluginsWithUi)([
|
|
168
|
+
(0, wysiwyg_1.createHeadingsPluginWithUi)({ disabledLevels: [1] }),
|
|
169
|
+
(0, wysiwyg_1.createBoldPluginWithUi)(),
|
|
170
|
+
(0, wysiwyg_1.createImagePluginWithUi)({
|
|
171
|
+
uploadImage: async (file) => ({
|
|
172
|
+
id: 1,
|
|
173
|
+
name: URL.createObjectURL(file),
|
|
174
|
+
extension: ".ext",
|
|
175
|
+
namespace: "wysiwyg",
|
|
176
|
+
uuid: "this-should-be-some-random-uuid",
|
|
177
|
+
}),
|
|
178
|
+
getImageUrl: (file) => file.name,
|
|
179
|
+
}),
|
|
180
|
+
(0, wysiwyg_1.createHighlightPluginWithUi)("red"),
|
|
181
|
+
]);
|
|
182
|
+
const isMounted = (0, use_is_mounted_1.useIsMounted)();
|
|
183
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
184
|
+
react_1.default.createElement(wysiwyg_1.WysiwygEditor, { id: "editor", initialValue: _initialValues, onChange: setValue, plugins: plugins }),
|
|
185
|
+
react_1.default.createElement("div", { className: "relative mt-4" },
|
|
186
|
+
react_1.default.createElement("div", { "aria-hidden": "true", className: "absolute inset-0 flex items-center" },
|
|
187
|
+
react_1.default.createElement("div", { className: "w-full border-t border-gray-300" })),
|
|
188
|
+
react_1.default.createElement("div", { className: "relative flex justify-center" },
|
|
189
|
+
react_1.default.createElement("span", { className: "bg-white px-2 text-sm text-gray-500" }, "Value"))),
|
|
190
|
+
react_1.default.createElement(show_1.Show, { when: isMounted },
|
|
191
|
+
react_1.default.createElement("pre", null,
|
|
192
|
+
react_1.default.createElement("code", null, JSON.stringify(value, null, " "))))));
|
|
193
|
+
}
|