mce 0.15.9 → 0.15.11

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/index.js CHANGED
@@ -2365,7 +2365,7 @@ const _4_1_text = defineMixin((editor) => {
2365
2365
  return false;
2366
2366
  });
2367
2367
  }
2368
- function handleSelection([start, end], cb) {
2368
+ function handleTextSelection([start, end], cb) {
2369
2369
  let flag = true;
2370
2370
  element.value?.text?.content.forEach((p, pIndex, pItems) => {
2371
2371
  if (!flag)
@@ -2402,7 +2402,7 @@ const _4_1_text = defineMixin((editor) => {
2402
2402
  if (hasTextSelectionRange.value) {
2403
2403
  const selection = textSelection.value;
2404
2404
  if (selection && selection[0] && selection[1]) {
2405
- handleSelection(selection, ({ selected, fStyle }) => {
2405
+ handleTextSelection(selection, ({ selected, fStyle }) => {
2406
2406
  if (selected && fStyle[key]) {
2407
2407
  value = fStyle[key];
2408
2408
  return false;
@@ -2434,7 +2434,7 @@ const _4_1_text = defineMixin((editor) => {
2434
2434
  const newContent = [];
2435
2435
  let newParagraph = { fragments: [] };
2436
2436
  let newFragment;
2437
- handleSelection(textSelection.value, ({ selected, fIndex, fStyle, fLength, c, cIndex, cLength }) => {
2437
+ handleTextSelection(textSelection.value, ({ selected, fIndex, fStyle, fLength, c, cIndex, cLength }) => {
2438
2438
  if (fIndex === 0 && cIndex === 0) {
2439
2439
  newParagraph = { fragments: [] };
2440
2440
  newFragment = void 0;
@@ -2558,6 +2558,7 @@ const _4_1_text = defineMixin((editor) => {
2558
2558
  Object.assign(editor, {
2559
2559
  hasTextSelectionRange,
2560
2560
  isTextAllSelected,
2561
+ handleTextSelection,
2561
2562
  textFontSizeToFit,
2562
2563
  textToFit,
2563
2564
  setTextStyle,
@@ -2921,9 +2922,15 @@ const _4_4_doc = defineMixin((editor, options) => {
2921
2922
  return _doc;
2922
2923
  };
2923
2924
  const loadDoc = async (source) => {
2924
- const _doc = await setDoc(await load(source));
2925
- emit("loadDoc", _doc, source);
2926
- return _doc;
2925
+ emit("docLoading", source);
2926
+ try {
2927
+ const _doc = await setDoc(await load(source));
2928
+ emit("docLoaded", source, _doc);
2929
+ return _doc;
2930
+ } catch (err) {
2931
+ emit("docLoaded", source, err);
2932
+ throw err;
2933
+ }
2927
2934
  };
2928
2935
  Object.assign(editor, {
2929
2936
  getDoc,
@@ -5172,7 +5179,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
5172
5179
  if (node.foreground.isValid() && node.foreground.image) {
5173
5180
  value = t("image");
5174
5181
  } else if (node.text.isValid()) {
5175
- value = node.text.getStringContent();
5182
+ value = node.text.innerText;
5176
5183
  }
5177
5184
  }
5178
5185
  }
@@ -6,6 +6,7 @@ declare global {
6
6
  interface Editor {
7
7
  hasTextSelectionRange: Ref<boolean>;
8
8
  isTextAllSelected: Ref<boolean>;
9
+ handleTextSelection: (textSelection: IndexCharacter[], cb: (arg: Record<string, any>) => boolean) => void;
9
10
  textFontSizeToFit: (element: Element2D, scale?: number) => void;
10
11
  textToFit: (element: Element2D, typography?: Mce.TypographyStrategy) => void;
11
12
  getTextStyle: (key: string) => any;
@@ -21,7 +21,8 @@ declare global {
21
21
  }
22
22
  interface Events {
23
23
  setDoc: [doc: Doc];
24
- loadDoc: [doc: Doc, source: any];
24
+ docLoading: [source: any];
25
+ docLoaded: [source: any, doc: Doc | Error];
25
26
  clearDoc: [];
26
27
  updateDoc: [update: Uint8Array, origin: any];
27
28
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.15.9",
4
+ "version": "0.15.11",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "diff": "^8.0.2",
62
62
  "file-saver": "^2.0.5",
63
63
  "lodash-es": "^4.17.22",
64
- "modern-canvas": "^0.14.24",
64
+ "modern-canvas": "^0.14.25",
65
65
  "modern-font": "^0.4.4",
66
66
  "modern-idoc": "^0.10.8",
67
67
  "modern-text": "^1.10.7",