@uxf/wysiwyg 11.88.1 → 11.89.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.
@@ -41,20 +41,20 @@ export declare const createListPluginWithUi: () => {
41
41
  };
42
42
  };
43
43
  export declare const createLinkPluginWithUi: () => {
44
- plugin: import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-link").LinkPlugin, import("./types").WysiwygContent, import("./types").UxfEditor>;
45
- component: ElementUiComponent<import("./plugins/link/types").TLinkElement>;
44
+ plugin: import("./types").UxfPlatePlugin<import("@udecode/plate-link").LinkPlugin>;
45
+ component: ElementUiComponent;
46
46
  };
47
47
  export declare const createImagePluginWithUi: (options: UxfImagePluginOptions) => {
48
48
  plugin: import("@udecode/plate-core").PlatePlugin<UxfImagePluginOptions, import("./types").WysiwygContent, import("@udecode/plate-core").PlateEditor<import("./types").WysiwygContent>>;
49
- component: ElementUiComponent<import("./types").UxfImageElement>;
49
+ component: ElementUiComponent;
50
50
  };
51
51
  export declare const createVideoPluginWithUi: () => {
52
52
  plugin: import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-media").MediaPlugin, import("./types").WysiwygContent, import("@udecode/plate-core").PlateEditor<import("./types").WysiwygContent>>;
53
- component: ElementUiComponent<import("./types").UxfVideoElement>;
53
+ component: ElementUiComponent;
54
54
  };
55
55
  export declare const createButtonPluginWithUi: () => {
56
56
  plugin: import("@udecode/plate-core").PlatePlugin<import("@udecode/utils").AnyObject, import("./types").WysiwygContent, import("@udecode/plate-core").PlateEditor<import("./types").WysiwygContent>>;
57
- component: ElementUiComponent<import("./types").UxfButtonElement>;
57
+ component: ElementUiComponent;
58
58
  };
