@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.
- package/dist/components/CharacterPicker.d.ts +31 -0
- package/dist/components/CharacterPicker.d.ts.map +1 -0
- package/dist/components/CharacterPicker.js +129 -0
- package/dist/components/EditableHtml.d.ts +11 -0
- package/dist/components/EditableHtml.d.ts.map +1 -0
- package/dist/components/EditableHtml.js +270 -0
- package/dist/components/MenuBar.d.ts +11 -0
- package/dist/components/MenuBar.d.ts.map +1 -0
- package/dist/components/MenuBar.js +460 -0
- package/dist/components/TiptapContainer.d.ts +11 -0
- package/dist/components/TiptapContainer.d.ts.map +1 -0
- package/dist/components/TiptapContainer.js +157 -0
- package/dist/components/characters/characterUtils.d.ts +36 -0
- package/dist/components/characters/characterUtils.d.ts.map +1 -0
- package/dist/components/characters/characterUtils.js +465 -0
- package/dist/components/characters/custom-popper.d.ts +14 -0
- package/dist/components/characters/custom-popper.d.ts.map +1 -0
- package/dist/components/characters/custom-popper.js +32 -0
- package/dist/components/common/done-button.d.ts +30 -0
- package/dist/components/common/done-button.d.ts.map +1 -0
- package/dist/components/common/done-button.js +26 -0
- package/dist/components/common/toolbar-buttons.d.ts +39 -0
- package/dist/components/common/toolbar-buttons.d.ts.map +1 -0
- package/dist/components/common/toolbar-buttons.js +91 -0
- package/dist/components/icons/CssIcon.d.ts +11 -0
- package/dist/components/icons/CssIcon.d.ts.map +1 -0
- package/dist/components/icons/CssIcon.js +14 -0
- package/dist/components/icons/RespArea.d.ts +26 -0
- package/dist/components/icons/RespArea.d.ts.map +1 -0
- package/dist/components/icons/RespArea.js +42 -0
- package/dist/components/icons/TableIcons.d.ts +14 -0
- package/dist/components/icons/TableIcons.d.ts.map +1 -0
- package/dist/components/icons/TableIcons.js +32 -0
- package/dist/components/icons/TextAlign.d.ts +18 -0
- package/dist/components/icons/TextAlign.d.ts.map +1 -0
- package/dist/components/icons/TextAlign.js +134 -0
- package/dist/components/image/AltDialog.d.ts +23 -0
- package/dist/components/image/AltDialog.d.ts.map +1 -0
- package/dist/components/image/AltDialog.js +61 -0
- package/dist/components/image/ImageToolbar.d.ts +25 -0
- package/dist/components/image/ImageToolbar.d.ts.map +1 -0
- package/dist/components/image/ImageToolbar.js +80 -0
- package/dist/components/image/InsertImageHandler.d.ts +33 -0
- package/dist/components/image/InsertImageHandler.d.ts.map +1 -0
- package/dist/components/image/InsertImageHandler.js +55 -0
- package/dist/components/media/MediaDialog.d.ts +44 -0
- package/dist/components/media/MediaDialog.d.ts.map +1 -0
- package/dist/components/media/MediaDialog.js +389 -0
- package/dist/components/media/MediaToolbar.d.ts +20 -0
- package/dist/components/media/MediaToolbar.d.ts.map +1 -0
- package/dist/components/media/MediaToolbar.js +41 -0
- package/dist/components/media/MediaWrapper.d.ts +20 -0
- package/dist/components/media/MediaWrapper.d.ts.map +1 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts.map +1 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
- package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
- package/dist/components/respArea/DragInTheBlank/choice.d.ts.map +1 -0
- package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
- package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
- package/dist/components/respArea/ExplicitConstructedResponse.d.ts.map +1 -0
- package/dist/components/respArea/ExplicitConstructedResponse.js +67 -0
- package/dist/components/respArea/InlineDropdown.d.ts +18 -0
- package/dist/components/respArea/InlineDropdown.d.ts.map +1 -0
- package/dist/components/respArea/InlineDropdown.js +91 -0
- package/dist/components/respArea/MathTemplated.d.ts +19 -0
- package/dist/components/respArea/MathTemplated.d.ts.map +1 -0
- package/dist/components/respArea/MathTemplated.js +97 -0
- package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
- package/dist/components/respArea/ToolbarIcon.d.ts.map +1 -0
- package/dist/components/respArea/ToolbarIcon.js +17 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- package/dist/extensions/css.d.ts +12 -0
- package/dist/extensions/css.d.ts.map +1 -0
- package/dist/extensions/css.js +115 -0
- package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
- package/dist/extensions/custom-toolbar-wrapper.d.ts.map +1 -0
- package/dist/extensions/custom-toolbar-wrapper.js +58 -0
- package/dist/extensions/div-node.d.ts +11 -0
- package/dist/extensions/div-node.d.ts.map +1 -0
- package/dist/extensions/div-node.js +25 -0
- package/dist/extensions/extended-table.d.ts +11 -0
- package/dist/extensions/extended-table.d.ts.map +1 -0
- package/dist/extensions/extended-table.js +15 -0
- package/dist/extensions/image-component.d.ts +22 -0
- package/dist/extensions/image-component.d.ts.map +1 -0
- package/dist/extensions/image-component.js +200 -0
- package/dist/extensions/image.d.ts +11 -0
- package/dist/extensions/image.d.ts.map +1 -0
- package/dist/extensions/image.js +42 -0
- package/dist/extensions/index.d.ts +17 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +65 -0
- package/dist/extensions/math.d.ts +15 -0
- package/dist/extensions/math.d.ts.map +1 -0
- package/dist/extensions/math.js +150 -0
- package/dist/extensions/media.d.ts +19 -0
- package/dist/extensions/media.d.ts.map +1 -0
- package/dist/extensions/media.js +147 -0
- package/dist/extensions/responseArea.d.ts +28 -0
- package/dist/extensions/responseArea.d.ts.map +1 -0
- package/dist/extensions/responseArea.js +259 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/styles/editorContainerStyles.d.ts +135 -0
- package/dist/styles/editorContainerStyles.d.ts.map +1 -0
- package/dist/theme.d.ts +10 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/utils/helper.d.ts +10 -0
- package/dist/utils/helper.d.ts.map +1 -0
- package/dist/utils/helper.js +7 -0
- package/dist/utils/size.d.ts +10 -0
- package/dist/utils/size.d.ts.map +1 -0
- package/dist/utils/size.js +14 -0
- package/package.json +71 -0
- package/src/components/CharacterPicker.tsx +210 -0
- package/src/components/EditableHtml.tsx +416 -0
- package/src/components/MenuBar.tsx +558 -0
- package/src/components/TiptapContainer.tsx +228 -0
- package/src/components/characters/characterUtils.ts +457 -0
- package/src/components/characters/custom-popper.tsx +48 -0
- package/src/components/common/done-button.tsx +37 -0
- package/src/components/common/toolbar-buttons.tsx +132 -0
- package/src/components/icons/CssIcon.tsx +25 -0
- package/src/components/icons/RespArea.tsx +81 -0
- package/src/components/icons/TableIcons.tsx +62 -0
- package/src/components/icons/TextAlign.tsx +124 -0
- package/src/components/image/AltDialog.tsx +92 -0
- package/src/components/image/ImageToolbar.tsx +109 -0
- package/src/components/image/InsertImageHandler.ts +121 -0
- package/src/components/media/MediaDialog.tsx +606 -0
- package/src/components/media/MediaToolbar.tsx +59 -0
- package/src/components/media/MediaWrapper.tsx +49 -0
- package/src/components/respArea/DragInTheBlank/DragInTheBlank.tsx +86 -0
- package/src/components/respArea/DragInTheBlank/choice.tsx +266 -0
- package/src/components/respArea/ExplicitConstructedResponse.tsx +122 -0
- package/src/components/respArea/InlineDropdown.tsx +152 -0
- package/src/components/respArea/MathTemplated.tsx +134 -0
- package/src/components/respArea/ToolbarIcon.tsx +76 -0
- package/src/constants.ts +15 -0
- package/src/extensions/css.tsx +230 -0
- package/src/extensions/custom-toolbar-wrapper.tsx +88 -0
- package/src/extensions/div-node.tsx +46 -0
- package/src/extensions/extended-table.ts +34 -0
- package/src/extensions/image-component.tsx +303 -0
- package/src/extensions/image.tsx +64 -0
- package/src/extensions/index.tsx +91 -0
- package/src/extensions/math.tsx +285 -0
- package/src/extensions/media.tsx +198 -0
- package/src/extensions/responseArea.tsx +404 -0
- package/src/index.tsx +15 -0
- package/src/styles/editorContainerStyles.ts +155 -0
- package/src/theme.ts +11 -0
- package/src/utils/helper.tsx +27 -0
- package/src/utils/size.ts +42 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/editable-html-tip-tap/src/components/CharacterPicker.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 const CharacterIcon: {
|
|
11
|
+
({ letter }: {
|
|
12
|
+
letter: any;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
propTypes: {
|
|
15
|
+
letter: PropTypes.Requireable<string>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare function CharacterPicker({ editor, opts, onClose }: {
|
|
19
|
+
editor: any;
|
|
20
|
+
opts: any;
|
|
21
|
+
onClose: any;
|
|
22
|
+
}): JSX.Element | null;
|
|
23
|
+
export declare namespace CharacterPicker {
|
|
24
|
+
var propTypes: {
|
|
25
|
+
editor: PropTypes.Requireable<object>;
|
|
26
|
+
opts: PropTypes.Requireable<object>;
|
|
27
|
+
onClose: PropTypes.Validator<(...args: any[]) => any>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export { CharacterIcon };
|
|
31
|
+
//# sourceMappingURL=CharacterPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CharacterPicker.d.ts","sourceRoot":"","sources":["../../src/components/CharacterPicker.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAIH,OAAO,SAAS,MAAM,YAAY,CAAC;AAQnC,QAAA,MAAM,aAAa;;;;;;;CASlB,CAAC;AAMF,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;;;;CAAA,sBAsKxD;yBAtKe,eAAe;;;;;;;AA8K/B,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { spanishConfig as e, specialConfig as t } from "./characters/characterUtils.js";
|
|
2
|
+
import n from "./characters/custom-popper.js";
|
|
3
|
+
import { useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
4
|
+
import s from "prop-types";
|
|
5
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
import d from "react-dom";
|
|
7
|
+
import { PureToolbar as f } from "@pie-lib/math-toolbar";
|
|
8
|
+
import p from "lodash-es/get.js";
|
|
9
|
+
//#region src/components/CharacterPicker.tsx
|
|
10
|
+
var m = ({ letter: e }) => /* @__PURE__ */ l("div", {
|
|
11
|
+
style: {
|
|
12
|
+
fontSize: "24px",
|
|
13
|
+
lineHeight: "24px"
|
|
14
|
+
},
|
|
15
|
+
children: e
|
|
16
|
+
});
|
|
17
|
+
m.propTypes = { letter: s.string };
|
|
18
|
+
function h({ editor: s, opts: m, onClose: h }) {
|
|
19
|
+
if (!m?.characters?.length) return null;
|
|
20
|
+
let g = a(null), [_, v] = o({
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0
|
|
23
|
+
}), [y, b] = o(null), x = i(() => {
|
|
24
|
+
if (!m) return e;
|
|
25
|
+
switch (!0) {
|
|
26
|
+
case m.language === "spanish": return e;
|
|
27
|
+
case m.language === "special": return t;
|
|
28
|
+
default: return m;
|
|
29
|
+
}
|
|
30
|
+
}, [m]), S = i(() => x.characters.reduce((e, t) => (t.length >= e.columns && (e.columns = t.length), e), {
|
|
31
|
+
rows: x.characters.length,
|
|
32
|
+
columns: 0
|
|
33
|
+
}), [x]), C = () => b(null);
|
|
34
|
+
r(() => () => {
|
|
35
|
+
C();
|
|
36
|
+
}, []), r(() => {
|
|
37
|
+
if (!s) return;
|
|
38
|
+
let e = s.options.element.getBoundingClientRect(), t = document.body.getBoundingClientRect(), { from: n } = s.state.selection, r = s.view.coordsAtPos(n), i = e.top + Math.abs(t.top) + e.height + 60;
|
|
39
|
+
e.y > g.current.offsetHeight && (i = i - (g.current.offsetHeight + e.height) - 80), v({
|
|
40
|
+
top: i,
|
|
41
|
+
left: r.left
|
|
42
|
+
});
|
|
43
|
+
let a = (e) => {
|
|
44
|
+
g.current && !g.current.contains(e.target) && !s.view.dom.contains(e.target) && h();
|
|
45
|
+
}, o = setTimeout(() => {
|
|
46
|
+
document.addEventListener("click", a);
|
|
47
|
+
});
|
|
48
|
+
return () => {
|
|
49
|
+
clearTimeout(o), document.removeEventListener("click", a);
|
|
50
|
+
};
|
|
51
|
+
}, [s, h]);
|
|
52
|
+
let w = (e, t) => b({
|
|
53
|
+
anchorEl: e.currentTarget,
|
|
54
|
+
el: t
|
|
55
|
+
}), T = (e) => {
|
|
56
|
+
typeof e == "string" && s.chain().focus().insertContent(e).run();
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ u(c, { children: [d.createPortal(/* @__PURE__ */ l("div", {
|
|
59
|
+
ref: g,
|
|
60
|
+
className: "insert-character-dialog",
|
|
61
|
+
"data-toolbar-for": s.instanceId,
|
|
62
|
+
style: {
|
|
63
|
+
visibility: _.top === 0 && _.left === 0 ? "hidden" : "initial",
|
|
64
|
+
position: "absolute",
|
|
65
|
+
top: `${_.top}px`,
|
|
66
|
+
left: `${_.left}px`,
|
|
67
|
+
maxWidth: "500px",
|
|
68
|
+
zIndex: 99
|
|
69
|
+
},
|
|
70
|
+
children: /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(f, {
|
|
71
|
+
keyPadCharacterRef: m.keyPadCharacterRef,
|
|
72
|
+
setKeypadInteraction: m.setKeypadInteraction,
|
|
73
|
+
autoFocus: !0,
|
|
74
|
+
noDecimal: !0,
|
|
75
|
+
hideInput: !0,
|
|
76
|
+
noLatexHandling: !0,
|
|
77
|
+
hideDoneButtonBackground: !0,
|
|
78
|
+
layoutForKeyPad: S,
|
|
79
|
+
additionalKeys: x.characters.reduce((e, t) => (e = [...e, ...t.map((e) => ({
|
|
80
|
+
name: p(e, "name") || e,
|
|
81
|
+
write: p(e, "write") || e,
|
|
82
|
+
label: p(e, "label") || e,
|
|
83
|
+
category: "character",
|
|
84
|
+
extraClass: "character",
|
|
85
|
+
extraProps: {
|
|
86
|
+
...e.extraProps || {},
|
|
87
|
+
style: {
|
|
88
|
+
...(e.extraProps || {}).style,
|
|
89
|
+
border: "1px solid #000"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
...x.hasPreview ? { actions: {
|
|
93
|
+
onMouseEnter: (t) => w(t, e),
|
|
94
|
+
onMouseLeave: C
|
|
95
|
+
} } : {}
|
|
96
|
+
}))], e), []),
|
|
97
|
+
keypadMode: "language",
|
|
98
|
+
onChange: T,
|
|
99
|
+
onDone: h
|
|
100
|
+
}) })
|
|
101
|
+
}), document.body), y && d.createPortal(/* @__PURE__ */ u(n, {
|
|
102
|
+
onClose: C,
|
|
103
|
+
anchorEl: y.anchorEl,
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ l("div", { children: y.el.label }),
|
|
106
|
+
/* @__PURE__ */ l("div", {
|
|
107
|
+
style: {
|
|
108
|
+
fontSize: 20,
|
|
109
|
+
lineHeight: "20px"
|
|
110
|
+
},
|
|
111
|
+
children: y.el.description
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ l("div", {
|
|
114
|
+
style: {
|
|
115
|
+
fontSize: 20,
|
|
116
|
+
lineHeight: "20px"
|
|
117
|
+
},
|
|
118
|
+
children: y.el.unicode
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}), document.body)] });
|
|
122
|
+
}
|
|
123
|
+
h.propTypes = {
|
|
124
|
+
editor: s.object,
|
|
125
|
+
opts: s.object,
|
|
126
|
+
onClose: s.func.isRequired
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { m as CharacterIcon, h as CharacterPicker };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/editable-html-tip-tap/src/components/EditableHtml.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
|
+
export declare const EditableHtml: (props: any) => JSX.Element;
|
|
10
|
+
export default EditableHtml;
|
|
11
|
+
//# sourceMappingURL=EditableHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableHtml.d.ts","sourceRoot":"","sources":["../../src/components/EditableHtml.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAiGH,eAAO,MAAM,YAAY,GAAI,UAAK,gBA0QjC,CAAC;AA4CF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { normalizeInitialMarkup as e } from "../utils/helper.js";
|
|
2
|
+
import t from "../extensions/extended-table.js";
|
|
3
|
+
import { DivNode as n } from "../extensions/div-node.js";
|
|
4
|
+
import { DragInTheBlankNode as r, ExplicitConstructedResponseNode as i, InlineDropdownNode as a, MathTemplatedNode as o, ResponseAreaExtension as s } from "../extensions/responseArea.js";
|
|
5
|
+
import { MathNode as c } from "../extensions/math.js";
|
|
6
|
+
import { ImageUploadNode as l } from "../extensions/image.js";
|
|
7
|
+
import { Media as u } from "../extensions/media.js";
|
|
8
|
+
import { CSSMark as d } from "../extensions/css.js";
|
|
9
|
+
import { valueToSize as f } from "../utils/size.js";
|
|
10
|
+
import p from "./TiptapContainer.js";
|
|
11
|
+
import { PLUGINS_MAP as m, buildExtensions as h } from "../extensions/index.js";
|
|
12
|
+
import { useEffect as g, useMemo as _, useState as v } from "react";
|
|
13
|
+
import y from "lodash-es/debounce.js";
|
|
14
|
+
import { EditorContent as b, useEditor as x, useEditorState as S } from "@tiptap/react";
|
|
15
|
+
import { styled as C } from "@mui/material/styles";
|
|
16
|
+
import w from "@tiptap/starter-kit";
|
|
17
|
+
import { TextStyleKit as T } from "@tiptap/extension-text-style";
|
|
18
|
+
import { CharacterCount as E } from "@tiptap/extension-character-count";
|
|
19
|
+
import D from "@tiptap/extension-superscript";
|
|
20
|
+
import O from "@tiptap/extension-subscript";
|
|
21
|
+
import k from "@tiptap/extension-text-align";
|
|
22
|
+
import A from "@tiptap/extension-image";
|
|
23
|
+
import j from "@tiptap/extension-placeholder";
|
|
24
|
+
import { TableRow as M } from "@tiptap/extension-table-row";
|
|
25
|
+
import { TableCell as N } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as P } from "@tiptap/extension-table-header";
|
|
27
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
28
|
+
//#region src/components/EditableHtml.tsx
|
|
29
|
+
var I = {
|
|
30
|
+
position: "bottom",
|
|
31
|
+
alignment: "left",
|
|
32
|
+
alwaysVisible: !1,
|
|
33
|
+
showDone: !0,
|
|
34
|
+
doneOn: "blur"
|
|
35
|
+
}, L = [
|
|
36
|
+
"bold",
|
|
37
|
+
"italic",
|
|
38
|
+
"underline",
|
|
39
|
+
"strikethrough",
|
|
40
|
+
"code",
|
|
41
|
+
"bulleted-list",
|
|
42
|
+
"numbered-list",
|
|
43
|
+
"image",
|
|
44
|
+
"math",
|
|
45
|
+
"languageCharacters",
|
|
46
|
+
"text-align",
|
|
47
|
+
"table",
|
|
48
|
+
"video",
|
|
49
|
+
"audio",
|
|
50
|
+
"responseArea",
|
|
51
|
+
"superscript",
|
|
52
|
+
"subscript",
|
|
53
|
+
"css",
|
|
54
|
+
"h3",
|
|
55
|
+
"undo",
|
|
56
|
+
"redo"
|
|
57
|
+
], R = {
|
|
58
|
+
"--white": "#fff",
|
|
59
|
+
"--black": "#2e2b29",
|
|
60
|
+
"--black-contrast": "#110f0e",
|
|
61
|
+
"--gray-1": "rgba(61, 37, 20, .05)",
|
|
62
|
+
"--gray-2": "rgba(61, 37, 20, .08)",
|
|
63
|
+
"--gray-3": "rgba(61, 37, 20, .12)",
|
|
64
|
+
"--gray-4": "rgba(53, 38, 28, .3)",
|
|
65
|
+
"--gray-5": "rgba(28, 25, 23, .6)",
|
|
66
|
+
"--green": "#22c55e",
|
|
67
|
+
"--purple": "#6a00f5",
|
|
68
|
+
"--purple-contrast": "#5800cc",
|
|
69
|
+
"--purple-light": "rgba(88, 5, 255, .05)",
|
|
70
|
+
"--yellow-contrast": "#facc15",
|
|
71
|
+
"--yellow": "rgba(250, 204, 21, .4)",
|
|
72
|
+
"--yellow-light": "#fffae5",
|
|
73
|
+
"--red": "#ff5c33",
|
|
74
|
+
"--red-light": "#ffebe5",
|
|
75
|
+
"--shadow": "0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)"
|
|
76
|
+
}, z = (b) => {
|
|
77
|
+
let { showParagraphs: C, separateParagraphs: z } = b.pluginProps || {}, [V, H] = v([]), [U, W] = v(!1), { toolbarOpts: G } = b, K = {
|
|
78
|
+
...I,
|
|
79
|
+
...G
|
|
80
|
+
}, q = _(() => {
|
|
81
|
+
let { customPlugins: e, ...t } = b.pluginProps || {};
|
|
82
|
+
e ||= [];
|
|
83
|
+
let n = (b.activePlugins || L)?.filter((e) => {
|
|
84
|
+
let n = t[m[e] || e] || {};
|
|
85
|
+
return !n || !n.disabled;
|
|
86
|
+
});
|
|
87
|
+
return h(n, e, {
|
|
88
|
+
math: {},
|
|
89
|
+
textAlign: b.textAlign,
|
|
90
|
+
html: {},
|
|
91
|
+
extraCSSRules: b.extraCSSRules || {},
|
|
92
|
+
image: { ...b.imageSupport },
|
|
93
|
+
toolbar: {},
|
|
94
|
+
table: {},
|
|
95
|
+
responseArea: { type: b.responseAreaProps?.type },
|
|
96
|
+
languageCharacters: b.languageCharactersProps,
|
|
97
|
+
keyPadCharacterRef: {},
|
|
98
|
+
setKeypadInteraction: {},
|
|
99
|
+
media: {}
|
|
100
|
+
});
|
|
101
|
+
}, [b]), J = x({
|
|
102
|
+
extensions: [
|
|
103
|
+
k.configure({
|
|
104
|
+
types: [
|
|
105
|
+
"heading",
|
|
106
|
+
"paragraph",
|
|
107
|
+
"div",
|
|
108
|
+
"h1",
|
|
109
|
+
"h2",
|
|
110
|
+
"h3",
|
|
111
|
+
"h4",
|
|
112
|
+
"h5",
|
|
113
|
+
"h6",
|
|
114
|
+
"td",
|
|
115
|
+
"th"
|
|
116
|
+
],
|
|
117
|
+
alignments: [
|
|
118
|
+
"left",
|
|
119
|
+
"right",
|
|
120
|
+
"center",
|
|
121
|
+
"justify"
|
|
122
|
+
]
|
|
123
|
+
}),
|
|
124
|
+
T,
|
|
125
|
+
E.configure({ limit: b.charactersLimit || 1e6 }),
|
|
126
|
+
w.configure({ trailingNode: {
|
|
127
|
+
node: "paragraph",
|
|
128
|
+
notAfter: ["paragraph", "div"]
|
|
129
|
+
} }),
|
|
130
|
+
n,
|
|
131
|
+
j.configure({
|
|
132
|
+
placeholder: b.placeholder,
|
|
133
|
+
showOnlyWhenEditable: !0,
|
|
134
|
+
showOnlyCurrent: !1,
|
|
135
|
+
includeChildren: !0
|
|
136
|
+
}),
|
|
137
|
+
t,
|
|
138
|
+
M,
|
|
139
|
+
P,
|
|
140
|
+
N,
|
|
141
|
+
s.configure(b.responseAreaProps),
|
|
142
|
+
i.configure(b.responseAreaProps),
|
|
143
|
+
r.configure(b.responseAreaProps),
|
|
144
|
+
a.configure(b.responseAreaProps),
|
|
145
|
+
o.configure(b.responseAreaProps),
|
|
146
|
+
c.configure({ toolbarOpts: K }),
|
|
147
|
+
O,
|
|
148
|
+
D,
|
|
149
|
+
A,
|
|
150
|
+
l.configure({
|
|
151
|
+
toolbarOpts: K,
|
|
152
|
+
imageHandling: {
|
|
153
|
+
disableImageAlignmentButtons: b.disableImageAlignmentButtons,
|
|
154
|
+
onDone: () => b.onDone?.(J.getHTML()),
|
|
155
|
+
onDelete: b.imageSupport && b.imageSupport.delete && ((e) => {
|
|
156
|
+
let { src: t } = e.attrs;
|
|
157
|
+
b.imageSupport.delete(t, (t) => {
|
|
158
|
+
let n = V.filter((t) => t.key !== e.key), r = {
|
|
159
|
+
pendingImages: n,
|
|
160
|
+
scheduled: U && n.length === 0 ? !1 : U
|
|
161
|
+
};
|
|
162
|
+
H(r.pendingImages), W(r.scheduled);
|
|
163
|
+
});
|
|
164
|
+
}),
|
|
165
|
+
insertImageRequested: b.imageSupport && ((e, t) => {
|
|
166
|
+
let n = (t) => {
|
|
167
|
+
let n;
|
|
168
|
+
U && t && (n = b.onChange);
|
|
169
|
+
let r = V.filter((t) => t.key !== e.key), i = { pendingImages: r };
|
|
170
|
+
r.length === 0 && (i.scheduled = !1), H(i.pendingImages), W(i.scheduled), n?.(J.getHTML());
|
|
171
|
+
}, r = () => {
|
|
172
|
+
let e = t(n);
|
|
173
|
+
b.imageSupport.add(e);
|
|
174
|
+
};
|
|
175
|
+
H([...V, e]), r();
|
|
176
|
+
}),
|
|
177
|
+
maxImageWidth: b.maxImageWidth,
|
|
178
|
+
maxImageHeight: b.maxImageHeight
|
|
179
|
+
},
|
|
180
|
+
limit: 3
|
|
181
|
+
}),
|
|
182
|
+
u.configure({ uploadSoundSupport: b.uploadSoundSupport }),
|
|
183
|
+
d.configure({ extraCSSRules: b.extraCSSRules })
|
|
184
|
+
],
|
|
185
|
+
immediatelyRender: !1,
|
|
186
|
+
editorProps: { handleKeyDown(e, t) {
|
|
187
|
+
return b.onKeyDown ? b.onKeyDown(t) : !1;
|
|
188
|
+
} },
|
|
189
|
+
editable: !b.disabled,
|
|
190
|
+
content: e(b.markup),
|
|
191
|
+
onUpdate: ({ editor: e, transaction: t }) => {
|
|
192
|
+
t.isDone && b.onChange?.(e.getHTML());
|
|
193
|
+
},
|
|
194
|
+
onBlur: y(({ editor: e }) => {
|
|
195
|
+
e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response") || (b.markup !== e.getHTML() && b.onChange?.(e.getHTML()), K.doneOn === "blur" && b.onDone?.(e.getHTML()));
|
|
196
|
+
}, 200)
|
|
197
|
+
}, [b.charactersLimit]);
|
|
198
|
+
g(() => {
|
|
199
|
+
b.editorRef && b.editorRef(J);
|
|
200
|
+
}, [b.editorRef, J]), g(() => {
|
|
201
|
+
J?.setEditable(!b.disabled);
|
|
202
|
+
}, [b.disabled, J]), g(() => {
|
|
203
|
+
if (!J) return;
|
|
204
|
+
let t = e(b.markup);
|
|
205
|
+
t !== J.getHTML() && J.commands.setContent(t, !1);
|
|
206
|
+
}, [b.markup, J]), g(() => {
|
|
207
|
+
Object.entries(R).forEach(([e, t]) => {
|
|
208
|
+
document.documentElement.style.setProperty(e, t);
|
|
209
|
+
});
|
|
210
|
+
}, []);
|
|
211
|
+
let Y = S({
|
|
212
|
+
editor: J,
|
|
213
|
+
selector: (e) => ({ isFocused: e.editor?.isFocused })
|
|
214
|
+
}), X = _(() => {
|
|
215
|
+
let { minWidth: e, width: t, maxWidth: n, minHeight: r, height: i, maxHeight: a } = b;
|
|
216
|
+
return {
|
|
217
|
+
width: f(t),
|
|
218
|
+
minWidth: f(e),
|
|
219
|
+
maxWidth: f(n),
|
|
220
|
+
height: f(i),
|
|
221
|
+
minHeight: f(r),
|
|
222
|
+
maxHeight: f(a)
|
|
223
|
+
};
|
|
224
|
+
}, [b]);
|
|
225
|
+
return /* @__PURE__ */ F(p, {
|
|
226
|
+
...b,
|
|
227
|
+
activePlugins: q,
|
|
228
|
+
toolbarOpts: K,
|
|
229
|
+
editorState: Y,
|
|
230
|
+
editor: J,
|
|
231
|
+
children: J && /* @__PURE__ */ F(B, {
|
|
232
|
+
style: {
|
|
233
|
+
minHeight: X.minHeight,
|
|
234
|
+
height: X.height,
|
|
235
|
+
maxHeight: X.maxHeight
|
|
236
|
+
},
|
|
237
|
+
showParagraph: C && !C.disabled,
|
|
238
|
+
separateParagraph: z && !z.disabled,
|
|
239
|
+
editor: J
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
}, B = C(b, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
|
|
243
|
+
display: "flex",
|
|
244
|
+
outline: "none !important",
|
|
245
|
+
"& .ProseMirror": {
|
|
246
|
+
flex: 1,
|
|
247
|
+
padding: "5px",
|
|
248
|
+
maxHeight: "500px",
|
|
249
|
+
outline: "none !important",
|
|
250
|
+
position: "initial",
|
|
251
|
+
"& > p, & > div": { margin: "0" },
|
|
252
|
+
"& p.is-editor-empty:first-child::before, & div.is-editor-empty:first-child::before": {
|
|
253
|
+
content: "attr(data-placeholder)",
|
|
254
|
+
float: "left",
|
|
255
|
+
height: 0,
|
|
256
|
+
color: "#9CA3AF",
|
|
257
|
+
pointerEvents: "none",
|
|
258
|
+
whiteSpace: "pre-wrap"
|
|
259
|
+
},
|
|
260
|
+
...e && { "& > p:has(+ p)::after, & > div:has(+ div)::after": {
|
|
261
|
+
display: "block",
|
|
262
|
+
content: "\"¶\"",
|
|
263
|
+
fontSize: "1em",
|
|
264
|
+
color: "#146EB3"
|
|
265
|
+
} },
|
|
266
|
+
...t && { "& > div:has(+ div)": { marginBottom: "1em" } }
|
|
267
|
+
}
|
|
268
|
+
}));
|
|
269
|
+
//#endregion
|
|
270
|
+
export { z as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/editable-html-tip-tap/src/components/MenuBar.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 const StyledMenuBar: (props: any) => JSX.Element;
|
|
10
|
+
export default StyledMenuBar;
|
|
11
|
+
//# sourceMappingURL=MenuBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuBar.d.ts","sourceRoot":"","sources":["../../src/components/MenuBar.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AA4aH,QAAA,MAAM,aAAa,GAAI,UAAK,gBA4B3B,CAAC;AA6FF,eAAe,aAAa,CAAC"}
|