@pie-lib/editable-html-tip-tap 3.1.2-next.20261019183544 → 3.1.2-next.20261019223635

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.
@@ -3,12 +3,11 @@ import PropTypes from 'prop-types';
3
3
  export declare class AltDialog extends React.Component {
4
4
  static propTypes: {
5
5
  onDone: PropTypes.Validator<(...args: any[]) => any>;
6
+ onClose: PropTypes.Validator<(...args: any[]) => any>;
6
7
  alt: PropTypes.Requireable<string>;
7
8
  };
8
9
  constructor(props: any);
9
- closeDialog: any;
10
10
  onDone: any;
11
- handleOverflow: any;
12
11
  render(): React.JSX.Element;
13
12
  }
14
13
  export default AltDialog;
@@ -11,6 +11,7 @@ import l from "@mui/material/Dialog";
11
11
  var u = class extends e.Component {
12
12
  static propTypes = {
13
13
  onDone: t.func.isRequired,
14
+ onClose: t.func.isRequired,
14
15
  alt: t.string
15
16
  };
16
17
  constructor(e) {
@@ -18,28 +19,18 @@ var u = class extends e.Component {
18
19
  let { alt: t } = e;
19
20
  this.state = { value: t };
20
21
  }
21
- closeDialog = () => {
22
- document.querySelectorAll("#text-dialog").forEach(function(e) {
23
- return e.remove();
24
- });
25
- };
26
22
  onDone = () => {
27
- let { onDone: e } = this.props, { value: t } = this.state;
28
- e(t), this.closeDialog();
29
- };
30
- handleOverflow = () => {
31
- document.body.style.removeProperty("overflow");
23
+ let { onDone: e, onClose: t } = this.props, { value: n } = this.state;
24
+ e(n), t();
32
25
  };
33
26
  render() {
34
27
  let { value: e } = this.state;
35
28
  return /* @__PURE__ */ r(l, {
36
29
  open: !0,
37
- disablePortal: !0,
38
- onClose: this.closeDialog,
30
+ onClose: this.props.onClose,
39
31
  id: "text-dialog",
40
32
  hideBackdrop: !0,
41
33
  disableScrollLock: !0,
42
- onEntered: this.handleOverflow,
43
34
  children: [/* @__PURE__ */ n(i, { children: /* @__PURE__ */ r("div", {
44
35
  style: { display: "flex" },
45
36
  children: [/* @__PURE__ */ n(a, { style: { paddingTop: "6px" } }), /* @__PURE__ */ n(o, {
@@ -2,12 +2,12 @@ import { AltDialog as e } from "./AltDialog.js";
2
2
  import { MarkButton as t } from "../common/toolbar-buttons.js";
3
3
  import n from "react";
4
4
  import { styled as r } from "@mui/material/styles";
5
- import i from "react-dom";
6
- import a from "prop-types";
7
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
8
- import l from "debug";
5
+ import i from "prop-types";
6
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ import c from "debug";
8
+ import { createRoot as l } from "react-dom/client";
9
9
  //#region src/components/image/ImageToolbar.tsx
10
- var u = l("@pie-lib:editable-html:plugins:image:image-toolbar"), d = r("div")(({ theme: e }) => ({
10
+ var u = c("@pie-lib:editable-html:plugins:image:image-toolbar"), d = r("div")(({ theme: e }) => ({
11
11
  paddingLeft: e.spacing.unit,
12
12
  display: "flex",
13
13
  alignItems: "center"
@@ -18,24 +18,24 @@ var u = l("@pie-lib:editable-html:plugins:image:image-toolbar"), d = r("div")(({
18
18
  paddingLeft: 8,
19
19
  marginLeft: 4
20
20
  }
21
- })), p = ({ alignment: e, active: n, onClick: r }) => /* @__PURE__ */ s(t, {
21
+ })), p = ({ alignment: e, active: n, onClick: r }) => /* @__PURE__ */ o(t, {
22
22
  active: n,
23
23
  onToggle: () => r(e),
24
24
  label: e,
25
25
  children: e
26
26
  });
27
27
  p.propTypes = {
28
- alignment: a.string.isRequired,
29
- active: a.bool.isRequired,
30
- onClick: a.func.isRequired
28
+ alignment: i.string.isRequired,
29
+ active: i.bool.isRequired,
30
+ onClick: i.func.isRequired
31
31
  };
32
32
  var m = class extends n.Component {
33
33
  static propTypes = {
34
- onChange: a.func.isRequired,
35
- alignment: a.string,
36
- alt: a.string,
37
- imageLoaded: a.bool,
38
- disableImageAlignmentButtons: a.bool
34
+ onChange: i.func.isRequired,
35
+ alignment: i.string,
36
+ alt: i.string,
37
+ imageLoaded: i.bool,
38
+ disableImageAlignmentButtons: i.bool
39
39
  };
40
40
  onAltTextDone = (e) => {
41
41
  u("[onAltTextDone]: alt:", e), this.props.onChange({ alt: e }, !0);
@@ -44,31 +44,34 @@ var m = class extends n.Component {
44
44
  u("[onAlignmentClick]: alignment:", e), this.props.onChange({ alignment: e });
45
45
  };
46
46
  renderDialog = () => {
47
- let { alt: t } = this.props, n = document.createElement("div"), r = /* @__PURE__ */ s(e, {
47
+ let { alt: t } = this.props, n = document.createElement("div"), r = l(n);
48
+ r.render(/* @__PURE__ */ o(e, {
48
49
  alt: t,
49
- onDone: this.onAltTextDone
50
- });
51
- i.render(r, n), document.body.appendChild(n);
50
+ onDone: this.onAltTextDone,
51
+ onClose: () => {
52
+ r.unmount(), n.remove();
53
+ }
54
+ })), document.body.appendChild(n);
52
55
  };
53
56
  render() {
54
57
  let { alignment: e, imageLoaded: t, disableImageAlignmentButtons: n } = this.props;
55
- return /* @__PURE__ */ c(d, { children: [!n && /* @__PURE__ */ c(o, { children: [
56
- /* @__PURE__ */ s(p, {
58
+ return /* @__PURE__ */ s(d, { children: [!n && /* @__PURE__ */ s(a, { children: [
59
+ /* @__PURE__ */ o(p, {
57
60
  alignment: "left",
58
61
  active: e === "left",
59
62
  onClick: this.onAlignmentClick
60
63
  }),
61
- /* @__PURE__ */ s(p, {
64
+ /* @__PURE__ */ o(p, {
62
65
  alignment: "center",
63
66
  active: e === "center",
64
67
  onClick: this.onAlignmentClick
65
68
  }),
66
- /* @__PURE__ */ s(p, {
69
+ /* @__PURE__ */ o(p, {
67
70
  alignment: "right",
68
71
  active: e === "right",
69
72
  onClick: this.onAlignmentClick
70
73
  })
71
- ] }), /* @__PURE__ */ s(f, {
74
+ ] }), /* @__PURE__ */ o(f, {
72
75
  disabled: !t,
73
76
  hasAlignmentButtons: !n,
74
77
  onMouseDown: (e) => t && this.renderDialog(e),
@@ -1,32 +1,33 @@
1
1
  import "react";
2
2
  import { Mark as e, mergeAttributes as t } from "@tiptap/core";
3
- import n from "react-dom";
3
+ import { flushSync as n } from "react-dom";
4
4
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
- import a from "@mui/material/List";
6
- import o from "@mui/material/ListItem";
5
+ import { createRoot as a } from "react-dom/client";
6
+ import o from "@mui/material/List";
7
+ import s from "@mui/material/ListItem";
7
8
  //#region src/extensions/css.tsx
8
- var s = () => {
9
+ var c = () => {
9
10
  document.querySelectorAll(".insert-css-dialog").forEach((e) => e.remove());
10
- }, c = ({ editor: e, callback: t, opts: c, selectedText: l, parentNode: u }) => {
11
- let d = e.options.element, f = document.createElement("div"), { selection: p } = e.state;
12
- s(), f.className = "insert-css-dialog";
13
- let m, h = !1, g = (e) => {
14
- if (h) {
15
- let t = f.contains(e.target) || m, n = d.contains(e.target);
16
- t || n || _();
17
- } else h = !0;
18
- }, _ = () => {
19
- t(void 0, !0), f.remove(), document.body.removeEventListener("click", g);
20
- }, v = (e) => {
21
- t(e, !0), f.remove(), document.body.removeEventListener("click", g);
22
- }, y = u?.attrs.class, b = (e) => {
23
- let t = `<span class="${e}">${l}</span>`;
24
- if (u) {
11
+ }, l = ({ editor: e, callback: t, opts: l, selectedText: u, parentNode: d }) => {
12
+ let f = e.options.element, p = document.createElement("div"), { selection: m } = e.state;
13
+ c(), p.className = "insert-css-dialog";
14
+ let h = a(p), g, _ = !1, v = (e) => {
15
+ if (_) {
16
+ let t = p.contains(e.target) || g, n = f.contains(e.target);
17
+ t || n || y();
18
+ } else _ = !0;
19
+ }, y = () => {
20
+ t(void 0, !0), h.unmount(), p.remove(), document.body.removeEventListener("click", v);
21
+ }, b = (e) => {
22
+ t(e, !0), h.unmount(), p.remove(), document.body.removeEventListener("click", v);
23
+ }, x = d?.attrs.class, S = (e) => {
24
+ let t = `<span class="${e}">${u}</span>`;
25
+ if (d) {
25
26
  let e = "span";
26
- u?.object === "inline" && (e = "span"), u?.object === "block" && (e = "div"), t = `<${e} class="${y}">${u.text.slice(0, p.$anchor.textOffset)}${t}${u.text.slice(p.$head.textOffset)}</${e}>`;
27
+ d?.object === "inline" && (e = "span"), d?.object === "block" && (e = "div"), t = `<${e} class="${x}">${d.text.slice(0, m.$anchor.textOffset)}${t}${d.text.slice(m.$head.textOffset)}</${e}>`;
27
28
  }
28
29
  return t;
29
- }, x = /* @__PURE__ */ i("div", {
30
+ }, C = /* @__PURE__ */ i("div", {
30
31
  style: {
31
32
  background: "white",
32
33
  height: 500,
@@ -37,35 +38,35 @@ var s = () => {
37
38
  },
38
39
  children: [
39
40
  /* @__PURE__ */ r("h2", { children: "Please choose a css class" }),
40
- y && /* @__PURE__ */ i("div", { children: ["The current parent has this class ", y] }),
41
- /* @__PURE__ */ r(a, {
41
+ x && /* @__PURE__ */ i("div", { children: ["The current parent has this class ", x] }),
42
+ /* @__PURE__ */ r(o, {
42
43
  component: "nav",
43
44
  style: { overflow: "scroll" },
44
- children: c.names.map((e, t) => /* @__PURE__ */ i(o, {
45
+ children: l.names.map((e, t) => /* @__PURE__ */ i(s, {
45
46
  button: !0,
46
- onClick: () => v(e),
47
+ onClick: () => b(e),
47
48
  children: [/* @__PURE__ */ r("div", {
48
49
  style: { marginRight: 20 },
49
50
  children: e
50
- }), /* @__PURE__ */ r("div", { dangerouslySetInnerHTML: { __html: b(e) } })]
51
+ }), /* @__PURE__ */ r("div", { dangerouslySetInnerHTML: { __html: S(e) } })]
51
52
  }, `rule-${t}`))
52
53
  })
53
54
  ]
54
55
  });
55
- n.render(x, f, () => {
56
+ n(() => h.render(C)), (() => {
56
57
  let t = e.view.nodeDOM(e.state.selection.from)?.parentNode;
57
58
  if (t) {
58
- let e = d.parentElement.parentElement.parentElement.getBoundingClientRect(), n = t.getBoundingClientRect();
59
- d.parentElement.parentElement.parentElement.appendChild(f), f.style.maxWidth = "500px", f.style.position = "absolute", f.style.top = 0, f.style.zIndex = 99999;
59
+ let e = f.parentElement.parentElement.parentElement.getBoundingClientRect(), n = t.getBoundingClientRect();
60
+ f.parentElement.parentElement.parentElement.appendChild(p), p.style.maxWidth = "500px", p.style.position = "absolute", p.style.top = 0, p.style.zIndex = 99999;
60
61
  let r = `${n.left + Math.abs(e.left) + t.offsetWidth + 10}px`, i = `${n.x}px`;
61
- f.style.left = r;
62
- let a = f.offsetWidth;
63
- f.style.left = "unset", f.style.right = i;
64
- let o = f.offsetWidth;
65
- f.style.left = "unset", f.style.right = "unset", a >= o ? f.style.left = r : f.style.right = i, document.body.addEventListener("click", g);
62
+ p.style.left = r;
63
+ let a = p.offsetWidth;
64
+ p.style.left = "unset", p.style.right = i;
65
+ let o = p.offsetWidth;
66
+ p.style.left = "unset", p.style.right = "unset", a >= o ? p.style.left = r : p.style.right = i, document.body.addEventListener("click", v);
66
67
  }
67
- });
68
- }, l = e.create({
68
+ })();
69
+ }, u = e.create({
69
70
  name: "cssmark",
70
71
  addOptions() {
71
72
  return { classes: [] };
@@ -103,7 +104,7 @@ var s = () => {
103
104
  setCSSClass: (e) => ({ commands: t }) => t.setMark(this.name, { class: e }),
104
105
  unsetCSSClass: () => ({ commands: e }) => e.unsetMark(this.name),
105
106
  openCSSClassDialog: () => ({ editor: e }) => {
106
- c({
107
+ l({
107
108
  editor: e,
108
109
  selectedText: e.state.doc.textBetween(e.state.selection.from, e.state.selection.to),
109
110
  parentNode: e.state.selection.$from.nodeAfter,
@@ -117,4 +118,4 @@ var s = () => {
117
118
  }
118
119
  });
119
120
  //#endregion
120
- export { l as CSSMark, s as removeDialogs };
121
+ export { u as CSSMark, c as removeDialogs };
@@ -3,8 +3,8 @@ import t from "../components/media/MediaToolbar.js";
3
3
  import { useEffect as n } from "react";
4
4
  import { NodeViewWrapper as r, ReactNodeViewRenderer as i } from "@tiptap/react";
5
5
  import { Node as a, mergeAttributes as o } from "@tiptap/core";
6
- import s from "react-dom";
7
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ import { createRoot as l } from "react-dom/client";
8
8
  //#region src/extensions/media.tsx
9
9
  var u = a.create({
10
10
  name: "media",
@@ -78,63 +78,65 @@ var u = a.create({
78
78
  };
79
79
  },
80
80
  addNodeView() {
81
- return i((e) => /* @__PURE__ */ c(p, {
81
+ return i((e) => /* @__PURE__ */ s(p, {
82
82
  ...e,
83
83
  options: this.options
84
84
  }));
85
85
  }
86
- }), d = () => {
87
- document.querySelectorAll(".insert-media-dialog").forEach((e) => e.remove());
88
- }, f = (t) => {
89
- let n = document.createElement("div"), { type: r, callback: i, options: a, ...o } = t, l = document.body.style.overflow;
90
- d(), n.className = "insert-media-dialog", document.body.style.overflow = "hidden";
91
- let u = (e, t) => {
92
- i(e, t), n.remove(), document.body.style.overflow = l;
93
- }, f = /* @__PURE__ */ c(e, {
86
+ }), d = null, f = (t) => {
87
+ d?.();
88
+ let n = document.createElement("div"), { type: r, callback: i, options: a, ...o } = t, c = document.body.style.overflow;
89
+ n.className = "insert-media-dialog", document.body.style.overflow = "hidden";
90
+ let u = l(n), f = () => {
91
+ u.unmount(), n.remove(), document.body.style.overflow = c, d === f && (d = null);
92
+ };
93
+ d = f;
94
+ let p = (e, t) => {
95
+ i(e, t), f();
96
+ }, m = /* @__PURE__ */ s(e, {
94
97
  ...o,
95
98
  uploadSoundSupport: a.uploadSoundSupport,
96
99
  type: r,
97
- disablePortal: !0,
98
100
  open: !0,
99
- handleClose: u
101
+ handleClose: p
100
102
  });
101
- s.render(f, n), document.body.appendChild(n);
103
+ u.render(m), document.body.appendChild(n);
102
104
  };
103
- function p({ editor: e, node: i, updateAttributes: a, deleteNode: o, options: s }) {
105
+ function p({ editor: e, node: i, updateAttributes: a, deleteNode: o, options: l }) {
104
106
  let { type: u, src: d, width: p, height: m, tag: h } = i.attrs;
105
107
  return n(() => {
106
108
  d || f({
107
109
  ...i.attrs,
108
- options: s,
110
+ options: l,
109
111
  edit: !0,
110
112
  callback: (t, n) => {
111
113
  t ? a(n) : o(), e.chain().focus().run();
112
114
  }
113
115
  });
114
- }, []), /* @__PURE__ */ l(r, {
116
+ }, []), /* @__PURE__ */ c(r, {
115
117
  "data-type": u,
116
118
  style: {
117
119
  width: p,
118
120
  height: m
119
121
  },
120
- children: [h === "audio" ? /* @__PURE__ */ c("audio", {
122
+ children: [h === "audio" ? /* @__PURE__ */ s("audio", {
121
123
  controls: !0,
122
124
  controlsList: "nodownload",
123
- children: /* @__PURE__ */ c("source", {
125
+ children: /* @__PURE__ */ s("source", {
124
126
  type: "audio/mp3",
125
127
  src: d
126
128
  })
127
- }) : /* @__PURE__ */ c("iframe", {
129
+ }) : /* @__PURE__ */ s("iframe", {
128
130
  src: d,
129
131
  allowFullScreen: !0,
130
132
  frameBorder: "0",
131
133
  width: p,
132
134
  height: m
133
- }), /* @__PURE__ */ c(t, {
135
+ }), /* @__PURE__ */ s(t, {
134
136
  onEdit: () => {
135
137
  f({
136
138
  ...i.attrs,
137
- options: s,
139
+ options: l,
138
140
  edit: !0,
139
141
  callback: (t, n) => {
140
142
  t && a(n), e.chain().focus().run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html-tip-tap",
3
- "version": "3.1.2-next.20261019183544",
3
+ "version": "3.1.2-next.20261019223635",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,10 +13,10 @@
13
13
  "@dnd-kit/utilities": "3.2.2",
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
- "@pie-lib/drag": "5.0.7-next.20261019183544",
17
- "@pie-lib/math-input": "9.0.7-next.20261019183544",
18
- "@pie-lib/math-toolbar": "4.0.7-next.20261019183544",
19
- "@pie-lib/render-ui": "8.0.7-next.20261019183544",
16
+ "@pie-lib/drag": "5.0.7-next.20261019223635",
17
+ "@pie-lib/math-input": "9.0.7-next.20261019223635",
18
+ "@pie-lib/math-toolbar": "4.0.7-next.20261019223635",
19
+ "@pie-lib/render-ui": "8.0.7-next.20261019223635",
20
20
  "@pie-lib/translator": "5.0.2-next.20261019155156",
21
21
  "@tiptap/core": "3.32.0",
22
22
  "@tiptap/extension-character-count": "3.32.0",
@@ -40,7 +40,6 @@
40
40
  "keycode": "^2.2.0",
41
41
  "prop-types": "^15.6.2",
42
42
  "react-attr-converter": "^0.3.1",
43
- "react-jss": "^8.6.1",
44
43
  "react-portal": "^4.2.0",
45
44
  "tippy.js": "latest",
46
45
  "to-style": "^1.3.3",