@pie-element/inline-dropdown 10.1.2-next.4 → 10.1.2-next.6

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.
@@ -39,5 +39,6 @@ export default class InlineDropdown extends HTMLElement {
39
39
  insertSound(handler: any): void;
40
40
  onDeleteSound(src: any, done: any): void;
41
41
  _render(): void;
42
+ connectedCallback(): void;
42
43
  disconnectedCallback(): void;
43
44
  }
@@ -1,4 +1,4 @@
1
- import e from "./main.js";
1
+ import { Main as e } from "./main.js";
2
2
  import t from "./defaults.js";
3
3
  import { createSlateMarkup as n, processMarkup as r } from "./markupUtils.js";
4
4
  import i from "react";
@@ -75,8 +75,11 @@ var p = f("multiple-choice:configure"), m = class f extends HTMLElement {
75
75
  });
76
76
  this._root ||= a(this), this._root.render(t);
77
77
  }
78
+ connectedCallback() {
79
+ this._render();
80
+ }
78
81
  disconnectedCallback() {
79
- this._root && this._root.unmount();
82
+ this._root &&= (this._root.unmount(), null);
80
83
  }
81
84
  };
82
85
  //#endregion
@@ -39,6 +39,7 @@ declare class RespAreaToolbar extends React.Component {
39
39
  onSelectChoice: any;
40
40
  onRemoveChoice: any;
41
41
  onEditChoice: any;
42
+ finishEditing: any;
42
43
  onKeyDown: any;
43
44
  onBlur: any;
44
45
  onClickInside: any;
@@ -14,12 +14,12 @@ import m from "@mui/icons-material/Close";
14
14
  import h from "@mui/icons-material/Edit";
15
15
  import g from "@mui/material/IconButton";
16
16
  //#region src/author/inline-dropdown-toolbar.tsx
17
- var _ = u("div")(({ theme: e }) => ({
17
+ var _ = u("div")(() => ({
18
18
  display: "flex",
19
19
  alignItems: "flex-start",
20
20
  position: "relative",
21
- background: e.palette.common.white,
22
- borderBottom: `1px solid ${e.palette.grey[400]}`,
21
+ background: s.white(),
22
+ borderBottom: `1px solid ${s.border()}`,
23
23
  "&:last-child": { borderRadius: "0 0 4px 4px" }
24
24
  })), v = u("div")(({ theme: e }) => ({
25
25
  display: "flex",
@@ -138,11 +138,11 @@ var _ = u("div")(({ theme: e }) => ({
138
138
  componentDidMount() {
139
139
  let { editor: e } = this.props, t = e.view.nodeDOM(e.state.selection.from);
140
140
  if (t?.nodeType === 1) {
141
- let e = t.getBoundingClientRect(), n = t.closest(".tiptap").getBoundingClientRect(), r = e.top - e.height, i = e.left - n.left;
141
+ let e = t.getBoundingClientRect(), n = t.closest(".tiptap").getBoundingClientRect(), r = e.top - n.top, i = e.left - n.left;
142
142
  this.setState({ toolbarStyle: {
143
143
  position: "absolute",
144
- top: `${r + e.height + 40}px`,
145
- left: `${i + 25}px`
144
+ top: `${r + e.height + 25}px`,
145
+ left: `${i}px`
146
146
  } });
147
147
  }
148
148
  }
@@ -183,13 +183,11 @@ var _ = u("div")(({ theme: e }) => ({
183
183
  }
184
184
  this.onRespAreaChange(e), this.setState({ editedChoiceIndex: t });
185
185
  };
186
- onKeyDown = (e) => {
187
- if (e.key === "Enter") {
188
- let e = this.editorRef.getHTML() || "";
189
- return this.onDone(e), this.preventDone = !0, !0;
190
- }
191
- return !1;
186
+ finishEditing = () => {
187
+ let e = this.editorRef.getHTML() || "";
188
+ this.onDone(e), this.preventDone = !0;
192
189
  };
190
+ onKeyDown = (e) => e.key === "Enter" ? (this.finishEditing(), !0) : !1;
193
191
  onBlur = () => {
194
192
  if (this.clickedInside) {
195
193
  this.clickedInside = !1;
@@ -206,13 +204,13 @@ var _ = u("div")(({ theme: e }) => ({
206
204
  this.clickedInside = !0;
207
205
  };
208
206
  render() {
209
- let { choices: t, spellCheck: n, uploadSoundSupport: r, mathMlOptions: i = {}, baseInputConfiguration: a = {}, responseAreaInputConfiguration: o = {} } = this.props, { respAreaMarkup: s, toolbarStyle: u } = this.state;
210
- return u ? /* @__PURE__ */ l(w, {
207
+ let { choices: t, spellCheck: n, uploadSoundSupport: r, mathMlOptions: i = {}, baseInputConfiguration: a = {}, responseAreaInputConfiguration: o = {} } = this.props, { respAreaMarkup: u, toolbarStyle: d, editedChoiceIndex: m } = this.state;
208
+ return d ? /* @__PURE__ */ l(w, {
211
209
  "data-inline-dropdown-toolbar": "",
212
210
  style: {
213
- ...u,
214
- backgroundColor: "#E0E1E6",
215
- zIndex: 1
211
+ ...d,
212
+ backgroundColor: s.dropdownBackground(),
213
+ zIndex: 999
216
214
  },
217
215
  onMouseDown: this.onClickInside,
218
216
  children: [/* @__PURE__ */ l(O, { children: [/* @__PURE__ */ c(T, {
@@ -227,7 +225,7 @@ var _ = u("div")(({ theme: e }) => ({
227
225
  showDone: !1,
228
226
  doneOn: "blur"
229
227
  },
230
- markup: s,
228
+ markup: u,
231
229
  onKeyDown: this.onKeyDown,
232
230
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
233
231
  onChange: (e) => {
@@ -250,10 +248,10 @@ var _ = u("div")(({ theme: e }) => ({
250
248
  uploadSoundSupport: r,
251
249
  mathMlOptions: i
252
250
  }), /* @__PURE__ */ c(E, {
253
- onClick: () => this.onAddChoice(),
251
+ onClick: () => m >= 0 ? this.finishEditing() : this.onAddChoice(),
254
252
  size: "small",
255
253
  "aria-label": "Add",
256
- children: /* @__PURE__ */ c(f, { fontSize: "inherit" })
254
+ children: c(m >= 0 ? p : f, { fontSize: "inherit" })
257
255
  })] }), t && /* @__PURE__ */ c(D, { children: t.map(({ label: e, correct: t }, n) => /* @__PURE__ */ c(S, {
258
256
  onClick: () => this.onSelectChoice(e, n),
259
257
  onRemoveChoice: () => this.onRemoveChoice(e, n),
@@ -376,4 +376,4 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
376
376
  }
377
377
  };
378
378
  //#endregion
379
- export { I as default };
379
+ export { I as Main, I as default };
@@ -20,4 +20,4 @@ var t = "imes|riangle|an|heta|herefore", n = "throot|parallel|cong|approx|eq|e|s
20
20
  return r.replace(s, (e, t) => a(t));
21
21
  };
22
22
  //#endregion
23
- export { c as createSlateMarkup, o as processMarkup };
23
+ export { a as createElementFromHTML, c as createSlateMarkup, o as processMarkup, i as removeUnwantedCharacters };