@pie-element/extended-text-entry 15.1.2-next.2 → 15.1.2

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 (100) hide show
  1. package/CHANGELOG.json +1282 -0
  2. package/CHANGELOG.md +2270 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +922 -0
  6. package/configure/CHANGELOG.md +1959 -0
  7. package/configure/lib/defaults.js +224 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/index.js +125 -0
  10. package/configure/lib/index.js.map +1 -0
  11. package/configure/lib/main.js +247 -0
  12. package/configure/lib/main.js.map +1 -0
  13. package/configure/package.json +23 -0
  14. package/controller/CHANGELOG.json +362 -0
  15. package/controller/CHANGELOG.md +1183 -0
  16. package/controller/lib/defaults.js +91 -0
  17. package/controller/lib/defaults.js.map +1 -0
  18. package/controller/lib/index.js +101 -0
  19. package/controller/lib/index.js.map +1 -0
  20. package/controller/package.json +16 -0
  21. package/docs/config-schema.json +1782 -0
  22. package/docs/config-schema.json.md +1333 -0
  23. package/docs/demo/config.js +7 -0
  24. package/docs/demo/generate.js +14 -0
  25. package/docs/demo/index.html +3 -0
  26. package/docs/demo/session.js +7 -0
  27. package/docs/pie-schema.json +954 -0
  28. package/docs/pie-schema.json.md +717 -0
  29. package/lib/annotation/annotation-editor.js +636 -0
  30. package/lib/annotation/annotation-editor.js.map +1 -0
  31. package/lib/annotation/annotation-menu.js +147 -0
  32. package/lib/annotation/annotation-menu.js.map +1 -0
  33. package/lib/annotation/annotation-utils.js +205 -0
  34. package/lib/annotation/annotation-utils.js.map +1 -0
  35. package/lib/annotation/freeform-editor.js +241 -0
  36. package/lib/annotation/freeform-editor.js.map +1 -0
  37. package/lib/index.js +108 -0
  38. package/lib/index.js.map +1 -0
  39. package/lib/main.js +205 -0
  40. package/lib/main.js.map +1 -0
  41. package/lib/print.js +86 -0
  42. package/lib/print.js.map +1 -0
  43. package/module/configure.js +1 -0
  44. package/module/controller.js +139 -0
  45. package/module/demo.js +38 -0
  46. package/module/element.js +1 -0
  47. package/module/index.html +21 -0
  48. package/module/manifest.json +22 -0
  49. package/module/print-demo.js +76 -0
  50. package/module/print.html +18 -0
  51. package/module/print.js +1 -0
  52. package/package.json +22 -87
  53. package/configure.js +0 -2
  54. package/controller.js +0 -1
  55. package/dist/author/defaults.d.ts +0 -166
  56. package/dist/author/defaults.js +0 -209
  57. package/dist/author/index.d.ts +0 -52
  58. package/dist/author/index.js +0 -74
  59. package/dist/author/main.d.ts +0 -26
  60. package/dist/author/main.js +0 -166
  61. package/dist/browser/author/index.js +0 -495
  62. package/dist/browser/author/index.js.map +0 -1
  63. package/dist/browser/browser-kkT1XVKw.js +0 -219
  64. package/dist/browser/browser-kkT1XVKw.js.map +0 -1
  65. package/dist/browser/controller/index.js +0 -184
  66. package/dist/browser/controller/index.js.map +0 -1
  67. package/dist/browser/delivery/index.js +0 -98
  68. package/dist/browser/delivery/index.js.map +0 -1
  69. package/dist/browser/dist-BCJzhghM.js +0 -47879
  70. package/dist/browser/dist-BCJzhghM.js.map +0 -1
  71. package/dist/browser/extended-text-entry.css +0 -2
  72. package/dist/browser/main-VcQEFn-b.js +0 -714
  73. package/dist/browser/main-VcQEFn-b.js.map +0 -1
  74. package/dist/browser/print/index.js +0 -48
  75. package/dist/browser/print/index.js.map +0 -1
  76. package/dist/controller/defaults.d.ts +0 -33
  77. package/dist/controller/defaults.js +0 -104
  78. package/dist/controller/index.d.ts +0 -59
  79. package/dist/controller/index.js +0 -72
  80. package/dist/delivery/annotation/annotation-editor.d.ts +0 -47
  81. package/dist/delivery/annotation/annotation-editor.js +0 -296
  82. package/dist/delivery/annotation/annotation-menu.d.ts +0 -25
  83. package/dist/delivery/annotation/annotation-menu.js +0 -113
  84. package/dist/delivery/annotation/annotation-utils.d.ts +0 -20
  85. package/dist/delivery/annotation/annotation-utils.js +0 -65
  86. package/dist/delivery/annotation/freeform-editor.d.ts +0 -30
  87. package/dist/delivery/annotation/freeform-editor.js +0 -143
  88. package/dist/delivery/index.d.ts +0 -23
  89. package/dist/delivery/index.js +0 -68
  90. package/dist/delivery/main.d.ts +0 -27
  91. package/dist/delivery/main.js +0 -134
  92. package/dist/extended-text-entry.css +0 -2
  93. package/dist/index.d.ts +0 -1
  94. package/dist/index.iife.d.ts +0 -8
  95. package/dist/index.iife.js +0 -403
  96. package/dist/index.js +0 -2
  97. package/dist/print/index.d.ts +0 -15
  98. package/dist/print/index.js +0 -48
  99. package/dist/runtime-support.d.ts +0 -12
  100. package/dist/runtime-support.js +0 -12