59
59
  export interface CreateAllPluginsOptions {
60
60
  image: UxfImagePluginOptions;
@@ -1,4 +1,4 @@
1
1
  import { MyOverrideByKey, UxfPlatePlugin, WysiwygPlugin, WysiwygRecursivePlugin } from "./types";
2
- export declare const createPluginsWithUi: (wysiwygPlugins: Array<WysiwygPlugin<any> | WysiwygRecursivePlugin<string>>, options?: {
2
+ export declare const createPluginsWithUi: (wysiwygPlugins: Array<WysiwygPlugin | WysiwygRecursivePlugin<string>>, options?: {
3
3
  overrideByKey?: MyOverrideByKey;
4
4
  }) => UxfPlatePlugin[];
@@ -41,6 +41,7 @@ const createPluginsWithUi = (wysiwygPlugins, options) => {
41
41
  ...plugins,
42
42
  ], {
43
43
  ...options,
44
+ // eslint-disable-next-line no-restricted-syntax
44
45
  components: pluginComponents /* TODO: fix this type mismatch */,
45
46
  });
46
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/wysiwyg",
3
- "version": "11.88.1",
3
+ "version": "11.89.0",
4
4
  "description": "UXF Wysiwyg editor",
5
5
  "author": "Robin Dvorak <dvorak@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/wysiwyg",
@@ -25,9 +25,9 @@
25
25
  "@udecode/plate-reset-node": "20.7.2",
26
26
  "@udecode/plate-select": "20.7.2",
27
27
  "@udecode/plate-trailing-block": "20.7.2",
28
- "@uxf/core": "11.88.0",
29
- "@uxf/core-react": "11.88.0",
30
- "@uxf/ui": "11.88.1",
28
+ "@uxf/core": "11.89.0",
29
+ "@uxf/core-react": "11.89.0",
30
+ "@uxf/ui": "11.89.0",
31
31
  "slate": "0.90.0",
32
32
  "slate-history": "0.86.0",
33
33
  "slate-hyperscript": "0.77.0",
@@ -12,7 +12,7 @@ const insertImage = (editor, file, alt, caption, source, url) => {
12
12
  alt,
13
13
  caption,
14
14
  source,
15
- url: url,
15
+ url,
16
16
  };
17
17
  (0, utils_1.insertVoid)(editor, image);
18
18
  };
@@ -1,3 +1,3 @@
1
1
  import { LinkPlugin } from "@udecode/plate-link";
2
- import { UxfEditor, WysiwygContent } from "../../types";
3
- export declare const createLinkPlugin: () => import("@udecode/plate-core").PlatePlugin<LinkPlugin, WysiwygContent, UxfEditor>;
2
+ import { UxfPlatePlugin } from "../../types";
3
+ export declare const createLinkPlugin: () => UxfPlatePlugin<LinkPlugin>;
@@ -1,2 +1,3 @@
1
+ import { AnyObject } from "@udecode/plate-common";
1
2
  import { WysiwygContent } from "../../types";
2
- export declare const addIdsToNodes: (nodes: any[]) => WysiwygContent;
3
+ export declare const addIdsToNodes: (nodes: AnyObject[]) => WysiwygContent;
package/types.d.ts CHANGED
@@ -89,7 +89,7 @@ export interface UxfButtonElement extends UxfBlockElement {
89
89
  children: [EmptyText];
90
90
  }
91
91
  export type WysiwygRootBlock = UxfParagraphElement | UxfBlockQuoteElement | UxfImageElement | UxfHeadingElement | UxfLinkElement | UxfUnorderedListElement | UxfOrderedListElement | UxfVideoElement | UxfButtonElement;
92
- export type UiComponents = Record<string, PlatePluginComponent>;
92
+ export type UiComponents = Partial<Record<string, PlatePluginComponent>>;
93
93
  export type WysiwygContent = WysiwygRootBlock[];
94
94
  export type RenderElementProps<E extends TElement = UxfBlockElement> = PlateRenderElementProps<WysiwygContent, E>;
95
95
  export type ElementUiComponent<E extends TElement = UxfBlockElement> = FC<RenderElementProps<E>>;
@@ -1,2 +1,2 @@
1
- import { ElementUiComponent, UxfButtonElement } from "../../types";
2
- export declare const ButtonElement: ElementUiComponent<UxfButtonElement>;
1
+ import { ElementUiComponent } from "../../types";
2
+ export declare const ButtonElement: ElementUiComponent;
@@ -46,7 +46,7 @@ const insert_button_modal_content_1 = require("./insert-button-modal-content");
46
46
  const CLASS_NAME = "uxf-wysiwyg__element";
47
47
  const ButtonElement = (props) => {
48
48
  var _a;
49
- const selected = (0, hooks_1.useSelected)();
49
+ const isSelected = (0, hooks_1.useSelected)();
50
50
  const onEdit = (0, react_1.useCallback)(() => {
51
51
  (0, modal_service_1.openModal)({
52
52
  children: (react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
@@ -56,9 +56,10 @@ const ButtonElement = (props) => {
56
56
  const onRemove = (0, react_1.useCallback)(() => {
57
57
  (0, remove_selected_button_1.removeSelectedButton)(props.editor);
58
58
  }, [props.editor]);
59
+ const element = props.element;
59
60
  return (react_1.default.createElement("div", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-button ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
60
- react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-button__action-buttons`, isSelected: selected, onDelete: onRemove, onEdit: onEdit, padding: selected },
61
- react_1.default.createElement(button_1.Button, { className: `${CLASS_NAME}-button__action-button`, href: props.element.buttonUrl, isDisabled: true, variant: "secondary" }, props.element.buttonText)),
61
+ react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-button__action-buttons`, isSelected: isSelected, onDelete: onRemove, onEdit: onEdit, padding: isSelected },
62
+ react_1.default.createElement(button_1.Button, { className: `${CLASS_NAME}-button__action-button`, href: element.buttonUrl, isDisabled: true, variant: "secondary" }, element.buttonText)),
62
63
  props.children));
63
64
  };
64
65
  exports.ButtonElement = ButtonElement;
@@ -14,8 +14,8 @@ export declare const createUxfUi: () => {
14
14
  li: import("..").ElementUiComponent;
15
15
  ul: import("..").ElementUiComponent;
16
16
  ol: import("..").ElementUiComponent;
17
- a: import("..").ElementUiComponent<import("../plugins/link/types").TLinkElement>;
18
- img: import("..").ElementUiComponent<import("..").UxfImageElement>;
19
- video: import("..").ElementUiComponent<import("..").UxfVideoElement>;
20
- button: import("..").ElementUiComponent<import("..").UxfButtonElement>;
17
+ a: import("..").ElementUiComponent;
18
+ img: import("..").ElementUiComponent;
19
+ video: import("..").ElementUiComponent;
20
+ button: import("..").ElementUiComponent;
21
21
  };
@@ -1,2 +1,2 @@
1
- import { ElementUiComponent, UxfImageElement } from "../../types";
2
- export declare const ImageElement: ElementUiComponent<UxfImageElement>;
1
+ import { ElementUiComponent } from "../../types";
2
+ export declare const ImageElement: ElementUiComponent;
@@ -45,7 +45,7 @@ const insert_image_modal_content_1 = require("./insert-image-modal-content");
45
45
  const CLASS_NAME = "uxf-wysiwyg__element";
46
46
  const ImageElement = (props) => {
47
47
  var _a;
48
- const selected = (0, hooks_1.useSelected)();
48
+ const isSelected = (0, hooks_1.useSelected)();
49
49
  const onEdit = (0, react_1.useCallback)(() => {
50
50
  (0, modal_service_1.openModal)({
51
51
  children: (react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
@@ -55,9 +55,10 @@ const ImageElement = (props) => {
55
55
  const onDelete = (0, react_1.useCallback)(() => {
56
56
  (0, remove_selected_image_1.removeSelectedImage)(props.editor);
57
57
  }, [props.editor]);
58
+ const element = props.element;
58
59
  return (react_1.default.createElement("div", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-image ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
59
- react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-image__action-buttons`, isSelected: selected, onDelete: onDelete, onEdit: onEdit },
60
- react_1.default.createElement("img", { alt: props.element.alt, className: `${CLASS_NAME}-image__img`, src: props.element.url })),
60
+ react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-image__action-buttons`, isSelected: isSelected, onDelete: onDelete, onEdit: onEdit },
61
+ react_1.default.createElement("img", { alt: element.alt, className: `${CLASS_NAME}-image__img`, src: element.url })),
61
62
  props.children));
62
63
  };
63
64
  exports.ImageElement = ImageElement;
@@ -1,3 +1,2 @@
1
- import { TLinkElement } from "../plugins/link/types";
2
1
  import { ElementUiComponent } from "../types";
3
- export declare const LinkElement: ElementUiComponent<TLinkElement>;
2
+ export declare const LinkElement: ElementUiComponent;
@@ -5,18 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ListToolbarButton = void 0;
7
7
  const plate_list_1 = require("@udecode/plate-list");
8
+ const is_nil_1 = require("@uxf/core/utils/is-nil");
8
9
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
9
10
  const react_1 = __importDefault(require("react"));
10
11
  const hooks_1 = require("../../../hooks");
11
12
  const utils_1 = require("../../../utils");
12
13
  const toolbar_button_1 = require("./toolbar-button");
13
14
  const CLASS_NAME = "uxf-wysiwyg__toolbar-button";
15
+ function getIsListElementActive(editor, type) {
16
+ const res = (0, is_not_nil_1.isNotNil)(editor.selection) ? (0, plate_list_1.getListItemEntry)(editor) : undefined;
17
+ if ((0, is_nil_1.isNil)(res)) {
18
+ return false;
19
+ }
20
+ const [listElement] = res.list;
21
+ return listElement.type === type;
22
+ }
14
23
  const ListToolbarButton = (props) => {
15
24
  var _a;
16
25
  const editor = (0, hooks_1.useUxfPlateEditorState)(props.plateId);
17
26
  const type = (0, utils_1.getPluginType)(editor, props.pluginKey);
18
- const res = (0, is_not_nil_1.isNotNil)(editor.selection) ? (0, plate_list_1.getListItemEntry)(editor) : undefined;
19
- const isActive = (res === null || res === void 0 ? void 0 : res.list[0].type) === type;
27
+ const isActive = getIsListElementActive(editor, type);
20
28
  const onMouseDown = () => {
21
29
  (0, plate_list_1.toggleList)(editor, {
22
30
  type,
@@ -1,2 +1,2 @@
1
- import { ElementUiComponent, UxfVideoElement } from "../../types";
2
- export declare const VideoElement: ElementUiComponent<UxfVideoElement>;
1
+ import { ElementUiComponent } from "../../types";
2
+ export declare const VideoElement: ElementUiComponent;
@@ -47,7 +47,7 @@ const CLASS_NAME = "uxf-wysiwyg__element";
47
47
  const VideoElement = (props) => {
48
48
  var _a;
49
49
  const t = (0, translations_1.useUxfTranslation)();
50
- const selected = (0, hooks_1.useSelected)();
50
+ const isSelected = (0, hooks_1.useSelected)();
51
51
  const onEdit = (0, react_1.useCallback)(() => {
52
52
  (0, modal_service_1.openModal)({
53
53
  children: (react_1.default.createElement(dialog_panel_1.DialogPanel, { width: "lg" },
@@ -57,9 +57,10 @@ const VideoElement = (props) => {
57
57
  const onDelete = (0, react_1.useCallback)(() => {
58
58
  (0, utils_1.removeSelectedNode)(props.editor);
59
59
  }, [props.editor]);
60
+ const element = props.element;
60
61
  return (react_1.default.createElement("div", { ...props.attributes, className: `${CLASS_NAME} ${CLASS_NAME}-video ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
61
- react_1.default.createElement(element_with_action_buttons_1.ElementWithActionButtons, { className: `${CLASS_NAME}-video__action-buttons`, isSelected: selected, onDelete: onDelete, onEdit: onEdit },
62
- react_1.default.createElement("iframe", { className: `${CLASS_NAME}-video__iframe`, src: props.element.embeddedUrl, tabIndex: -1, title: t("uxf-wysiwyg:plugins.video.iframe-title") })),
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") })),
63
64
  props.children));
64
65
  };
65
66
  exports.VideoElement = VideoElement;