@uxf/wysiwyg 10.0.0-beta.49 → 10.0.0-beta.52
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/package.json +3 -3
- package/translations/context.d.ts +3 -0
- package/translations/context.js +9 -0
- package/translations/translations.d.ts +23 -0
- package/translations/translations.js +23 -0
- package/ui/floating-link.js +5 -3
- package/ui/toolbar/toolbar.js +13 -11
- package/wysiwyg-editor.d.ts +2 -0
- package/wysiwyg-editor.js +9 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/wysiwyg",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.52",
|
|
4
4
|
"description": "UXF Wysiwyg editor",
|
|
5
5
|
"author": "Robin Dvorak <dvorak@uxf.cz>",
|
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/wysiwyg",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@uxf/ui": "10.0.0-beta.
|
|
13
|
+
"@uxf/ui": "10.0.0-beta.52",
|
|
14
14
|
"react": "^18.2.0",
|
|
15
15
|
"react-dom": "^18.2.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@uxf/ui": "10.0.0-beta.
|
|
18
|
+
"@uxf/ui": "10.0.0-beta.52",
|
|
19
19
|
"react": ">=18.0.0",
|
|
20
20
|
"react-dom": ">=18.0.0"
|
|
21
21
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTranslation = exports.TranslationContextProvider = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const translations_1 = require("./translations");
|
|
6
|
+
const TranslationContext = (0, react_1.createContext)(translations_1.defaultTranslationFunction);
|
|
7
|
+
exports.TranslationContextProvider = TranslationContext.Provider;
|
|
8
|
+
const useTranslation = () => (0, react_1.useContext)(TranslationContext);
|
|
9
|
+
exports.useTranslation = useTranslation;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const translations: {
|
|
2
|
+
readonly "wysiwyg:plugins.bold.tooltip": "Tučné (Ctrl+B)";
|
|
3
|
+
readonly "wysiwyg:plugins.italic.tooltip": "Kurzíva (Ctrl+I)";
|
|
4
|
+
readonly "wysiwyg:plugins.underline.tooltip": "Podtržení (Ctrl+U)";
|
|
5
|
+
readonly "wysiwyg:plugins.code.tooltip": "Kód";
|
|
6
|
+
readonly "wysiwyg:plugins.highlight.tooltip": "Zvýraznění (Ctrl+Shift+H)";
|
|
7
|
+
readonly "wysiwyg:plugins.h1.tooltip": "Nadpis H1";
|
|
8
|
+
readonly "wysiwyg:plugins.h2.tooltip": "Nadpis H2";
|
|
9
|
+
readonly "wysiwyg:plugins.h3.tooltip": "Nadpis H3";
|
|
10
|
+
readonly "wysiwyg:plugins.h4.tooltip": "Nadpis H4";
|
|
11
|
+
readonly "wysiwyg:plugins.h5.tooltip": "Nadpis H5";
|
|
12
|
+
readonly "wysiwyg:plugins.h6.tooltip": "Nadpis H6";
|
|
13
|
+
readonly "wysiwyg:plugins.link.url-address.label": "URL adresa";
|
|
14
|
+
readonly "wysiwyg:plugins.link.url-address.placeholder": "Vložte URL adresu";
|
|
15
|
+
readonly "wysiwyg:plugins.link.link-text.label": "Text odkazu";
|
|
16
|
+
readonly "wysiwyg:plugins.link.link-text.placeholder": "Vložte text odkazu";
|
|
17
|
+
readonly "wysiwyg:plugins.link.open-in-new-tab": "Otevřít v nové záložce";
|
|
18
|
+
};
|
|
19
|
+
export type TranslationFunction = (key: keyof typeof translations, query?: {
|
|
20
|
+
[name: string]: any;
|
|
21
|
+
}) => string;
|
|
22
|
+
export declare const defaultTranslationFunction: TranslationFunction;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultTranslationFunction = void 0;
|
|
4
|
+
const translations = {
|
|
5
|
+
"wysiwyg:plugins.bold.tooltip": "Tučné (Ctrl+B)",
|
|
6
|
+
"wysiwyg:plugins.italic.tooltip": "Kurzíva (Ctrl+I)",
|
|
7
|
+
"wysiwyg:plugins.underline.tooltip": "Podtržení (Ctrl+U)",
|
|
8
|
+
"wysiwyg:plugins.code.tooltip": "Kód",
|
|
9
|
+
"wysiwyg:plugins.highlight.tooltip": "Zvýraznění (Ctrl+Shift+H)",
|
|
10
|
+
"wysiwyg:plugins.h1.tooltip": "Nadpis H1",
|
|
11
|
+
"wysiwyg:plugins.h2.tooltip": "Nadpis H2",
|
|
12
|
+
"wysiwyg:plugins.h3.tooltip": "Nadpis H3",
|
|
13
|
+
"wysiwyg:plugins.h4.tooltip": "Nadpis H4",
|
|
14
|
+
"wysiwyg:plugins.h5.tooltip": "Nadpis H5",
|
|
15
|
+
"wysiwyg:plugins.h6.tooltip": "Nadpis H6",
|
|
16
|
+
"wysiwyg:plugins.link.url-address.label": "URL adresa",
|
|
17
|
+
"wysiwyg:plugins.link.url-address.placeholder": "Vložte URL adresu",
|
|
18
|
+
"wysiwyg:plugins.link.link-text.label": "Text odkazu",
|
|
19
|
+
"wysiwyg:plugins.link.link-text.placeholder": "Vložte text odkazu",
|
|
20
|
+
"wysiwyg:plugins.link.open-in-new-tab": "Otevřít v nové záložce",
|
|
21
|
+
};
|
|
22
|
+
const defaultTranslationFunction = (key) => translations[key];
|
|
23
|
+
exports.defaultTranslationFunction = defaultTranslationFunction;
|
package/ui/floating-link.js
CHANGED
|
@@ -36,6 +36,7 @@ const floating_link_wrapper_1 = require("../plugins/link/floating-link-wrapper")
|
|
|
36
36
|
const hooks_2 = require("../plugins/link/hooks");
|
|
37
37
|
const get_active_link_1 = require("../plugins/link/transforms/get-active-link");
|
|
38
38
|
const unwrap_link_1 = require("../plugins/link/transforms/unwrap-link");
|
|
39
|
+
const context_1 = require("../translations/context");
|
|
39
40
|
const Edit = () => {
|
|
40
41
|
var _a;
|
|
41
42
|
const editor = (0, hooks_1.useUxfEditorRef)();
|
|
@@ -54,6 +55,7 @@ const Edit = () => {
|
|
|
54
55
|
react_1.default.createElement(icon_1.Icon, { name: "delete", size: 15 }))));
|
|
55
56
|
};
|
|
56
57
|
const Insert = () => {
|
|
58
|
+
const t = (0, context_1.useTranslation)();
|
|
57
59
|
const linkActions = (0, hooks_2.useLinkActions)();
|
|
58
60
|
const onChangeTarget = (0, react_1.useCallback)((checked) => {
|
|
59
61
|
linkActions.setTarget(checked ? "_blank" : "_self");
|
|
@@ -69,9 +71,9 @@ const Insert = () => {
|
|
|
69
71
|
};
|
|
70
72
|
}, []);
|
|
71
73
|
return (react_1.default.createElement("div", { className: "w-80 bg-white p-4 shadow sm:rounded-lg" },
|
|
72
|
-
react_1.default.createElement(text_input_1.TextInput, { className: "first-input", leftAddon: react_1.default.createElement("span", { className: "mx-2 w-24" }, "
|
|
73
|
-
react_1.default.createElement(text_input_1.TextInput, { className: "mt-4", leftAddon: react_1.default.createElement("span", { className: "mx-2 w-24" }, "
|
|
74
|
-
react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "mt-4", label: "
|
|
74
|
+
react_1.default.createElement(text_input_1.TextInput, { className: "first-input", leftAddon: react_1.default.createElement("span", { className: "mx-2 w-24" }, t("wysiwyg:plugins.link.url-address.label")), placeholder: t("wysiwyg:plugins.link.url-address.placeholder"), onChange: linkActions.setUrl, value: linkActions.getUrl }),
|
|
75
|
+
react_1.default.createElement(text_input_1.TextInput, { className: "mt-4", leftAddon: react_1.default.createElement("span", { className: "mx-2 w-24" }, t("wysiwyg:plugins.link.link-text.label")), placeholder: t("wysiwyg:plugins.link.link-text.placeholder"), onChange: linkActions.setText, value: linkActions.getText }),
|
|
76
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "mt-4", label: t("wysiwyg:plugins.link.open-in-new-tab"), onChange: onChangeTarget, value: linkActions.getTarget === "_blank" })));
|
|
75
77
|
};
|
|
76
78
|
const FloatingLink = () => {
|
|
77
79
|
const isEditing = (0, plate_link_1.useFloatingLinkSelectors)().isEditing();
|
package/ui/toolbar/toolbar.js
CHANGED
|
@@ -28,16 +28,18 @@ const constants_3 = require("../../plugins/link/constants");
|
|
|
28
28
|
const button_1 = require("../../plugins/button");
|
|
29
29
|
const types_7 = require("../../plugins/image/types");
|
|
30
30
|
const create_video_plugin_1 = require("../../plugins/embedded/video/create-video-plugin");
|
|
31
|
+
const context_1 = require("../../translations/context");
|
|
31
32
|
const Toolbar = (props) => {
|
|
32
33
|
const editor = (0, hooks_1.useUxfPlateEditorState)();
|
|
34
|
+
const t = (0, context_1.useTranslation)();
|
|
33
35
|
return (react_1.default.createElement("div", { ...props, className: "mb-4 flex flex-wrap gap-2" },
|
|
34
36
|
(0, utils_1.isSomeOfPluginsEnabled)(editor, constants_1.KEYS_HEADING) && (react_1.default.createElement(button_group_1.ButtonGroup, null,
|
|
35
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H1, icon: "h1", tooltipText: "
|
|
36
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H2, icon: "h2", tooltipText: "
|
|
37
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H3, icon: "h3", tooltipText: "
|
|
38
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H4, icon: "h4", tooltipText: "
|
|
39
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H5, icon: "h5", tooltipText: "
|
|
40
|
-
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H6, icon: "h6", tooltipText: "
|
|
37
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H1, icon: "h1", tooltipText: t("wysiwyg:plugins.h1.tooltip") }),
|
|
38
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H2, icon: "h2", tooltipText: t("wysiwyg:plugins.h2.tooltip") }),
|
|
39
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H3, icon: "h3", tooltipText: t("wysiwyg:plugins.h3.tooltip") }),
|
|
40
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H4, icon: "h4", tooltipText: t("wysiwyg:plugins.h4.tooltip") }),
|
|
41
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H5, icon: "h5", tooltipText: t("wysiwyg:plugins.h5.tooltip") }),
|
|
42
|
+
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: constants_1.ELEMENT_H6, icon: "h6", tooltipText: t("wysiwyg:plugins.h6.tooltip") }))),
|
|
41
43
|
(0, utils_1.isSomeOfPluginsEnabled)(editor, [
|
|
42
44
|
types_2.BOLD_PLUGIN_KEY,
|
|
43
45
|
types_4.ITALIC_PLUGIN_KEY,
|
|
@@ -45,11 +47,11 @@ const Toolbar = (props) => {
|
|
|
45
47
|
types_3.CODE_PLUGIN_KEY,
|
|
46
48
|
types_6.HIGHLIGHT_PLUGIN_KEY,
|
|
47
49
|
]) && (react_1.default.createElement(button_group_1.ButtonGroup, null,
|
|
48
|
-
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_2.BOLD_PLUGIN_KEY, iconName: "bold", iconSize: 12, tooltipText: "
|
|
49
|
-
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_4.ITALIC_PLUGIN_KEY, iconName: "italic", iconSize: 12, tooltipText: "
|
|
50
|
-
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_5.UNDER_LINE_PLUGIN_KEY, iconName: "underline", iconSize: 14, tooltipText: "
|
|
51
|
-
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_3.CODE_PLUGIN_KEY, iconName: "code-simple", tooltipText: "
|
|
52
|
-
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_6.HIGHLIGHT_PLUGIN_KEY, iconName: "highlighter-line", iconSize: 19, tooltipText: "
|
|
50
|
+
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_2.BOLD_PLUGIN_KEY, iconName: "bold", iconSize: 12, tooltipText: t("wysiwyg:plugins.bold.tooltip") }),
|
|
51
|
+
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_4.ITALIC_PLUGIN_KEY, iconName: "italic", iconSize: 12, tooltipText: t("wysiwyg:plugins.italic.tooltip") }),
|
|
52
|
+
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_5.UNDER_LINE_PLUGIN_KEY, iconName: "underline", iconSize: 14, tooltipText: t("wysiwyg:plugins.underline.tooltip") }),
|
|
53
|
+
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_3.CODE_PLUGIN_KEY, iconName: "code-simple", tooltipText: t("wysiwyg:plugins.code.tooltip") }),
|
|
54
|
+
react_1.default.createElement(mark_toolbar_button_1.MarkToolbarButton, { pluginKey: types_6.HIGHLIGHT_PLUGIN_KEY, iconName: "highlighter-line", iconSize: 19, tooltipText: t("wysiwyg:plugins.highlight.tooltip") }))),
|
|
53
55
|
react_1.default.createElement(element_toolbar_button_1.ElementToolbarButton, { pluginKey: types_1.BLOCK_QUOTE_PLUGIN_KEY, icon: "block-quote", tooltipText: "Citace" }),
|
|
54
56
|
(0, utils_1.isSomeOfPluginsEnabled)(editor, [constants_2.LIST_UNORDERED_TYPE, constants_2.LIST_ORDERED_TYPE]) && (react_1.default.createElement(button_group_1.ButtonGroup, null,
|
|
55
57
|
react_1.default.createElement(list_toolbar_button_1.ListToolbarButton, { pluginKey: constants_2.LIST_UNORDERED_TYPE, iconName: "ul" }),
|
package/wysiwyg-editor.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TEditableProps } from "@udecode/plate-core";
|
|
2
2
|
import { FC } from "react";
|
|
3
3
|
import { UxfPlatePlugin, WysiwygContent } from "./types";
|
|
4
|
+
import { TranslationFunction } from "./translations/translations";
|
|
4
5
|
export interface WysiwygEditorProps {
|
|
5
6
|
initialValue: WysiwygContent | undefined;
|
|
6
7
|
onChange: (value: WysiwygContent) => void;
|
|
7
8
|
plugins: UxfPlatePlugin[];
|
|
8
9
|
editableProps?: TEditableProps<WysiwygContent>;
|
|
10
|
+
t?: TranslationFunction;
|
|
9
11
|
}
|
|
10
12
|
export declare const WysiwygEditor: FC<WysiwygEditorProps>;
|
package/wysiwyg-editor.js
CHANGED
|
@@ -7,17 +7,20 @@ exports.WysiwygEditor = void 0;
|
|
|
7
7
|
const plate_core_1 = require("@udecode/plate-core");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const toolbar_1 = require("./ui/toolbar/toolbar");
|
|
10
|
+
const context_1 = require("./translations/context");
|
|
11
|
+
const translations_1 = require("./translations/translations");
|
|
10
12
|
const defaultEditableProps = {
|
|
11
13
|
placeholder: "Napište něco hezkého...",
|
|
12
14
|
spellCheck: false,
|
|
13
15
|
autoFocus: true,
|
|
14
16
|
readOnly: false,
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (react_1.default.createElement(
|
|
19
|
-
react_1.default.createElement(
|
|
20
|
-
|
|
21
|
-
react_1.default.createElement(
|
|
18
|
+
const WysiwygEditor = (props) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (react_1.default.createElement(context_1.TranslationContextProvider, { value: (_a = props.t) !== null && _a !== void 0 ? _a : translations_1.defaultTranslationFunction },
|
|
21
|
+
react_1.default.createElement(plate_core_1.PlateProvider, { initialValue: props.initialValue, plugins: props.plugins, onChange: props.onChange },
|
|
22
|
+
react_1.default.createElement(toolbar_1.Toolbar, null),
|
|
23
|
+
react_1.default.createElement("div", { className: "wysiwyg" },
|
|
24
|
+
react_1.default.createElement(plate_core_1.Plate, { editableProps: { ...defaultEditableProps, ...props.editableProps }, normalizeInitialValue: true })))));
|
|
22
25
|
};
|
|
23
26
|
exports.WysiwygEditor = WysiwygEditor;
|