@@ -1,296 +0,0 @@
1
- import { clearSelection as e, getAnnotationElements as t, getDOMNodes as n, getLabelElement as r, getRangeDetails as i, isSideLabel as a, removeElemsWrapping as o, wrapRange as s } from "./annotation-utils.js";
2
- import c from "./freeform-editor.js";
3
- import l from "./annotation-menu.js";
4
- import u from "react";
5
- import d from "prop-types";
6
- import { styled as f } from "@mui/material/styles";
7
- import p from "@pie-lib/editable-html-tip-tap";
8
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
9
- import { InputContainer as g } from "@pie-lib/config-ui";
10
- //#region src/delivery/annotation/annotation-editor.tsx
11
- var _ = f("div")({
12
- padding: "10px 120px 10px 16px",
13
- backgroundColor: "rgba(0, 0, 0, 0.06)",
14
- border: "1px solid #ccc",
15
- borderRadius: "4px",
16
- overflowY: "scroll",
17
- lineHeight: "36px",
18
- whiteSpace: "pre-wrap",
19
- overflowWrap: "break-word",
20
- "& p": { margin: 0 },
21
- "& span[data-latex]": {
22
- userSelect: "none",
23
- "-webkit-user-select": "none",
24
- "-moz-user-select": "none",
25
- "-ms-user-select": "none"
26
- }
27
- }), v = f("div")({ width: "230px" }), y = f("div")({
28
- position: "relative",
29
- overflowX: "hidden",
30
- display: "flex"
31
- }), b = f(g)(({ theme: e }) => ({
32
- paddingTop: e.spacing(2),
33
- marginBottom: e.spacing(2),
34
- marginTop: e.spacing(2),
35
- width: "100%"
36
- })), x = "\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: \"\";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n";
37
- if (!document.getElementById("annotation-editor-styles")) {
38
- let e = document.createElement("style");
39
- e.id = "annotation-editor-styles", e.textContent = x, document.head.appendChild(e);
40
- }
41
- var S = class extends u.Component {
42
- static propTypes = {
43
- text: d.string,
44
- comment: d.string,
45
- annotations: d.array,
46
- predefinedAnnotations: d.array,
47
- onChange: d.func.isRequired,
48
- onCommentChange: d.func.isRequired,
49
- width: d.number,
50
- height: d.number,
51
- maxHeight: d.string,
52
- disabled: d.bool,
53
- disabledMath: d.bool,
54
- customKeys: d.array,
55
- keypadMode: d.string
56
- };
57
- constructor(e) {
58
- super(e), this.state = {
59
- anchorEl: null,
60
- openedMenu: !1,
61
- openedEditor: !1,
62
- selectedElems: [],
63
- labelElem: null,
64
- selectionDetails: null,
65
- annotation: null,
66
- annotationIndex: null
67
- };
68
- }
69
- componentDidMount() {
70
- let { annotations: e, text: t } = this.props;
71
- t && e.forEach((e) => {
72
- let [t, r] = n(e.start, e.end, this.textRef);
73
- if (t && r) {
74
- let n = document.createRange();
75
- n.setStart(t.node, t.offset), n.setEnd(r.node, r.offset);
76
- let i = s(n);
77
- this.createDOMAnnotation(i, e);
78
- }
79
- }), this.textRef && (this.adjustAnnotationsPosition(), this.textRef.addEventListener("scroll", this.adjustAnnotationsPosition));
80
- }
81
- adjustAnnotationsPosition = () => {
82
- if (this.textRef && this.labelsRef) {
83
- let e = this.textRef.offsetLeft + this.textRef.offsetWidth + 8;
84
- Array.from(this.labelsRef.children).forEach((n) => {
85
- let r = t(n.dataset.annId), i = (r[0].offsetTop ? r[0].offsetTop : r[0].offsetParent.offsetTop) - this.textRef.scrollTop - 6;
86
- n.style.top = `${i}px`, n.style.left = `${e}px`;
87
- });
88
- }
89
- };
90
- handleClick = (e) => {
91
- let { annotations: n } = this.props, { selectionDetails: i } = this.state;
92
- if (i) return;
93
- let { id: a, annId: o } = e.target.dataset, s = a || o, c = t(s), l = r(s), u = n.findIndex((e) => e.id === s), d = l.hasAttribute("data-freeform");
94
- d && (l.style.zIndex = "10"), this.setState({
95
- anchorEl: c[0],
96
- openedMenu: !!a || !!o && !d,
97
- openedEditor: !!o && d,
98
- selectedElems: c,
99
- labelElem: l,
100
- annotationIndex: u,
101
- annotation: n[u],
102
- selectionDetails: null
103
- });
104
- };
105
- handleHover = (e) => {
106
- let { id: n, annId: i } = e.target.dataset, a = n || i, o = t(a), s = r(a), c = s.hasAttribute("data-freeform");
107
- o.forEach((e) => {
108
- e.style.zIndex = "20", e.classList.contains("positive") ? e.style.backgroundColor = "rgb(51, 255, 51, 0.7)" : e.classList.contains("negative") && (e.style.backgroundColor = "rgba(255, 102, 204, 0.55)");
109
- }), c ? (s.style.zIndex = "20", s.classList.contains("positive") ? (s.style.backgroundColor = "rgb(128, 255, 128)", s.style.setProperty("--before-border-color", "rgb(153, 255, 153)")) : s.classList.contains("negative") && (s.style.backgroundColor = "rgb(255, 179, 230)", s.style.setProperty("--before-border-color", "rgb(255, 179, 230)"))) : (s.style.zIndex = "20", s.classList.contains("positive") ? s.style.color = "rgb(0, 77, 0)" : s.classList.contains("negative") && (s.style.color = "rgb(153, 0, 102)"));
110
- };
111
- handleCancelHover = (e) => {
112
- let { id: n, annId: i } = e.target.dataset, a = n || i, o = t(a), s = r(a), c = s.hasAttribute("data-freeform");
113
- o.forEach((e) => {
114
- e.style.zIndex = "", e.classList.contains("positive") ? e.style.backgroundColor = "rgb(51, 255, 51, 0.5)" : e.classList.contains("negative") && (e.style.backgroundColor = "rgba(255, 102, 204, 0.4)");
115
- }), c ? (s.style.zIndex = "", s.classList.contains("positive") ? (s.style.backgroundColor = "rgb(153, 255, 153)", s.style.removeProperty("--before-border-color")) : s.classList.contains("negative") && (s.style.backgroundColor = "rgb(255, 204, 238)", s.style.removeProperty("--before-border-color"))) : (s.style.zIndex = "", s.classList.contains("positive") ? s.style.color = "rgb(0, 128, 0)" : s.classList.contains("negative") && (s.style.color = "rgb(204, 0, 136)"));
116
- };
117
- handleClose = (t) => {
118
- let { selectedElems: n, labelElem: r } = this.state;
119
- n.length && !n[0].hasAttribute("data-id") && o(n, this.textRef), r && (r.style.zIndex = ""), this.setState({
120
- anchorEl: null,
121
- openedMenu: !1,
122
- openedEditor: !1,
123
- selectedElems: [],
124
- labelElem: null,
125
- selectionDetails: null,
126
- annotationIndex: null,
127
- annotation: null
128
- }), e();
129
- };
130
- handleSelection = (t) => {
131
- let n = window.getSelection();
132
- if (t.detail > 2) {
133
- e();
134
- return;
135
- }
136
- if (n && n.rangeCount > 0) {
137
- let e = n.getRangeAt(0), t = e.toString(), r = this.textRef.contains(e.commonAncestorContainer);
138
- if (!n.isCollapsed && t !== "" && r) {
139
- let t = i(e, this.textRef), n = s(e);
140
- this.setState({
141
- anchorEl: n[0],
142
- openedMenu: !0,
143
- selectedElems: n,
144
- selectionDetails: t
145
- });
146
- }
147
- }
148
- };
149
- deleteAnnotation = () => {
150
- let { annotations: e, onChange: t } = this.props, { selectedElems: n, labelElem: r, annotationIndex: i, annotation: s } = this.state;
151
- (a(s.label) ? this.labelsRef : n[0]).removeChild(r), o(n, this.textRef), e.splice(i, 1), t(e), this.handleClose();
152
- };
153
- createDOMAnnotation = (e, t) => {
154
- let { disabled: n } = this.props, { id: r, label: i, type: o } = t;
155
- (e || []).forEach((e) => {
156
- e.dataset.id = r, e.className = `annotation ${o}`, e.style.position = "relative", e.style.cursor = "pointer", o === "positive" ? e.style.backgroundColor = "rgb(51, 255, 51, 0.5)" : o === "negative" && (e.style.backgroundColor = "rgba(255, 102, 204, 0.4)"), e.onclick = !n && this.handleClick, e.onmouseover = this.handleHover, e.onmouseout = this.handleCancelHover;
157
- });
158
- let s = e && e[0] || {}, c = document.createElement("SPAN");
159
- if (c.dataset.annId = r, c.innerHTML = i, c.onclick = !n && this.handleClick, c.onmouseover = this.handleHover, c.onmouseout = this.handleCancelHover, a(i)) {
160
- let e = (s.offsetTop ? s.offsetTop : s.offsetParent.offsetTop) - this.textRef.scrollTop, t = this.textRef.offsetLeft + this.textRef.offsetWidth + 8;
161
- c.dataset.freeform = !0, c.className = `sideAnnotation ${o}`, c.style.position = "absolute", c.style.padding = "4px", c.style.borderRadius = "4px", c.style.marginLeft = "8px", c.style.width = "180px", c.style.whiteSpace = "pre-wrap", c.style.wordBreak = "break-word", c.style.border = "2px solid #ffffff", c.style.fontSize = "14px", c.style.fontStyle = "normal", c.style.fontWeight = "normal", c.style.top = `${e}px`, c.style.left = `${t}px`, o === "negative" ? c.style.backgroundColor = "rgb(255, 204, 238)" : o === "positive" && (c.style.backgroundColor = "rgb(153, 255, 153)"), c.style.setProperty("--before-border-width", "7px"), c.style.setProperty("--before-top", "5px"), c.style.setProperty("--before-right", "100%"), o === "negative" ? c.style.setProperty("--before-border-color", "rgb(255, 204, 238)") : o === "positive" && c.style.setProperty("--before-border-color", "rgb(153, 255, 153)"), this.labelsRef.appendChild(c);
162
- } else c.className = `annotationLabel ${o}`, c.style.backgroundColor = "rgb(242, 242, 242)", c.style.padding = "2px", c.style.position = "absolute", c.style.userSelect = "none", c.style.whiteSpace = "nowrap", c.style.top = "-10px", c.style.left = "-2px", c.style.fontSize = "12px", c.style.fontStyle = "normal", c.style.fontWeight = "normal", c.style.lineHeight = "6px", c.style.webkitUserSelect = "none", c.style.mozUserSelect = "none", c.style.msUserSelect = "none", o === "positive" ? c.style.color = "rgb(0, 128, 0)" : o === "negative" && (c.style.color = "rgb(204, 0, 136)"), s.appendChild(c);
163
- };
164
- createNewAnnotation = (e, t) => {
165
- let { selectedElems: n, selectionDetails: r } = this.state, i = {
166
- id: [
167
- r.start,
168
- r.end,
169
- (/* @__PURE__ */ new Date()).getTime()
170
- ].join("-"),
171
- label: e,
172
- type: t,
173
- ...r
174
- };
175
- return this.createDOMAnnotation(n, i), i;
176
- };
177
- handleMenuClick = (e) => {
178
- let { annotations: t, onChange: n } = this.props, { annotation: r, annotationIndex: i } = this.state, { type: a, text: o } = e;
179
- if (r) {
180
- let e = {
181
- ...r,
182
- label: o,
183
- type: a
184
- }, { type: n, label: s } = r;
185
- this.updateLabel(s, e, a !== n && n), t.splice(i, 1, e);
186
- } else {
187
- let e = this.createNewAnnotation(o, a);
188
- t.push(e);
189
- }
190
- n(t), this.handleClose();
191
- };
192
- editAnnotation = () => {
193
- this.setState({
194
- openedMenu: !1,
195
- openedEditor: !0
196
- });
197
- };
198
- addAnnotation = (e) => {
199
- let { annotations: t, onChange: n } = this.props, i = this.createNewAnnotation("", e), a = r(i.id);
200
- t.push(i), this.setState({
201
- openedMenu: !1,
202
- openedEditor: !0,
203
- annotationIndex: t.length - 1,
204
- annotation: i,
205
- labelElem: a
206
- }), n(t);
207
- };
208
- updateLabel = (e, t, n) => {
209
- let { selectedElems: r, labelElem: i } = this.state, { label: o, type: s } = t;
210
- a(o) && a(e) || !a(o) && !a(e) ? (i.innerHTML = o, n && (i.classList.remove(n), i.classList.add(s), r.forEach((e) => {
211
- e.classList.remove(n), e.classList.add(s);
212
- }))) : a(o) && !a(e) ? (r[0].removeChild(i), this.createDOMAnnotation(r, t)) : !a(o) && a(e) && (this.labelsRef.removeChild(i), this.createDOMAnnotation(r, t));
213
- };
214
- changeAnnotationType = (e) => {
215
- let { annotations: t, onChange: n } = this.props, { annotationIndex: r, selectedElems: i } = this.state, { type: a, label: o } = t[r], s = a === "positive" ? "negative" : "positive", c = {
216
- ...t[r],
217
- type: s,
218
- label: e
219
- };
220
- i.forEach((e) => {
221
- e.classList.remove(a), e.classList.add(s);
222
- }), this.updateLabel(o, c, a), t.splice(r, 1, c), n(t), this.handleClose();
223
- };
224
- updateAnnotation = (e, t) => {
225
- let { annotations: n, onChange: r } = this.props, { annotationIndex: i } = this.state, a = {
226
- ...n[i],
227
- label: t
228
- };
229
- this.updateLabel(e, a), n.splice(i, 1, a), r(n);
230
- };
231
- componentWillUnmount() {
232
- this.textRef.removeEventListener("scroll", this.adjustAnnotationsPosition);
233
- }
234
- render() {
235
- let { comment: t, customKeys: n, disabled: r, disabledMath: i, keypadMode: a, height: o, width: s, maxHeight: u, onCommentChange: d, predefinedAnnotations: f, text: g } = this.props, { anchorEl: x, annotation: S, openedMenu: C, openedEditor: w, selectionDetails: T } = this.state, E = x && (x.offsetTop ? x.offsetTop : x.offsetParent.offsetTop), D = this.textRef && E ? E - this.textRef.scrollTop - 8 : 0;
236
- return /* @__PURE__ */ h("div", { children: [
237
- /* @__PURE__ */ h(y, { children: [/* @__PURE__ */ m(_, {
238
- style: {
239
- width: s - 34,
240
- minHeight: o,
241
- maxHeight: u
242
- },
243
- ref: (e) => this.textRef = e,
244
- onMouseDown: r ? () => {} : e,
245
- onMouseUp: r ? () => {} : this.handleSelection,
246
- dangerouslySetInnerHTML: { __html: g }
247
- }), /* @__PURE__ */ m(v, { ref: (e) => this.labelsRef = e })] }),
248
- /* @__PURE__ */ m(b, {
249
- label: "Comment",
250
- children: /* @__PURE__ */ m(p, {
251
- className: "prompt",
252
- markup: t || "",
253
- onChange: d,
254
- width: s && (s + 104).toString(),
255
- disabled: r,
256
- pluginProps: {
257
- math: {
258
- disabled: i,
259
- customKeys: n,
260
- keypadMode: a,
261
- controlledKeypadMode: !1
262
- },
263
- video: { disabled: !0 },
264
- audio: { disabled: !0 },
265
- textAlign: { disabled: !0 },
266
- h3: { disabled: !0 }
267
- }
268
- })
269
- }),
270
- /* @__PURE__ */ m(l, {
271
- anchorEl: x,
272
- open: C && !r,
273
- annotations: f,
274
- isNewAnnotation: !!T,
275
- onClose: this.handleClose,
276
- onDelete: this.deleteAnnotation,
277
- onEdit: this.editAnnotation,
278
- onWrite: this.addAnnotation,
279
- onAnnotate: this.handleMenuClick
280
- }),
281
- /* @__PURE__ */ m(c, {
282
- anchorEl: this.textRef,
283
- open: w && !r,
284
- offset: D,
285
- value: S && S.label || "",
286
- type: S && S.type,
287
- onClose: this.handleClose,
288
- onDelete: this.deleteAnnotation,
289
- onSave: this.updateAnnotation,
290
- onTypeChange: this.changeAnnotationType
291
- })
292
- ] });
293
- }
294
- };
295
- //#endregion
296
- export { S as default };
@@ -1,25 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/extended-text-entry/src/annotation/annotation-menu.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 React from 'react';
10
- import PropTypes from 'prop-types';
11
- declare class AnnotationMenu extends React.Component {
12
- static propTypes: {
13
- anchorEl: PropTypes.Requireable<object>;
14
- open: PropTypes.Requireable<boolean>;
15
- annotations: PropTypes.Requireable<any[]>;
16
- isNewAnnotation: PropTypes.Requireable<boolean>;
17
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
18
- onDelete: PropTypes.Requireable<(...args: any[]) => any>;
19
- onEdit: PropTypes.Requireable<(...args: any[]) => any>;
20
- onWrite: PropTypes.Requireable<(...args: any[]) => any>;
21
- onAnnotate: PropTypes.Requireable<(...args: any[]) => any>;
22
- };
23
- render(): React.JSX.Element;
24
- }
25
- export default AnnotationMenu;
@@ -1,113 +0,0 @@
1
- import e from "react";
2
- import t from "prop-types";
3
- import { styled as n } from "@mui/material/styles";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
- import { Popover as a } from "@mui/material";
6
- //#region src/delivery/annotation/annotation-menu.tsx
7
- var o = n(a)({ "& .MuiPaper-root": {
8
- overflowX: "unset",
9
- overflowY: "unset",
10
- marginTop: "-16px",
11
- "&::after": {
12
- position: "absolute",
13
- left: "calc(50% - 7px)",
14
- border: "solid transparent",
15
- content: "\"\"",
16
- height: 0,
17
- width: 0,
18
- pointerEvents: "none",
19
- borderWidth: "7px",
20
- borderTopColor: "black"
21
- }
22
- } }), s = n("div")(({ theme: e }) => ({
23
- width: "300px",
24
- overflow: "hidden",
25
- borderRadius: "4px",
26
- backgroundColor: e.palette.common.white,
27
- border: `2px solid ${e.palette.grey[100]}`
28
- })), c = n("div")({
29
- display: "flex",
30
- flexWrap: "wrap"
31
- }), l = n("div")(({ theme: e }) => ({
32
- display: "flex",
33
- flexWrap: "wrap",
34
- borderTop: `2px solid ${e.palette.grey[100]}`
35
- })), u = n("div")(({ theme: e, variant: t }) => ({
36
- width: "22%",
37
- textAlign: "center",
38
- padding: "4px",
39
- cursor: "pointer",
40
- borderBottom: `1px solid ${e.palette.grey[100]}`,
41
- "&:not(:nth-child(4n))": { borderRight: `1px solid ${e.palette.grey[100]}` },
42
- "&:nth-child(4n)": { flexGrow: 1 },
43
- "&:hover": { backgroundColor: e.palette.grey[100] },
44
- ...t === "positive" && {
45
- backgroundColor: "rgb(153, 255, 153) !important",
46
- "&:hover": { filter: "brightness(85%)" }
47
- },
48
- ...t === "negative" && {
49
- backgroundColor: "rgb(255, 204, 238) !important",
50
- "&:hover": { filter: "brightness(85%)" }
51
- }
52
- })), d = class extends e.Component {
53
- static propTypes = {
54
- anchorEl: t.object,
55
- open: t.bool,
56
- annotations: t.array,
57
- isNewAnnotation: t.bool,
58
- onClose: t.func,
59
- onDelete: t.func,
60
- onEdit: t.func,
61
- onWrite: t.func,
62
- onAnnotate: t.func
63
- };
64
- render() {
65
- let { anchorEl: t, annotations: n, isNewAnnotation: a, onAnnotate: d, onClose: f, onEdit: p, onDelete: m, onWrite: h, open: g } = this.props;
66
- return /* @__PURE__ */ r(o, {
67
- anchorEl: t,
68
- open: g,
69
- onClose: f,
70
- elevation: 5,
71
- transitionDuration: {
72
- enter: 225,
73
- exit: 195
74
- },
75
- anchorOrigin: {
76
- vertical: "top",
77
- horizontal: "center"
78
- },
79
- transformOrigin: {
80
- vertical: "bottom",
81
- horizontal: "center"
82
- },
83
- children: /* @__PURE__ */ i(s, { children: [/* @__PURE__ */ r(c, { children: n.map((e, t) => /* @__PURE__ */ r(u, {
84
- variant: e.type,
85
- onClick: () => d(e),
86
- children: e.label
87
- }, `annotation-${t}`)) }), /* @__PURE__ */ i(l, { children: [
88
- /* @__PURE__ */ r(u, {
89
- onClick: f,
90
- children: "Cancel"
91
- }),
92
- /* @__PURE__ */ r(u, { style: { pointerEvents: "none" } }),
93
- a ? /* @__PURE__ */ i(e.Fragment, { children: [/* @__PURE__ */ r(u, {
94
- variant: "positive",
95
- onClick: () => h("positive"),
96
- children: "Write"
97
- }), /* @__PURE__ */ r(u, {
98
- variant: "negative",
99
- onClick: () => h("negative"),
100
- children: "Write"
101
- })] }) : /* @__PURE__ */ i(e.Fragment, { children: [/* @__PURE__ */ r(u, {
102
- onClick: m,
103
- children: "Delete"
104
- }), /* @__PURE__ */ r(u, {
105
- onClick: p,
106
- children: "Edit"
107
- })] })
108
- ] })] })
109
- });
110
- }
111
- };
112
- //#endregion
113
- export { d as default };
@@ -1,20 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/extended-text-entry/src/annotation/annotation-utils.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 getDOMNodes: (startOffset: any, endOffset: any, rootNode: any) => any[];
10
- export declare const wrapRange: (range: any) => any[];
11
- export declare const getRangeDetails: (range: any, rootNode: any) => {
12
- quote: string | any[];
13
- start: number;
14
- end: number;
15
- };
16
- export declare const removeElemsWrapping: (elems: any, container: any) => void;
17
- export declare const clearSelection: () => void;
18
- export declare const isSideLabel: (text: any) => boolean;
19
- export declare const getAnnotationElements: (id: any) => Element[];
20
- export declare const getLabelElement: (id: any) => Element | null;
@@ -1,65 +0,0 @@
1
- //#region src/delivery/annotation/annotation-utils.ts
2
- var e = (t, n, r) => {
3
- let i = r || [], a = i.reduce((e, t) => e + t.textContent.length, 0), o = !0;
4
- if (a > n) return !1;
5
- for (t &&= (t.nodeType === 3 && t.parentNode && !t.parentNode.hasAttribute("data-ann-id") && i.push(t), t.firstChild); t && o;) o = e(t, n, i), t = t.nextSibling;
6
- return i;
7
- }, t = (t, n, r) => {
8
- let i = e(r, n), a = [], o = 0;
9
- return i.forEach((e) => {
10
- let r = o + e.textContent.length;
11
- [t, n].forEach((t) => {
12
- o <= t && t < r && a.push({
13
- node: e,
14
- offset: t - o
15
- });
16
- }), o = r;
17
- }), a;
18
- }, n = (e) => {
19
- let { commonAncestorContainer: t, startContainer: n, endContainer: r, startOffset: i, endOffset: a } = e, o = [], s = !1, c = !1, l = "", u = (e) => {
20
- let { nodeValue: t, childNodes: d } = e;
21
- e === n && e === r ? (t && (l += t.substring(i, a)), s = c = !0) : e === n ? (t && (l += t.substring(i)), s = !0) : e === r ? (t && (l += t.substring(0, a)), c = !0) : e && e.nodeType === 3 && e.parentNode && !e.parentNode.hasAttribute("data-ann-id") && t && s && !c && (l += t, o.push(e)), d.forEach((e) => {
22
- if (!c) u(e);
23
- else return;
24
- });
25
- };
26
- return u(t), [o, l];
27
- }, r = (e) => {
28
- let t = document.createElement("SPAN");
29
- return e.surroundContents(t), t;
30
- }, i = (e) => {
31
- if (e.startContainer === e.endContainer) return [r(e)];
32
- let [t] = n(e), i = document.createRange();
33
- i.selectNodeContents(e.startContainer), i.setStart(e.startContainer, e.startOffset);
34
- let a = r(i), o = document.createRange();
35
- o.selectNode(e.endContainer), o.setEnd(e.endContainer, e.endOffset);
36
- let s = r(o);
37
- return [
38
- a,
39
- ...t.map((e) => {
40
- let t = document.createElement("SPAN");
41
- return e.parentNode.insertBefore(t, e), t.appendChild(e), t;
42
- }),
43
- s
44
- ];
45
- }, a = (e, t) => {
46
- let r = document.createRange();
47
- r.setStart(t, 0), r.setEnd(e.startContainer, e.startOffset);
48
- let [, i] = n(r), [, a] = n(e), o = i.length;
49
- return {
50
- quote: a,
51
- start: o,
52
- end: o + a.length
53
- };
54
- }, o = (e, t) => {
55
- (e || []).forEach((e) => {
56
- let t = e.parentNode, n = e.childNodes, r = n.length;
57
- if (r > 0) for (let i = 0; i < r; i++) t.insertBefore(n[0], e);
58
- else t.insertBefore(document.createTextNode(e.textContent), e);
59
- t.removeChild(e);
60
- }), t.normalize();
61
- }, s = () => {
62
- document.getSelection ? (document.getSelection().removeAllRanges(), document.getSelection().addRange(document.createRange())) : window.getSelection ? window.getSelection().removeAllRanges ? (window.getSelection().removeAllRanges(), window.getSelection().addRange(document.createRange())) : window.getSelection().empty && window.getSelection().empty() : document.selection && document.selection.empty();
63
- }, c = (e) => e.length >= 20 || e.search(/\n|\r|\r\n/) !== -1, l = (e) => Array.from(document.querySelectorAll(`[data-id='${e}']`)), u = (e) => document.querySelector(`[data-ann-id='${e}']`);
64
- //#endregion
65
- export { s as clearSelection, l as getAnnotationElements, t as getDOMNodes, u as getLabelElement, a as getRangeDetails, c as isSideLabel, o as removeElemsWrapping, i as wrapRange };
@@ -1,30 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/extended-text-entry/src/annotation/freeform-editor.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 React from 'react';
10
- import PropTypes from 'prop-types';
11
- declare class FreeformEditor extends React.Component {
12
- static propTypes: {
13
- anchorEl: PropTypes.Requireable<object>;
14
- open: PropTypes.Requireable<boolean>;
15
- offset: PropTypes.Requireable<number>;
16
- value: PropTypes.Requireable<string>;
17
- type: PropTypes.Requireable<string>;
18
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
19
- onDelete: PropTypes.Requireable<(...args: any[]) => any>;
20
- onSave: PropTypes.Requireable<(...args: any[]) => any>;
21
- onTypeChange: PropTypes.Requireable<(...args: any[]) => any>;
22
- };
23
- constructor(props: any);
24
- UNSAFE_componentWillReceiveProps(nextProps: any): void;
25
- onValueChange: (event: any) => void;
26
- handleSave: any;
27
- handleTypeChange: any;
28
- render(): React.JSX.Element;
29
- }
30
- export default FreeformEditor;