@pie-lib/editable-html-tip-tap 2.1.2-next.29 → 2.1.2-next.30

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 (276) hide show
  1. package/dist/components/CharacterPicker.d.ts +31 -0
  2. package/dist/components/CharacterPicker.js +131 -0
  3. package/dist/components/EditableHtml.d.ts +11 -0
  4. package/dist/components/EditableHtml.js +291 -0
  5. package/dist/components/MenuBar.d.ts +11 -0
  6. package/dist/components/MenuBar.js +462 -0
  7. package/dist/components/TiptapContainer.d.ts +11 -0
  8. package/dist/components/TiptapContainer.js +154 -0
  9. package/dist/components/characters/characterUtils.d.ts +35 -0
  10. package/dist/components/characters/characterUtils.js +465 -0
  11. package/dist/components/characters/custom-popper.d.ts +14 -0
  12. package/dist/components/characters/custom-popper.js +32 -0
  13. package/dist/components/common/done-button.d.ts +30 -0
  14. package/dist/components/common/done-button.js +26 -0
  15. package/dist/components/common/toolbar-buttons.d.ts +38 -0
  16. package/dist/components/common/toolbar-buttons.js +91 -0
  17. package/dist/components/icons/CssIcon.d.ts +11 -0
  18. package/dist/components/icons/CssIcon.js +14 -0
  19. package/dist/components/icons/RespArea.d.ts +26 -0
  20. package/dist/components/icons/RespArea.js +42 -0
  21. package/dist/components/icons/TableIcons.d.ts +14 -0
  22. package/dist/components/icons/TableIcons.js +32 -0
  23. package/dist/components/icons/TextAlign.d.ts +18 -0
  24. package/dist/components/icons/TextAlign.js +134 -0
  25. package/dist/components/image/AltDialog.d.ts +22 -0
  26. package/dist/components/image/AltDialog.js +61 -0
  27. package/dist/components/image/ImageToolbar.d.ts +24 -0
  28. package/dist/components/image/ImageToolbar.js +80 -0
  29. package/dist/components/image/InsertImageHandler.d.ts +32 -0
  30. package/dist/components/image/InsertImageHandler.js +53 -0
  31. package/dist/components/media/MediaDialog.d.ts +43 -0
  32. package/dist/components/media/MediaDialog.js +389 -0
  33. package/dist/components/media/MediaToolbar.d.ts +19 -0
  34. package/dist/components/media/MediaToolbar.js +41 -0
  35. package/dist/components/media/MediaWrapper.d.ts +19 -0
  36. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
  37. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
  38. package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
  39. package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
  40. package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
  41. package/dist/components/respArea/ExplicitConstructedResponse.js +83 -0
  42. package/dist/components/respArea/InlineDropdown.d.ts +18 -0
  43. package/dist/components/respArea/InlineDropdown.js +119 -0
  44. package/dist/components/respArea/MathTemplated.d.ts +19 -0
  45. package/dist/components/respArea/MathTemplated.js +97 -0
  46. package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
  47. package/dist/components/respArea/ToolbarIcon.js +17 -0
  48. package/dist/components/respArea/inlineDropdownUtils.d.ts +15 -0
  49. package/dist/components/respArea/inlineDropdownUtils.js +15 -0
  50. package/dist/constants.d.ts +13 -0
  51. package/dist/constants.js +4 -0
  52. package/dist/extensions/css.d.ts +11 -0
  53. package/dist/extensions/css.js +115 -0
  54. package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
  55. package/dist/extensions/custom-toolbar-wrapper.js +61 -0
  56. package/dist/extensions/div-node.d.ts +10 -0
  57. package/dist/extensions/div-node.js +42 -0
  58. package/dist/extensions/ensure-empty-root-div.d.ts +14 -0
  59. package/dist/extensions/ensure-empty-root-div.js +24 -0
  60. package/dist/extensions/ensure-list-item-content-is-div.d.ts +15 -0
  61. package/dist/extensions/ensure-list-item-content-is-div.js +31 -0
  62. package/dist/extensions/extended-list-item.d.ts +13 -0
  63. package/dist/extensions/extended-list-item.js +5 -0
  64. package/dist/extensions/extended-table-cell.d.ts +10 -0
  65. package/dist/extensions/extended-table-cell.js +6 -0
  66. package/dist/extensions/extended-table.d.ts +17 -0
  67. package/dist/extensions/extended-table.js +34 -0
  68. package/dist/extensions/heading-paragraph.d.ts +17 -0
  69. package/dist/extensions/heading-paragraph.js +30 -0
  70. package/dist/extensions/image-component.d.ts +22 -0
  71. package/dist/extensions/image-component.js +220 -0
  72. package/dist/extensions/image.d.ts +10 -0
  73. package/dist/extensions/image.js +68 -0
  74. package/dist/extensions/index.d.ts +16 -0
  75. package/dist/extensions/index.js +64 -0
  76. package/dist/extensions/math.d.ts +15 -0
  77. package/dist/extensions/math.js +158 -0
  78. package/dist/extensions/media.d.ts +19 -0
  79. package/dist/extensions/media.js +149 -0
  80. package/dist/extensions/responseArea.d.ts +27 -0
  81. package/dist/extensions/responseArea.js +259 -0
  82. package/dist/index.d.ts +13 -0
  83. package/dist/index.js +7 -0
  84. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  85. package/dist/styles/editorContainerStyles.d.ts +134 -0
  86. package/dist/theme.d.ts +9 -0
  87. package/dist/utils/helper.d.ts +9 -0
  88. package/dist/utils/helper.js +27 -0
  89. package/dist/utils/size.d.ts +9 -0
  90. package/dist/utils/size.js +14 -0
  91. package/package.json +40 -24
  92. package/CHANGELOG.json +0 -32
  93. package/CHANGELOG.md +0 -2532
  94. package/LICENSE.md +0 -5
  95. package/lib/components/CharacterPicker.js +0 -201
  96. package/lib/components/CharacterPicker.js.map +0 -1
  97. package/lib/components/EditableHtml.js +0 -376
  98. package/lib/components/EditableHtml.js.map +0 -1
  99. package/lib/components/MenuBar.js +0 -696
  100. package/lib/components/MenuBar.js.map +0 -1
  101. package/lib/components/TiptapContainer.js +0 -234
  102. package/lib/components/TiptapContainer.js.map +0 -1
  103. package/lib/components/characters/characterUtils.js +0 -378
  104. package/lib/components/characters/characterUtils.js.map +0 -1
  105. package/lib/components/characters/custom-popper.js +0 -44
  106. package/lib/components/characters/custom-popper.js.map +0 -1
  107. package/lib/components/common/done-button.js +0 -34
  108. package/lib/components/common/done-button.js.map +0 -1
  109. package/lib/components/common/toolbar-buttons.js +0 -144
  110. package/lib/components/common/toolbar-buttons.js.map +0 -1
  111. package/lib/components/icons/CssIcon.js +0 -25
  112. package/lib/components/icons/CssIcon.js.map +0 -1
  113. package/lib/components/icons/RespArea.js +0 -72
  114. package/lib/components/icons/RespArea.js.map +0 -1
  115. package/lib/components/icons/TableIcons.js +0 -53
  116. package/lib/components/icons/TableIcons.js.map +0 -1
  117. package/lib/components/icons/TextAlign.js +0 -157
  118. package/lib/components/icons/TextAlign.js.map +0 -1
  119. package/lib/components/image/AltDialog.js +0 -98
  120. package/lib/components/image/AltDialog.js.map +0 -1
  121. package/lib/components/image/ImageToolbar.js +0 -137
  122. package/lib/components/image/ImageToolbar.js.map +0 -1
  123. package/lib/components/image/InsertImageHandler.js +0 -135
  124. package/lib/components/image/InsertImageHandler.js.map +0 -1
  125. package/lib/components/media/MediaDialog.js +0 -594
  126. package/lib/components/media/MediaDialog.js.map +0 -1
  127. package/lib/components/media/MediaToolbar.js +0 -74
  128. package/lib/components/media/MediaToolbar.js.map +0 -1
  129. package/lib/components/media/MediaWrapper.js +0 -67
  130. package/lib/components/media/MediaWrapper.js.map +0 -1
  131. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
  132. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
  133. package/lib/components/respArea/DragInTheBlank/choice.js +0 -250
  134. package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
  135. package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
  136. package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
  137. package/lib/components/respArea/InlineDropdown.js +0 -209
  138. package/lib/components/respArea/InlineDropdown.js.map +0 -1
  139. package/lib/components/respArea/MathTemplated.js +0 -130
  140. package/lib/components/respArea/MathTemplated.js.map +0 -1
  141. package/lib/components/respArea/ToolbarIcon.js +0 -81
  142. package/lib/components/respArea/ToolbarIcon.js.map +0 -1
  143. package/lib/components/respArea/inlineDropdownUtils.js +0 -67
  144. package/lib/components/respArea/inlineDropdownUtils.js.map +0 -1
  145. package/lib/constants.js +0 -11
  146. package/lib/constants.js.map +0 -1
  147. package/lib/extensions/css.js +0 -217
  148. package/lib/extensions/css.js.map +0 -1
  149. package/lib/extensions/custom-toolbar-wrapper.js +0 -92
  150. package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
  151. package/lib/extensions/div-node.js +0 -83
  152. package/lib/extensions/div-node.js.map +0 -1
  153. package/lib/extensions/ensure-empty-root-div.js +0 -48
  154. package/lib/extensions/ensure-empty-root-div.js.map +0 -1
  155. package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
  156. package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
  157. package/lib/extensions/extended-list-item.js +0 -15
  158. package/lib/extensions/extended-list-item.js.map +0 -1
  159. package/lib/extensions/extended-table-cell.js +0 -22
  160. package/lib/extensions/extended-table-cell.js.map +0 -1
  161. package/lib/extensions/extended-table.js +0 -75
  162. package/lib/extensions/extended-table.js.map +0 -1
  163. package/lib/extensions/heading-paragraph.js +0 -61
  164. package/lib/extensions/heading-paragraph.js.map +0 -1
  165. package/lib/extensions/image-component.js +0 -348
  166. package/lib/extensions/image-component.js.map +0 -1
  167. package/lib/extensions/image.js +0 -134
  168. package/lib/extensions/image.js.map +0 -1
  169. package/lib/extensions/index.js +0 -46
  170. package/lib/extensions/index.js.map +0 -1
  171. package/lib/extensions/math.js +0 -342
  172. package/lib/extensions/math.js.map +0 -1
  173. package/lib/extensions/media.js +0 -243
  174. package/lib/extensions/media.js.map +0 -1
  175. package/lib/extensions/responseArea.js +0 -446
  176. package/lib/extensions/responseArea.js.map +0 -1
  177. package/lib/index.js +0 -37
  178. package/lib/index.js.map +0 -1
  179. package/lib/styles/editorContainerStyles.js +0 -137
  180. package/lib/styles/editorContainerStyles.js.map +0 -1
  181. package/lib/theme.js +0 -8
  182. package/lib/theme.js.map +0 -1
  183. package/lib/utils/helper.js +0 -73
  184. package/lib/utils/helper.js.map +0 -1
  185. package/lib/utils/size.js +0 -26
  186. package/lib/utils/size.js.map +0 -1
  187. package/src/__tests__/EditableHtml.test.jsx +0 -554
  188. package/src/__tests__/constants.test.js +0 -19
  189. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  190. package/src/__tests__/extensions.test.js +0 -208
  191. package/src/__tests__/index.test.jsx +0 -154
  192. package/src/__tests__/size-utils.test.js +0 -64
  193. package/src/__tests__/theme.test.js +0 -17
  194. package/src/components/CharacterPicker.jsx +0 -207
  195. package/src/components/EditableHtml.jsx +0 -440
  196. package/src/components/MenuBar.jsx +0 -554
  197. package/src/components/TiptapContainer.jsx +0 -219
  198. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  199. package/src/components/__tests__/CharacterPicker.test.jsx +0 -261
  200. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  201. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  202. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
  203. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  204. package/src/components/__tests__/InlineDropdown.test.jsx +0 -388
  205. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  206. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  207. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  208. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  209. package/src/components/__tests__/MenuBar.test.jsx +0 -250
  210. package/src/components/__tests__/RespArea.test.jsx +0 -122
  211. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  212. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  213. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  214. package/src/components/__tests__/characterUtils.test.js +0 -166
  215. package/src/components/__tests__/choice.test.jsx +0 -171
  216. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  217. package/src/components/__tests__/done-button.test.jsx +0 -54
  218. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  219. package/src/components/characters/characterUtils.js +0 -447
  220. package/src/components/characters/custom-popper.js +0 -38
  221. package/src/components/common/done-button.jsx +0 -27
  222. package/src/components/common/toolbar-buttons.jsx +0 -122
  223. package/src/components/icons/CssIcon.jsx +0 -15
  224. package/src/components/icons/RespArea.jsx +0 -71
  225. package/src/components/icons/TableIcons.jsx +0 -52
  226. package/src/components/icons/TextAlign.jsx +0 -114
  227. package/src/components/image/AltDialog.jsx +0 -82
  228. package/src/components/image/ImageToolbar.jsx +0 -99
  229. package/src/components/image/InsertImageHandler.js +0 -107
  230. package/src/components/media/MediaDialog.jsx +0 -596
  231. package/src/components/media/MediaToolbar.jsx +0 -49
  232. package/src/components/media/MediaWrapper.jsx +0 -39
  233. package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
  234. package/src/components/respArea/DragInTheBlank/choice.jsx +0 -256
  235. package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
  236. package/src/components/respArea/InlineDropdown.jsx +0 -220
  237. package/src/components/respArea/MathTemplated.jsx +0 -124
  238. package/src/components/respArea/ToolbarIcon.jsx +0 -66
  239. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  240. package/src/components/respArea/inlineDropdownUtils.js +0 -79
  241. package/src/constants.js +0 -5
  242. package/src/extensions/__tests__/css.test.js +0 -196
  243. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  244. package/src/extensions/__tests__/divNode.test.js +0 -87
  245. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  246. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  247. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  248. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  249. package/src/extensions/__tests__/extended-table.test.js +0 -183
  250. package/src/extensions/__tests__/image-component.test.jsx +0 -345
  251. package/src/extensions/__tests__/image.test.js +0 -237
  252. package/src/extensions/__tests__/math.test.js +0 -603
  253. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  254. package/src/extensions/__tests__/media.test.js +0 -271
  255. package/src/extensions/__tests__/responseArea.test.js +0 -601
  256. package/src/extensions/css.js +0 -220
  257. package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
  258. package/src/extensions/div-node.js +0 -86
  259. package/src/extensions/ensure-empty-root-div.js +0 -47
  260. package/src/extensions/ensure-list-item-content-is-div.js +0 -62
  261. package/src/extensions/extended-list-item.js +0 -10
  262. package/src/extensions/extended-table-cell.js +0 -19
  263. package/src/extensions/extended-table.js +0 -60
  264. package/src/extensions/heading-paragraph.js +0 -53
  265. package/src/extensions/image-component.jsx +0 -338
  266. package/src/extensions/image.js +0 -109
  267. package/src/extensions/index.js +0 -81
  268. package/src/extensions/math.js +0 -326
  269. package/src/extensions/media.js +0 -188
  270. package/src/extensions/responseArea.js +0 -401
  271. package/src/index.jsx +0 -5
  272. package/src/styles/editorContainerStyles.js +0 -145
  273. package/src/theme.js +0 -1
  274. package/src/utils/__tests__/helper.test.js +0 -126
  275. package/src/utils/helper.js +0 -69
  276. package/src/utils/size.js +0 -32
