@pie-lib/editable-html-tip-tap 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/components/CharacterPicker.d.ts +31 -0
  2. package/dist/components/CharacterPicker.d.ts.map +1 -0
  3. package/dist/components/CharacterPicker.js +129 -0
  4. package/dist/components/EditableHtml.d.ts +11 -0
  5. package/dist/components/EditableHtml.d.ts.map +1 -0
  6. package/dist/components/EditableHtml.js +270 -0
  7. package/dist/components/MenuBar.d.ts +11 -0
  8. package/dist/components/MenuBar.d.ts.map +1 -0
  9. package/dist/components/MenuBar.js +460 -0
  10. package/dist/components/TiptapContainer.d.ts +11 -0
  11. package/dist/components/TiptapContainer.d.ts.map +1 -0
  12. package/dist/components/TiptapContainer.js +157 -0
  13. package/dist/components/characters/characterUtils.d.ts +36 -0
  14. package/dist/components/characters/characterUtils.d.ts.map +1 -0
  15. package/dist/components/characters/characterUtils.js +465 -0
  16. package/dist/components/characters/custom-popper.d.ts +14 -0
  17. package/dist/components/characters/custom-popper.d.ts.map +1 -0
  18. package/dist/components/characters/custom-popper.js +32 -0
  19. package/dist/components/common/done-button.d.ts +30 -0
  20. package/dist/components/common/done-button.d.ts.map +1 -0
  21. package/dist/components/common/done-button.js +26 -0
  22. package/dist/components/common/toolbar-buttons.d.ts +39 -0
  23. package/dist/components/common/toolbar-buttons.d.ts.map +1 -0
  24. package/dist/components/common/toolbar-buttons.js +91 -0
  25. package/dist/components/icons/CssIcon.d.ts +11 -0
  26. package/dist/components/icons/CssIcon.d.ts.map +1 -0
  27. package/dist/components/icons/CssIcon.js +14 -0
  28. package/dist/components/icons/RespArea.d.ts +26 -0
  29. package/dist/components/icons/RespArea.d.ts.map +1 -0
  30. package/dist/components/icons/RespArea.js +42 -0
  31. package/dist/components/icons/TableIcons.d.ts +14 -0
  32. package/dist/components/icons/TableIcons.d.ts.map +1 -0
  33. package/dist/components/icons/TableIcons.js +32 -0
  34. package/dist/components/icons/TextAlign.d.ts +18 -0
  35. package/dist/components/icons/TextAlign.d.ts.map +1 -0
  36. package/dist/components/icons/TextAlign.js +134 -0
  37. package/dist/components/image/AltDialog.d.ts +23 -0
  38. package/dist/components/image/AltDialog.d.ts.map +1 -0
  39. package/dist/components/image/AltDialog.js +61 -0
  40. package/dist/components/image/ImageToolbar.d.ts +25 -0
  41. package/dist/components/image/ImageToolbar.d.ts.map +1 -0
  42. package/dist/components/image/ImageToolbar.js +80 -0
  43. package/dist/components/image/InsertImageHandler.d.ts +33 -0
  44. package/dist/components/image/InsertImageHandler.d.ts.map +1 -0
  45. package/dist/components/image/InsertImageHandler.js +55 -0
  46. package/dist/components/media/MediaDialog.d.ts +44 -0
  47. package/dist/components/media/MediaDialog.d.ts.map +1 -0
  48. package/dist/components/media/MediaDialog.js +389 -0
  49. package/dist/components/media/MediaToolbar.d.ts +20 -0
  50. package/dist/components/media/MediaToolbar.d.ts.map +1 -0
  51. package/dist/components/media/MediaToolbar.js +41 -0
  52. package/dist/components/media/MediaWrapper.d.ts +20 -0
  53. package/dist/components/media/MediaWrapper.d.ts.map +1 -0
  54. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
  55. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts.map +1 -0
  56. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
  57. package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
  58. package/dist/components/respArea/DragInTheBlank/choice.d.ts.map +1 -0
  59. package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
  60. package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
  61. package/dist/components/respArea/ExplicitConstructedResponse.d.ts.map +1 -0
  62. package/dist/components/respArea/ExplicitConstructedResponse.js +67 -0
  63. package/dist/components/respArea/InlineDropdown.d.ts +18 -0
  64. package/dist/components/respArea/InlineDropdown.d.ts.map +1 -0
  65. package/dist/components/respArea/InlineDropdown.js +91 -0
  66. package/dist/components/respArea/MathTemplated.d.ts +19 -0
  67. package/dist/components/respArea/MathTemplated.d.ts.map +1 -0
  68. package/dist/components/respArea/MathTemplated.js +97 -0
  69. package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
  70. package/dist/components/respArea/ToolbarIcon.d.ts.map +1 -0
  71. package/dist/components/respArea/ToolbarIcon.js +17 -0
  72. package/dist/constants.d.ts +14 -0
  73. package/dist/constants.d.ts.map +1 -0
  74. package/dist/constants.js +4 -0
  75. package/dist/extensions/css.d.ts +12 -0
  76. package/dist/extensions/css.d.ts.map +1 -0
  77. package/dist/extensions/css.js +115 -0
  78. package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
  79. package/dist/extensions/custom-toolbar-wrapper.d.ts.map +1 -0
  80. package/dist/extensions/custom-toolbar-wrapper.js +58 -0
  81. package/dist/extensions/div-node.d.ts +11 -0
  82. package/dist/extensions/div-node.d.ts.map +1 -0
  83. package/dist/extensions/div-node.js +25 -0
  84. package/dist/extensions/extended-table.d.ts +11 -0
  85. package/dist/extensions/extended-table.d.ts.map +1 -0
  86. package/dist/extensions/extended-table.js +15 -0
  87. package/dist/extensions/image-component.d.ts +22 -0
  88. package/dist/extensions/image-component.d.ts.map +1 -0
  89. package/dist/extensions/image-component.js +200 -0
  90. package/dist/extensions/image.d.ts +11 -0
  91. package/dist/extensions/image.d.ts.map +1 -0
  92. package/dist/extensions/image.js +42 -0
  93. package/dist/extensions/index.d.ts +17 -0
  94. package/dist/extensions/index.d.ts.map +1 -0
  95. package/dist/extensions/index.js +65 -0
  96. package/dist/extensions/math.d.ts +15 -0
  97. package/dist/extensions/math.d.ts.map +1 -0
  98. package/dist/extensions/math.js +150 -0
  99. package/dist/extensions/media.d.ts +19 -0
  100. package/dist/extensions/media.d.ts.map +1 -0
  101. package/dist/extensions/media.js +147 -0
  102. package/dist/extensions/responseArea.d.ts +28 -0
  103. package/dist/extensions/responseArea.d.ts.map +1 -0
  104. package/dist/extensions/responseArea.js +259 -0
  105. package/dist/index.d.ts +13 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +6 -0
  108. package/dist/styles/editorContainerStyles.d.ts +135 -0
  109. package/dist/styles/editorContainerStyles.d.ts.map +1 -0
  110. package/dist/theme.d.ts +10 -0
  111. package/dist/theme.d.ts.map +1 -0
  112. package/dist/utils/helper.d.ts +10 -0
  113. package/dist/utils/helper.d.ts.map +1 -0
  114. package/dist/utils/helper.js +7 -0
  115. package/dist/utils/size.d.ts +10 -0
  116. package/dist/utils/size.d.ts.map +1 -0
  117. package/dist/utils/size.js +14 -0
  118. package/package.json +71 -0
  119. package/src/components/CharacterPicker.tsx +210 -0
  120. package/src/components/EditableHtml.tsx +416 -0
  121. package/src/components/MenuBar.tsx +558 -0
  122. package/src/components/TiptapContainer.tsx +228 -0
  123. package/src/components/characters/characterUtils.ts +457 -0
  124. package/src/components/characters/custom-popper.tsx +48 -0
  125. package/src/components/common/done-button.tsx +37 -0
  126. package/src/components/common/toolbar-buttons.tsx +132 -0
  127. package/src/components/icons/CssIcon.tsx +25 -0
  128. package/src/components/icons/RespArea.tsx +81 -0
  129. package/src/components/icons/TableIcons.tsx +62 -0
  130. package/src/components/icons/TextAlign.tsx +124 -0
  131. package/src/components/image/AltDialog.tsx +92 -0
  132. package/src/components/image/ImageToolbar.tsx +109 -0
  133. package/src/components/image/InsertImageHandler.ts +121 -0
  134. package/src/components/media/MediaDialog.tsx +606 -0
  135. package/src/components/media/MediaToolbar.tsx +59 -0
  136. package/src/components/media/MediaWrapper.tsx +49 -0
  137. package/src/components/respArea/DragInTheBlank/DragInTheBlank.tsx +86 -0
  138. package/src/components/respArea/DragInTheBlank/choice.tsx +266 -0
  139. package/src/components/respArea/ExplicitConstructedResponse.tsx +122 -0
  140. package/src/components/respArea/InlineDropdown.tsx +152 -0
  141. package/src/components/respArea/MathTemplated.tsx +134 -0
  142. package/src/components/respArea/ToolbarIcon.tsx +76 -0
  143. package/src/constants.ts +15 -0
  144. package/src/extensions/css.tsx +230 -0
  145. package/src/extensions/custom-toolbar-wrapper.tsx +88 -0
  146. package/src/extensions/div-node.tsx +46 -0
  147. package/src/extensions/extended-table.ts +34 -0
  148. package/src/extensions/image-component.tsx +303 -0
  149. package/src/extensions/image.tsx +64 -0
  150. package/src/extensions/index.tsx +91 -0
  151. package/src/extensions/math.tsx +285 -0
  152. package/src/extensions/media.tsx +198 -0
  153. package/src/extensions/responseArea.tsx +404 -0
  154. package/src/index.tsx +15 -0
  155. package/src/styles/editorContainerStyles.ts +155 -0
  156. package/src/theme.ts +11 -0
  157. package/src/utils/helper.tsx +27 -0
  158. package/src/utils/size.ts +42 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/custom-toolbar-wrapper.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ declare function CustomToolbarWrapper(props: any): JSX.Element;