@@ -0,0 +1,149 @@
1
+ import e from "../components/media/MediaDialog.js";
2
+ import t from "../components/media/MediaToolbar.js";
3
+ import { useEffect as n } from "react";
4
+ import { NodeViewWrapper as r, ReactNodeViewRenderer as i } from "@tiptap/react";
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";
8
+ //#region src/extensions/media.tsx
9
+ var u = a.create({
10
+ name: "media",
11
+ group: "inline",
12
+ inline: !0,
13
+ atom: !0,
14
+ addAttributes() {
15
+ return {
16
+ type: { default: "video" },
17
+ src: { default: null },
18
+ width: { default: null },
19
+ height: { default: null },
20
+ title: { default: null },
21
+ starts: { default: null },
22
+ ends: { default: null },
23
+ editing: { default: !1 },
24
+ tag: { default: "iframe" },
25
+ url: { default: null }
26
+ };
27
+ },
28
+ parseHTML() {
29
+ return [{
30
+ tag: "iframe[data-type=\"video\"]",
31
+ getAttrs: (e) => ({
32
+ type: "video",
33
+ tag: "iframe",
34
+ src: e.getAttribute("src"),
35
+ width: e.getAttribute("width"),
36
+ height: e.getAttribute("height"),
37
+ title: e.dataset.title,
38
+ starts: e.dataset.starts,
39
+ ends: e.dataset.ends,
40
+ url: e.dataset.url
41
+ })
42
+ }, {
43
+ tag: "audio",
44
+ getAttrs: (e) => ({
45
+ type: "audio",
46
+ tag: "audio",
47
+ src: e.querySelector("source")?.getAttribute("src")
48
+ })
49
+ }];
50
+ },
51
+ renderHTML({ HTMLAttributes: e }) {
52
+ let { tag: t, src: n, width: r, height: i } = e;
53
+ return t === "audio" ? [
54
+ "audio",
55
+ {
56
+ controls: "controls",
57
+ controlsList: "nodownload"
58
+ },
59
+ ["source", {
60
+ src: n,
61
+ type: "audio/mp3"
62
+ }]
63
+ ] : ["iframe", o({
64
+ "data-type": "video",
65
+ frameborder: "0",
66
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
67
+ allowfullscreen: "",
68
+ src: n
69
+ }, r ? { width: r } : {}, i ? { height: i } : {})];
70
+ },
71
+ addCommands() {
72
+ return {
73
+ insertMedia: (e) => ({ commands: t }) => t.insertContent({
74
+ type: this.name,
75
+ attrs: e
76
+ }),
77
+ updateMedia: (e) => ({ commands: t }) => t.updateAttributes(this.name, e)
78
+ };
79
+ },
80
+ addNodeView() {
81
+ return i((e) => /* @__PURE__ */ c(p, {
82
+ ...e,
83
+ options: this.options
84
+ }));
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, {
94
+ ...o,
95
+ uploadSoundSupport: a.uploadSoundSupport,
96
+ type: r,
97
+ disablePortal: !0,
98
+ open: !0,
99
+ handleClose: u
100
+ });
101
+ s.render(f, n), document.body.appendChild(n);
102
+ };
103
+ function p({ editor: e, node: i, updateAttributes: a, deleteNode: o, options: s }) {
104
+ let { type: u, src: d, width: p, height: m, tag: h } = i.attrs;
105
+ return n(() => {
106
+ d || f({
107
+ ...i.attrs,
108
+ options: s,
109
+ edit: !0,
110
+ callback: (t, n) => {
111
+ t ? a(n) : o(), e.chain().focus().run();
112
+ }
113
+ });
114
+ }, []), /* @__PURE__ */ l(r, {
115
+ "data-type": u,
116
+ style: {
117
+ width: p,
118
+ height: m
119
+ },
120
+ children: [h === "audio" ? /* @__PURE__ */ c("audio", {
121
+ controls: !0,
122
+ controlsList: "nodownload",
123
+ children: /* @__PURE__ */ c("source", {
124
+ type: "audio/mp3",
125
+ src: d
126
+ })
127
+ }) : /* @__PURE__ */ c("iframe", {
128
+ src: d,
129
+ allowFullScreen: !0,
130
+ frameBorder: "0",
131
+ width: p,
132
+ height: m
133
+ }), /* @__PURE__ */ c(t, {
134
+ onEdit: () => {
135
+ f({
136
+ ...i.attrs,
137
+ options: s,
138
+ edit: !0,
139
+ callback: (t, n) => {
140
+ t && a(n), e.chain().focus().run();
141
+ }
142
+ });
143
+ },
144
+ onRemove: o
145
+ })]
146
+ });
147
+ }
148
+ //#endregion
149
+ export { u as Media };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/extensions/responseArea.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 { Extension } from '@tiptap/core';
10
+ import { Node } from '@tiptap/react';
11
+ export declare const ResponseAreaExtension: Extension<any, any>;
12
+ /**
13
+ * ExplicitConstructedResponse Node
14
+ */
15
+ export declare const ExplicitConstructedResponseNode: Node<any, any>;
16
+ /**
17
+ * MathTemplated Node
18
+ */
19
+ export declare const MathTemplatedNode: Node<any, any>;
20
+ /**
21
+ * DragInTheBlank Node
22
+ */
23
+ export declare const DragInTheBlankNode: Node<any, any>;
24
+ /**
25
+ * InlineDropdown Node
26
+ */
27
+ export declare const InlineDropdownNode: Node<any, any>;
@@ -0,0 +1,259 @@
1
+ import e from "../components/respArea/ExplicitConstructedResponse.js";
2
+ import t from "../components/respArea/DragInTheBlank/DragInTheBlank.js";
3
+ import n from "../components/respArea/InlineDropdown.js";
4
+ import r from "../components/respArea/MathTemplated.js";
5
+ import "react";
6
+ import { Node as i, ReactNodeViewRenderer as a } from "@tiptap/react";
7
+ import { Extension as o } from "@tiptap/core";
8
+ import { NodeSelection as s, Plugin as c, PluginKey as l, TextSelection as u } from "prosemirror-state";
9
+ import { jsx as d } from "react/jsx-runtime";
10
+ //#region src/extensions/responseArea.tsx
11
+ var f = {}, p = (e) => String(e || "").replace(/-/g, "_"), m = (e) => e && e.attrs && e.attrs.index != null ? String(e.attrs.index) : null, h = (e, t) => {
12
+ let n = [];
13
+ return e.descendants((e, r) => {
14
+ if (e.type && e.type.name === t) {
15
+ let t = m(e);
16
+ t != null && n.push({
17
+ index: t,
18
+ pos: r,
19
+ node: e
20
+ });
21
+ }
22
+ return !0;
23
+ }), n;
24
+ }, g = (e, t) => {
25
+ let n = 0;
26
+ return e.descendants((e) => (e.type && e.type.name === t && (n += 1), !0)), n;
27
+ }, _ = ({ schema: e, typeName: t, index: n }) => {
28
+ let r = e.nodes[t];
29
+ return r ? r.create({
30
+ index: String(n),
31
+ id: String(n),
32
+ value: ""
33
+ }) : null;
34
+ }, v = (e, t) => {
35
+ let n = e.resolve(Math.min(t, e.content.size));
36
+ return u.near(n, 1);
37
+ }, y = o.create({
38
+ name: "responseArea",
39
+ addOptions() {
40
+ return {
41
+ maxResponseAreas: null,
42
+ error: null,
43
+ options: null,
44
+ respAreaToolbar: null,
45
+ onHandleAreaChange: null
46
+ };
47
+ },
48
+ addProseMirrorPlugins() {
49
+ if (!this.options.type) return [];
50
+ let e = p(this.options.type);
51
+ return [new c({
52
+ key: new l(`response-area-watcher:${e}`),
53
+ view: (t) => (f[e] === void 0 && (f[e] = 0, t.state.doc.descendants((t) => {
54
+ if (t.type && t.type.name === e) {
55
+ let n = m(t);
56
+ if (n != null) {
57
+ let t = parseInt(n, 10);
58
+ !Number.isNaN(t) && t > f[e] && (f[e] = t);
59
+ }
60
+ }
61
+ return !0;
62
+ })), { update: (t, n) => {
63
+ let r = t.state;
64
+ if (n.doc.eq(r.doc)) return;
65
+ let i = h(r.doc, e), a = h(n.doc, e);
66
+ if (this.options.toolbar && (this.options.toolbar.disabled = i.length >= this.options.maxResponseAreas), a.length > i.length) {
67
+ let e = new Set(i.map((e) => e.index)), t = a.filter((t) => !e.has(t.index));
68
+ t.length && typeof this.options.onHandleAreaChange == "function" && this.options.onHandleAreaChange(t);
69
+ }
70
+ } })
71
+ })];
72
+ },
73
+ addCommands() {
74
+ return {
75
+ insertResponseArea: (e) => ({ tr: t, state: n, dispatch: r, commands: i }) => {
76
+ let a = p(e);
77
+ if (g(n.doc, a) >= this.options.maxResponseAreas) return !1;
78
+ f[a] === void 0 && (f[a] = 0);
79
+ let o = f[a] + 1;
80
+ f[a] += 1;
81
+ let c = _({
82
+ schema: n.schema,
83
+ typeName: a,
84
+ index: o
85
+ });
86
+ if (!c) return !1;
87
+ let { selection: l } = n, u = l.from, d = (e) => {
88
+ try {
89
+ return t.insert(e, c), e;
90
+ } catch {
91
+ return null;
92
+ }
93
+ }, m = d(u);
94
+ if (m ??= d(t.doc.content.size), m == null) return !1;
95
+ if ([
96
+ "math_templated",
97
+ "inline_dropdown",
98
+ "explicit_constructed_response"
99
+ ].includes(a)) t.setSelection(s.create(t.doc, m));
100
+ else {
101
+ let e = m + c.nodeSize;
102
+ t.setSelection(v(t.doc, e));
103
+ }
104
+ return r && (i.focus(), r(t)), !0;
105
+ },
106
+ refreshResponseArea: () => ({ tr: e, state: t, commands: n, dispatch: r }) => {
107
+ let { selection: i } = t, a = i.$from.nodeAfter, o = i.from;
108
+ return e.setNodeMarkup(o, void 0, {
109
+ ...a?.attrs,
110
+ updated: `${Date.now()}`
111
+ }), e.setSelection(s.create(e.doc, o)), r && (n.focus(), r(e)), !0;
112
+ }
113
+ };
114
+ }
115
+ }), b = i.create({
116
+ name: "explicit_constructed_response",
117
+ group: "inline",
118
+ inline: !0,
119
+ atom: !0,
120
+ addAttributes() {
121
+ return {
122
+ index: { default: null },
123
+ value: { default: "" },
124
+ updated: { default: "" }
125
+ };
126
+ },
127
+ parseHTML() {
128
+ return [{
129
+ tag: "span[data-type=\"explicit_constructed_response\"]",
130
+ getAttrs: (e) => ({
131
+ index: e.dataset.index,
132
+ value: e.dataset.value
133
+ })
134
+ }];
135
+ },
136
+ renderHTML({ HTMLAttributes: e }) {
137
+ return ["span", {
138
+ "data-type": "explicit_constructed_response",
139
+ "data-index": e.index,
140
+ "data-value": e.value
141
+ }];
142
+ },
143
+ addNodeView() {
144
+ return a((t) => /* @__PURE__ */ d(e, {
145
+ ...t,
146
+ options: this.options
147
+ }));
148
+ }
149
+ }), x = i.create({
150
+ name: "math_templated",
151
+ group: "inline",
152
+ inline: !0,
153
+ atom: !0,
154
+ addAttributes() {
155
+ return {
156
+ index: { default: null },
157
+ value: { default: "" },
158
+ updated: { default: "" }
159
+ };
160
+ },
161
+ parseHTML() {
162
+ return [{
163
+ tag: "span[data-type=\"math_templated\"]",
164
+ getAttrs: (e) => ({
165
+ index: e.dataset.index,
166
+ value: e.dataset.value
167
+ })
168
+ }];
169
+ },
170
+ renderHTML({ HTMLAttributes: e }) {
171
+ return ["span", {
172
+ "data-type": "math_templated",
173
+ "data-index": e.index,
174
+ "data-value": e.value
175
+ }];
176
+ },
177
+ addNodeView() {
178
+ return a((e) => /* @__PURE__ */ d(r, {
179
+ ...e,
180
+ options: this.options
181
+ }));
182
+ }
183
+ }), S = i.create({
184
+ name: "drag_in_the_blank",
185
+ group: "inline",
186
+ inline: !0,
187
+ atom: !0,
188
+ addAttributes() {
189
+ return {
190
+ index: { default: null },
191
+ id: { default: null },
192
+ value: { default: "" },
193
+ inTable: { default: null },
194
+ updated: { default: "" }
195
+ };
196
+ },
197
+ parseHTML() {
198
+ return [{
199
+ tag: "span[data-type=\"drag_in_the_blank\"]",
200
+ getAttrs: (e) => ({
201
+ index: e.dataset.index,
202
+ id: e.dataset.id,
203
+ value: e.dataset.value,
204
+ inTable: e.dataset.inTable
205
+ })
206
+ }];
207
+ },
208
+ renderHTML({ HTMLAttributes: e }) {
209
+ return ["span", {
210
+ "data-type": "drag_in_the_blank",
211
+ "data-index": e.index,
212
+ "data-id": e.id,
213
+ "data-value": e.value,
214
+ "data-in-table": e.inTable
215
+ }];
216
+ },
217
+ addNodeView() {
218
+ return a((e) => /* @__PURE__ */ d(t, {
219
+ ...e,
220
+ options: this.options
221
+ }));
222
+ }
223
+ }), C = i.create({
224
+ name: "inline_dropdown",
225
+ group: "inline",
226
+ inline: !0,
227
+ atom: !0,
228
+ addAttributes() {
229
+ return {
230
+ index: { default: null },
231
+ value: { default: "" },
232
+ updated: { default: "" }
233
+ };
234
+ },
235
+ parseHTML() {
236
+ return [{
237
+ tag: "span[data-type=\"inline_dropdown\"]",
238
+ getAttrs: (e) => ({
239
+ index: e.dataset.index,
240
+ value: e.dataset.value
241
+ })
242
+ }];
243
+ },
244
+ renderHTML({ HTMLAttributes: e }) {
245
+ return ["span", {
246
+ "data-type": "inline_dropdown",
247
+ "data-index": e.index,
248
+ "data-value": e.value
249
+ }];
250
+ },
251
+ addNodeView() {
252
+ return a((e) => /* @__PURE__ */ d(n, {
253
+ ...e,
254
+ options: this.options
255
+ }));
256
+ }
257
+ });
258
+ //#endregion
259
+ export { S as DragInTheBlankNode, b as ExplicitConstructedResponseNode, C as InlineDropdownNode, x as MathTemplatedNode, y as ResponseAreaExtension };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/index.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 StyledEditor, { EditableHtml } from './components/EditableHtml.js';
10
+ import { ALL_PLUGINS, DEFAULT_PLUGINS } from './extensions/index.js';
11
+ import { deleteInlineDropdownByIndex } from './components/respArea/inlineDropdownUtils.js';
12
+ export { EditableHtml, ALL_PLUGINS, DEFAULT_PLUGINS, deleteInlineDropdownByIndex };
13
+ export default StyledEditor;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { ALL_PLUGINS as e, DEFAULT_PLUGINS as t } from "./extensions/index.js";
2
+ import n from "./components/EditableHtml.js";
3
+ import { deleteInlineDropdownByIndex as r } from "./components/respArea/inlineDropdownUtils.js";
4
+ //#region src/index.tsx
5
+ var i = n;
6
+ //#endregion
7
+ export { e as ALL_PLUGINS, t as DEFAULT_PLUGINS, n as EditableHtml, i as default, r as deleteInlineDropdownByIndex };
@@ -0,0 +1,16 @@
1
+ //#region ../../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
2
+ function e(t) {
3
+ var n, r, i = "";
4
+ if (typeof t == "string" || typeof t == "number") i += t;
5
+ else if (typeof t == "object") if (Array.isArray(t)) {
6
+ var a = t.length;
7
+ for (n = 0; n < a; n++) t[n] && (r = e(t[n])) && (i && (i += " "), i += r);
8
+ } else for (r in t) t[r] && (i && (i += " "), i += r);
9
+ return i;
10
+ }
11
+ function t() {
12
+ for (var t, n, r = 0, i = "", a = arguments.length; r < a; r++) (t = arguments[r]) && (n = e(t)) && (i && (i += " "), i += n);
13
+ return i;
14
+ }
15
+ //#endregion
16
+ export { t as default };
@@ -0,0 +1,134 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/styles/editorContainerStyles.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 styles: (theme: any) => {
10
+ root: {
11
+ position: string;
12
+ padding: string;
13
+ border: string;
14
+ borderRadius: string;
15
+ cursor: string;
16
+ '& [data-slate-editor="true"]': {
17
+ wordBreak: string;
18
+ overflow: string;
19
+ maxHeight: string;
20
+ padding: string;
21
+ };
22
+ '&:first-child': {
23
+ marginTop: number;
24
+ };
25
+ '& ul, & ol': {
26
+ padding: string;
27
+ margin: string;
28
+ };
29
+ '& ul li p, & ol li p': {
30
+ marginTop: string;
31
+ marginBottom: string;
32
+ };
33
+ '& h1, & h2, & h3, & h4, & h5, & h6': {
34
+ lineHeight: number;
35
+ marginTop: string;
36
+ textWrap: string;
37
+ };
38
+ '& h1, & h2': {
39
+ marginTop: string;
40
+ marginBottom: string;
41
+ };
42
+ '& h1': {
43
+ fontSize: string;
44
+ };
45
+ '& h2': {
46
+ fontSize: string;
47
+ };
48
+ '& h3': {
49
+ fontSize: string;
50
+ };
51
+ '& h4, & h5, & h6': {
52
+ fontSize: string;
53
+ };
54
+ '& code': {
55
+ backgroundColor: string;
56
+ borderRadius: string;
57
+ color: string;
58
+ fontSize: string;
59
+ padding: string;
60
+ };
61
+ '& pre': {
62
+ background: string;
63
+ borderRadius: string;
64
+ color: string;
65
+ fontFamily: string;
66
+ margin: string;
67
+ padding: string;
68
+ '& code': {
69
+ background: string;
70
+ color: string;
71
+ fontSize: string;
72
+ padding: number;
73
+ };
74
+ };
75
+ '& blockquote': {
76
+ background: string;
77
+ borderLeft: string;
78
+ margin: string;
79
+ padding: string;
80
+ };
81
+ '& hr': {
82
+ border: string;
83
+ borderTop: string;
84
+ margin: string;
85
+ };
86
+ '& table': {
87
+ tableLayout: string;
88
+ width: string;
89
+ borderCollapse: string;
90
+ color: any;
91
+ backgroundColor: any;
92
+ };
93
+ '& table:not([border="1"]) tr': {
94
+ borderTop: string;
95
+ };
96
+ '& td, th': {
97
+ padding: string;
98
+ textAlign: string;
99
+ };
100
+ '& table:not([border="1"]) td, th': {
101
+ border: string;
102
+ };
103
+ };
104
+ children: {
105
+ padding: string;
106
+ };
107
+ editorHolder: {
108
+ position: string;
109
+ padding: string;
110
+ overflowY: string;
111
+ color: any;
112
+ backgroundColor: any;
113
+ };
114
+ disabledScrollbar: {
115
+ '&::-webkit-scrollbar': {
116
+ display: string;
117
+ };
118
+ scrollbarWidth: string;
119
+ '-ms-overflow-style': string;
120
+ };
121
+ error: {
122
+ border: string;
123
+ };
124
+ noBorder: {
125
+ border: string;
126
+ };
127
+ noPadding: {
128
+ padding: number;
129
+ };
130
+ toolbarOnTop: {
131
+ marginTop: string;
132
+ };
133
+ };
134
+ export default styles;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/theme.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 primary = "#304ffe";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/utils/helper.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 normalizeInitialMarkup: (markup: any) => any;
@@ -0,0 +1,27 @@
1
+ //#region src/utils/helper.tsx
2
+ var e = (e) => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), t = (e) => {
3
+ let t = document.createElement("div");
4
+ t.innerHTML = e;
5
+ let n = Array.from(t.children);
6
+ return n.length < 2 || !n.every((e) => e.tagName === "DIV") || !n.every((e) => e.attributes.length === 0) || !n.every((e) => Array.from(e.children).every((e) => {
7
+ let t = e.tagName;
8
+ return [
9
+ "SPAN",
10
+ "B",
11
+ "I",
12
+ "EM",
13
+ "STRONG",
14
+ "U",
15
+ "SUB",
16
+ "SUP",
17
+ "A",
18
+ "CODE",
19
+ "BR"
20
+ ].includes(t);
21
+ })) ? e : `<p>${n.map((e) => e.innerHTML).join("<br>")}</p>`;
22
+ }, n = (n) => {
23
+ let r = String(n ?? "").trim();
24
+ return r ? /<[^>]+>/.test(r) ? t(r) : `<div>${e(r)}</div>` : "<div></div>";
25
+ };
26
+ //#endregion
27
+ export { n as normalizeInitialMarkup };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @synced-from pie-lib/packages/editable-html-tip-tap/src/utils/size.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 valueToSize: (v: any) => string | number | undefined;
@@ -0,0 +1,14 @@
1
+ //#region src/utils/size.ts
2
+ var e = (e) => {
3
+ if (!e) return;
4
+ let t = /^calc\((.*)\)$/;
5
+ if (typeof e == "string") {
6
+ if (e.endsWith("%")) return;
7
+ if (e.endsWith("px") || e.endsWith("vh") || e.endsWith("vw") || e.endsWith("ch") || e.endsWith("em") || e.match(t)) return e;
8
+ let n = parseInt(e, 10);
9
+ return Number.isNaN(n) ? n : `${n}px`;
10
+ }
11
+ if (typeof e == "number") return `${e}px`;
12
+ };
13
+ //#endregion
14
+ export { e as valueToSize };