10
+ export default CustomToolbarWrapper;
11
+ //# sourceMappingURL=custom-toolbar-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-toolbar-wrapper.d.ts","sourceRoot":"","sources":["../../src/extensions/custom-toolbar-wrapper.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAmDH,iBAAS,oBAAoB,CAAC,KAAK,KAAA,eA0BlC;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { PIE_TOOLBAR__CLASS as e } from "../constants.js";
2
+ import { DoneButton as t } from "../components/common/done-button.js";
3
+ import "react";
4
+ import { styled as n } from "@mui/material/styles";
5
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
+ import a from "@mui/material/IconButton";
7
+ import o from "@mui/icons-material/Delete";
8
+ //#region src/extensions/custom-toolbar-wrapper.tsx
9
+ var s = n("div", { shouldForwardProp: (e) => ![
10
+ "showDone",
11
+ "toolbarAlignment",
12
+ "isFocused",
13
+ "autoWidth",
14
+ "isHidden"
15
+ ].includes(e) })(({ showDone: e, toolbarAlignment: t, isFocused: n, autoWidth: r, isHidden: i }) => ({
16
+ position: "absolute",
17
+ zIndex: 10,
18
+ cursor: "pointer",
19
+ justifyContent: "space-between",
20
+ background: "var(--editable-html-toolbar-bg, #efefef)",
21
+ minWidth: e ? "280px" : "265px",
22
+ margin: "5px 0 0 0",
23
+ padding: "2px",
24
+ boxShadow: "0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)",
25
+ boxSizing: "border-box",
26
+ display: "flex",
27
+ opacity: 1,
28
+ ...t === "right" && { right: 0 },
29
+ ...r ? { width: "auto" } : { width: "100%" },
30
+ ...i && { visibility: "hidden" }
31
+ })), c = n(a)({
32
+ width: "28px",
33
+ height: "28px",
34
+ padding: "4px",
35
+ verticalAlign: "top"
36
+ }), l = n("div")({ display: "flex" });
37
+ function u(n) {
38
+ let { children: a, deletable: u, toolbarOpts: d, autoWidth: f, isFocused: p, doneButtonRef: m, onDelete: h, showDone: g, onDone: _ } = n, v = d.minWidth === void 0 ? {} : { minWidth: d.minWidth };
39
+ return /* @__PURE__ */ i(s, {
40
+ className: e,
41
+ showDone: g,
42
+ toolbarAlignment: d.alignment,
43
+ isFocused: d.alwaysVisible || p,
44
+ autoWidth: f,
45
+ isHidden: d.isHidden === !0,
46
+ style: { ...v },
47
+ children: [a, /* @__PURE__ */ i(l, { children: [u && /* @__PURE__ */ r(c, {
48
+ "aria-label": "Delete",
49
+ onMouseDown: (e) => h?.(e),
50
+ children: /* @__PURE__ */ r(o, {})
51
+ }), g && /* @__PURE__ */ r(t, {
52
+ doneButtonRef: m,
53
+ onClick: _
54
+ })] })]
55
+ });
56
+ }
57
+ //#endregion
58
+ export { u as default };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/div-node.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import { Node } from '@tiptap/core';
10
+ export declare const DivNode: Node<any, any>;
11
+ //# sourceMappingURL=div-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"div-node.d.ts","sourceRoot":"","sources":["../../src/extensions/div-node.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,OAAO,gBAgClB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Node as e } from "@tiptap/core";
2
+ //#region src/extensions/div-node.tsx
3
+ var t = e.create({
4
+ name: "div",
5
+ group: "block",
6
+ content: "inline*",
7
+ parseHTML() {
8
+ return [{ tag: "div" }];
9
+ },
10
+ renderHTML({ HTMLAttributes: e }) {
11
+ return [
12
+ "div",
13
+ e,
14
+ 0
15
+ ];
16
+ },
17
+ addKeyboardShortcuts() {
18
+ return { Enter: () => {
19
+ let { state: e } = this.editor, { $from: t } = e.selection;
20
+ return t.parent.type.name === "div" ? this.editor.chain().focus().setNode("paragraph").splitBlock().run() : !1;
21
+ } };
22
+ }
23
+ });
24
+ //#endregion
25
+ export { t as DivNode };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/extended-table.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ declare const ExtendedTable: import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any>;
10
+ export default ExtendedTable;
11
+ //# sourceMappingURL=extended-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extended-table.d.ts","sourceRoot":"","sources":["../../src/extensions/extended-table.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAIH,QAAA,MAAM,aAAa,kFAmBjB,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Table as e } from "@tiptap/extension-table";
2
+ //#region src/extensions/extended-table.ts
3
+ var t = e.extend({
4
+ addAttributes() {
5
+ return { border: { default: "1" } };
6
+ },
7
+ renderHTML(e) {
8
+ let t = this.parent(e), { border: n } = e.HTMLAttributes, r = `${t[1].style}${t[1].style.match(/.*; */) ? "" : ";"}`;
9
+ return t[1].style = `${r}
10
+ color: var(--pie-text, black);
11
+ background-color: var(--pie-background, rgba(255, 255, 255))`, t[1].border = n || "1", t;
12
+ }
13
+ });
14
+ //#endregion
15
+ export { t as default };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/image-component.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import PropTypes from 'prop-types';
10
+ declare function ImageComponent(props: any): JSX.Element;
11
+ declare namespace ImageComponent {
12
+ var propTypes: {
13
+ node: PropTypes.Validator<object>;
14
+ editor: PropTypes.Validator<object>;
15
+ attributes: PropTypes.Requireable<object>;
16
+ onFocus: PropTypes.Requireable<(...args: any[]) => any>;
17
+ maxImageWidth: PropTypes.Requireable<number>;
18
+ maxImageHeight: PropTypes.Requireable<number>;
19
+ };
20
+ }
21
+ export default ImageComponent;
22
+ //# sourceMappingURL=image-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-component.d.ts","sourceRoot":"","sources":["../../src/extensions/image-component.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH,OAAO,SAAS,MAAM,YAAY,CAAC;AA+DnC,iBAAS,cAAc,CAAC,KAAK,KAAA,eAyN5B;kBAzNQ,cAAc;;;;;;;;;;AAoOvB,eAAe,cAAc,CAAC"}
@@ -0,0 +1,200 @@
1
+ import e from "../components/image/InsertImageHandler.js";
2
+ import t from "../components/image/ImageToolbar.js";
3
+ import n from "./custom-toolbar-wrapper.js";
4
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
5
+ import { NodeViewWrapper as s } from "@tiptap/react";
6
+ import { styled as c } from "@mui/material/styles";
7
+ import l from "prop-types";
8
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
9
+ import f from "lodash-es/isEqual.js";
10
+ import p from "debug";
11
+ import m from "@mui/material/LinearProgress";
12
+ //#region src/extensions/image-component.tsx
13
+ p("@pie-lib:editable-html:plugins:image:component");
14
+ var h = c(m, { shouldForwardProp: (e) => e !== "hideProgress" })(({ hideProgress: e }) => ({
15
+ position: "absolute",
16
+ left: "0",
17
+ width: "fit-content",
18
+ top: "0%",
19
+ transition: "opacity 200ms linear",
20
+ ...e && { opacity: 0 }
21
+ })), g = c("div", { shouldForwardProp: (e) => ![
22
+ "active",
23
+ "loading",
24
+ "pendingDelete"
25
+ ].includes(e) })(({ theme: e, active: t, loading: n, pendingDelete: r }) => ({
26
+ position: "relative",
27
+ border: t ? `solid 1px ${e.palette.primary.main}` : `solid 1px ${e.palette.common.white}`,
28
+ display: "flex",
29
+ transition: "opacity 200ms linear",
30
+ ...n && { opacity: .3 },
31
+ ...r && { opacity: .3 }
32
+ })), _ = c("div")(({ theme: e }) => ({
33
+ position: "relative",
34
+ width: "fit-content",
35
+ display: "flex",
36
+ alignItems: "center",
37
+ "&&:hover > .resize": { display: "block" }
38
+ })), v = c("div")(({ theme: e }) => ({
39
+ backgroundColor: e.palette.primary.main,
40
+ cursor: "col-resize",
41
+ height: "35px",
42
+ width: "5px",
43
+ borderRadius: 8,
44
+ marginLeft: "5px",
45
+ marginRight: "10px",
46
+ display: "none"
47
+ })), y = (e) => e ? `${e}px` : "calc(20px)";
48
+ function b(c) {
49
+ let { node: l, editor: p, attributes: m, onFocus: b, selected: x, options: S, maxImageWidth: C = 700, maxImageHeight: w = 900, latex: T, handleChange: E, handleDone: D } = c, { alt: O } = l.attrs, [k, A] = o(!1), j = a(l), M = a(null), N = a(null), P = a(null), F = r((e) => {
50
+ let t = e / M.current.naturalWidth * 4;
51
+ return parseInt(t.toFixed(0) * 25, 10);
52
+ }, []), I = r(() => {
53
+ if (!l.attrs.width || !M.current) return;
54
+ let e = {
55
+ ...l.attrs,
56
+ resizePercent: F(l.attrs.width)
57
+ };
58
+ f(e, l.attrs) || p.commands.updateAttributes("imageUploadNode", e);
59
+ }, [
60
+ p,
61
+ l.attrs,
62
+ F
63
+ ]);
64
+ i(() => {
65
+ j.current = l;
66
+ }, [l]), i(() => {
67
+ let { selection: e } = p.state, t = e.from + l.nodeSize === e.to;
68
+ x ? t && A(x) : A(x);
69
+ }, [
70
+ p,
71
+ l,
72
+ x
73
+ ]), i(() => {
74
+ S.imageHandling.insertImageRequested(l, (t) => new e(p, l, t)), I();
75
+ let t = N.current;
76
+ return t && t.addEventListener("mousedown", H, !1), () => {
77
+ t && t.removeEventListener("mousedown", H, !1), S.imageHandling.onDelete(j.current);
78
+ };
79
+ }, []), i(() => {
80
+ I();
81
+ });
82
+ let L = r(() => {
83
+ let e = M.current;
84
+ if (e && (!e.style.width || e.style.width === "calc(20px)")) {
85
+ let t = Math.min(e.naturalWidth, C), n = Math.min(e.naturalHeight, w);
86
+ e.style.width = `${t}px`, e.style.height = `${n}px`;
87
+ let r = {
88
+ width: t,
89
+ height: n
90
+ };
91
+ f(r, l.attrs) || p.commands.updateAttributes("imageUploadNode", r);
92
+ }
93
+ }, [
94
+ p,
95
+ l.attrs,
96
+ C,
97
+ w
98
+ ]), R = (e, t, n = !0, r) => {
99
+ if (n) {
100
+ let n = e.width / e.height;
101
+ return r === "height" ? {
102
+ width: t.height * n,
103
+ height: t.height
104
+ } : {
105
+ width: t.width,
106
+ height: t.width / n
107
+ };
108
+ }
109
+ return t;
110
+ }, z = r((e) => {
111
+ let t = M.current;
112
+ if (!t) return;
113
+ let n = e.target.getBoundingClientRect(), r = R({
114
+ width: t.naturalWidth,
115
+ height: t.naturalHeight
116
+ }, {
117
+ width: e.clientX - n.left,
118
+ height: e.clientY - n.top
119
+ });
120
+ if (r.width > 50 && r.height > 50 && r.width <= 700 && r.height <= 900) {
121
+ t.style.width = `${r.width}px`, t.style.height = `${r.height}px`;
122
+ let e = {
123
+ width: r.width,
124
+ height: r.height
125
+ };
126
+ f(e, l.attrs) || p.commands.updateAttributes("imageUploadNode", e);
127
+ }
128
+ }, [p, l.attrs]), B = r((e) => {
129
+ p.commands.updateAttributes("imageUploadNode", e);
130
+ }, [p]), V = r(() => {
131
+ window.removeEventListener("mousemove", z), window.removeEventListener("mouseup", V);
132
+ }, [z]), H = r(() => {
133
+ window.addEventListener("mousemove", z), window.addEventListener("mouseup", V);
134
+ }, [z, V]), U = {
135
+ width: y(l.attrs.width),
136
+ height: y(l.attrs.height),
137
+ objectFit: "contain"
138
+ }, W = {
139
+ left: "flex-start",
140
+ center: "center",
141
+ right: "flex-end"
142
+ }[l.attrs.alignment] || "flex-start";
143
+ return /* @__PURE__ */ d(s, { children: [/* @__PURE__ */ d(g, {
144
+ onFocus: b,
145
+ active: x,
146
+ loading: !l.attrs.loaded,
147
+ pendingDelete: l.attrs.deleteStatus === "pending",
148
+ style: { justifyContent: W },
149
+ children: [/* @__PURE__ */ u(h, {
150
+ mode: "determinate",
151
+ value: l.attrs.percent || 0,
152
+ hideProgress: l.attrs.loaded
153
+ }), /* @__PURE__ */ d(_, { children: [/* @__PURE__ */ u("img", {
154
+ ...m,
155
+ ref: M,
156
+ src: l.attrs.src,
157
+ style: U,
158
+ onLoad: L,
159
+ alt: l.attrs.alt
160
+ }), /* @__PURE__ */ u(v, {
161
+ ref: N,
162
+ className: "resize"
163
+ })] })]
164
+ }), k && /* @__PURE__ */ u("div", {
165
+ ref: P,
166
+ style: {
167
+ position: "absolute",
168
+ top: "100%",
169
+ left: 0,
170
+ zIndex: 20,
171
+ background: "var(--editable-html-toolbar-bg, #efefef)",
172
+ boxShadow: "0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)",
173
+ width: "100%"
174
+ },
175
+ children: /* @__PURE__ */ u(n, {
176
+ showDone: !0,
177
+ ...S,
178
+ onDone: () => {
179
+ A(!1), c.imageHandling?.onDone(), c.editor.commands.focus("end");
180
+ },
181
+ children: /* @__PURE__ */ u(t, {
182
+ disableImageAlignmentButtons: S.disableImageAlignmentButtons,
183
+ alt: l.attrs.alt,
184
+ imageLoaded: l.attrs.loaded,
185
+ alignment: l.attrs.alignment || "left",
186
+ onChange: B
187
+ })
188
+ })
189
+ })] });
190
+ }
191
+ b.propTypes = {
192
+ node: l.object.isRequired,
193
+ editor: l.object.isRequired,
194
+ attributes: l.object,
195
+ onFocus: l.func,
196
+ maxImageWidth: l.number,
197
+ maxImageHeight: l.number
198
+ };
199
+ //#endregion
200
+ export { b as default };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/image.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import { Node } from '@tiptap/core';
10
+ export declare const ImageUploadNode: Node<any, any>;
11
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/extensions/image.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,eAAO,MAAM,eAAe,gBAgD1B,CAAC"}
@@ -0,0 +1,42 @@
1
+ import e from "./image-component.js";
2
+ import "react";
3
+ import { ReactNodeViewRenderer as t } from "@tiptap/react";
4
+ import { Node as n, mergeAttributes as r } from "@tiptap/core";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ //#region src/extensions/image.tsx
7
+ var a = n.create({
8
+ name: "imageUploadNode",
9
+ group: "block",
10
+ atom: !0,
11
+ selectable: !0,
12
+ draggable: !0,
13
+ addAttributes() {
14
+ return {
15
+ loaded: { default: !1 },
16
+ deleteStatus: { default: null },
17
+ alignment: { default: null },
18
+ percent: { default: null },
19
+ width: { default: null },
20
+ height: { default: null },
21
+ src: { default: null },
22
+ alt: { default: null }
23
+ };
24
+ },
25
+ parseHTML() {
26
+ return [{ tag: "div[data-type=\"image-upload-node\"]" }];
27
+ },
28
+ renderHTML({ HTMLAttributes: e }) {
29
+ return ["img", r(e, { "data-type": "image-upload-node" })];
30
+ },
31
+ addNodeView() {
32
+ return t((t) => /* @__PURE__ */ i(e, {
33
+ ...t,
34
+ options: this.options
35
+ }));
36
+ },
37
+ addCommands() {
38
+ return { setImageUploadNode: () => ({ commands: e }) => e.insertContent({ type: this.name }) };
39
+ }
40
+ });
41
+ //#endregion
42
+ export { a as ImageUploadNode };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export declare const ALL_PLUGINS: string[];
10
+ export declare const PLUGINS_MAP: {
11
+ 'text-align': string;
12
+ 'bulleted-list': string;
13
+ 'numbered-list': string;
14
+ };
15
+ export declare const DEFAULT_PLUGINS: string[];
16
+ export declare const buildExtensions: (activeExtensions: any, customExtensions: any, opts: any) => any;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAOH,eAAO,MAAM,WAAW,UAwBvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAIvB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAqF,CAAC;AAElH,eAAO,MAAM,eAAe,GAAI,qBAAgB,EAAE,qBAAgB,EAAE,SAAI,QAyCvE,CAAC"}
@@ -0,0 +1,65 @@
1
+ import e from "debug";
2
+ import t from "lodash-es/compact.js";
3
+ import n from "lodash-es/isEmpty.js";
4
+ //#region src/extensions/index.tsx
5
+ var r = e("@pie-lib:editable-html:plugins"), i = [
6
+ "bold",
7
+ "html",
8
+ "extraCSSRules",
9
+ "italic",
10
+ "underline",
11
+ "strikethrough",
12
+ "bulleted-list",
13
+ "numbered-list",
14
+ "image",
15
+ "math",
16
+ "languageCharacters",
17
+ "text-align",
18
+ "blockquote",
19
+ "h3",
20
+ "table",
21
+ "video",
22
+ "audio",
23
+ "responseArea",
24
+ "redo",
25
+ "undo",
26
+ "superscript",
27
+ "subscript"
28
+ ], a = {
29
+ "text-align": "textAlign",
30
+ "bulleted-list": "ul_list",
31
+ "numbered-list": "ol_list"
32
+ }, o = i.filter((e) => ![
33
+ "responseArea",
34
+ "h3",
35
+ "blockquote"
36
+ ].includes(e)), s = (e, i, a) => {
37
+ r("[buildPlugins] opts: ", a), e ||= o;
38
+ let s = (t, n = !0) => e.includes(t) && n && t, c = a.image && a.image.delete, l = a.math, u = a.responseArea && a.responseArea.type, d = !n(a.extraCSSRules), f = a?.languageCharacters || [];
39
+ return t([
40
+ s("table"),
41
+ s("bold"),
42
+ s("italic"),
43
+ s("strikethrough"),
44
+ s("underline"),
45
+ s("superscript"),
46
+ s("subscript"),
47
+ s("image", !!c),
48
+ s("video"),
49
+ s("audio"),
50
+ s("math", !!l),
51
+ ...f.map((e) => s("languageCharacters", e)),
52
+ s("text-align"),
53
+ s("blockquote"),
54
+ s("h3"),
55
+ s("bulleted-list"),
56
+ s("numbered-list"),
57
+ s("undo"),
58
+ s("redo"),
59
+ s("responseArea", !!u),
60
+ s("css", !!d),
61
+ s("html", !!a.html)
62
+ ]);
63
+ };
64
+ //#endregion
65
+ export { i as ALL_PLUGINS, o as DEFAULT_PLUGINS, a as PLUGINS_MAP, s as buildExtensions };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/math.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import { Node } from '@tiptap/core';
10
+ import { Plugin } from 'prosemirror-state';
11
+ export declare const EnsureTextAfterMathPlugin: (mathNodeName: any) => Plugin<any>;
12
+ export declare const ZeroWidthSpaceHandlingPlugin: Plugin<any>;
13
+ export declare const MathNode: Node<any, any>;
14
+ export declare const MathNodeView: (props: any) => JSX.Element;
15
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/extensions/math.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAiB,MAAM,EAA4B,MAAM,mBAAmB,CAAC;AAMpF,eAAO,MAAM,yBAAyB,GAAI,iBAAY,gBAyBlD,CAAC;AAEL,eAAO,MAAM,4BAA4B,aA4CvC,CAAC;AAEH,eAAO,MAAM,QAAQ,gBAuFnB,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,UAAK,gBAsGjC,CAAC"}