lexxy 0.1.17.beta → 0.1.19.beta

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4110accda8b3076f07bc48ae4d079733e7972198cd2b8c6801073b99a2af27a1
4
- data.tar.gz: b3a5df5347125312a746dbc4d1a2ad961f642cd1506abcb7610a3eafd70588a9
3
+ metadata.gz: 0edf37852f38dc8deb59194838075da7752d5a54fa8d56e3d483b640d2afb950
4
+ data.tar.gz: 61e0232d676d0358fc605e56d494bf981c38ba6586f9901b2eea77d51d5415f4
5
5
  SHA512:
6
- metadata.gz: c06e2386dcd78237df5381b138511dfe40d23240fb222ce5610e58cd505002a2561f435350f2fd250af0624b6f1fba2a15d5c0a9c554b8f9d3aa78e8435c34c5
7
- data.tar.gz: 974cb1bd0ae568f224f006a37d98ba4bcc5a2c4dcd718f91027cbab9b045c6479a939b321fd0704ceecfcd38b76f7095733246efcdb6cb89a827836963d1270e
6
+ metadata.gz: 8d68a219385971dd5cead807b78144911ab3fc89224d5493cc3706e4ecca0ce2cbf965966ab016c4bfa872c234be5c1d5be9e12fc9e273a561b7324a47f0bb11
7
+ data.tar.gz: 7f70f60e226d2dc13d29aa754a0b04ad54c784c1d66785a5754848a1cafe0e5f5d7553b727c581637e8c60faba6cd087e2fa18d68bb59d2cf18ebb556df382f9
@@ -5869,6 +5869,10 @@ class ActionTextAttachmentUploadNode extends ActionTextAttachmentNode {
5869
5869
  return new ActionTextAttachmentUploadNode({ ...node }, node.__key)
5870
5870
  }
5871
5871
 
5872
+ static importJSON(serializedNode) {
5873
+ return new ActionTextAttachmentUploadNode({ ...serializedNode })
5874
+ }
5875
+
5872
5876
  constructor({ file, uploadUrl, blobUrlTemplate, editor, progress }, key) {
5873
5877
  super({ contentType: file.type }, key);
5874
5878
  this.file = file;
@@ -5908,6 +5912,17 @@ class ActionTextAttachmentUploadNode extends ActionTextAttachmentNode {
5908
5912
  return { element: img }
5909
5913
  }
5910
5914
 
5915
+ exportJSON() {
5916
+ return {
5917
+ type: "action_text_attachment_upload",
5918
+ version: 1,
5919
+ progress: this.progress,
5920
+ uploadUrl: this.uploadUrl,
5921
+ blobUrlTemplate: this.blobUrlTemplate,
5922
+ ...super.exportJSON()
5923
+ }
5924
+ }
5925
+
5911
5926
  #createDOMForImage() {
5912
5927
  return createElement("img")
5913
5928
  }
@@ -6774,22 +6789,24 @@ class Selection {
6774
6789
  const node = this.nodeAfterCursor;
6775
6790
  if (node instanceof ki) {
6776
6791
  this.#selectInLexical(node);
6792
+ return true
6777
6793
  } else {
6778
6794
  this.#contents.deleteSelectedNodes();
6779
6795
  }
6780
6796
 
6781
- return true
6797
+ return false
6782
6798
  }
6783
6799
 
6784
6800
  #deletePreviousOrNext() {
6785
6801
  const node = this.nodeBeforeCursor;
6786
6802
  if (node instanceof ki) {
6787
6803
  this.#selectInLexical(node);
6804
+ return true
6788
6805
  } else {
6789
6806
  this.#contents.deleteSelectedNodes();
6790
6807
  }
6791
6808
 
6792
- return true
6809
+ return false
6793
6810
  }
6794
6811
 
6795
6812
  #getValidSelectionRange() {
@@ -7401,10 +7418,10 @@ class Contents {
7401
7418
  const selection = Lr();
7402
7419
  if (!yr(selection)) return
7403
7420
 
7404
- const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow();
7421
+ const topLevelElement = selection.anchor.getNode().getTopLevelElement();
7405
7422
 
7406
7423
  // Check if format is already applied
7407
- if (isFormatAppliedFn(topLevelElement)) {
7424
+ if (topLevelElement && isFormatAppliedFn(topLevelElement)) {
7408
7425
  this.#unwrap(topLevelElement);
7409
7426
  } else {
7410
7427
  this.#insertNodeWrappingAllSelectedNodes(newNodeFn);
@@ -7634,10 +7651,7 @@ class Contents {
7634
7651
  const node = xo(nodeKey);
7635
7652
  if (!node) return
7636
7653
 
7637
- let previousNode = node;
7638
- try {
7639
- previousNode = node.getTopLevelElementOrThrow();
7640
- } catch {}
7654
+ const previousNode = node.getTopLevelElement() || node;
7641
7655
 
7642
7656
  const newNode = options.attachment ? this.#createCustomAttachmentNodeWithHtml(html, options.attachment) : this.#createHtmlNodeWith(html);
7643
7657
  previousNode.insertAfter(newNode);
@@ -7664,16 +7678,21 @@ class Contents {
7664
7678
  if (!yr(selection)) return
7665
7679
 
7666
7680
  const selectedNodes = selection.extract();
7667
- if (selectedNodes.length === 0) return
7668
-
7681
+ if (selectedNodes.length === 0) {
7682
+ return
7683
+ }
7669
7684
  const topLevelElements = new Set();
7670
7685
  selectedNodes.forEach((node) => {
7671
7686
  const topLevel = node.getTopLevelElementOrThrow();
7672
7687
  topLevelElements.add(topLevel);
7673
7688
  });
7674
7689
 
7675
- const elements = this.#removeTrailingEmptyParagraphs(Array.from(topLevelElements));
7676
- if (elements.length === 0) return
7690
+ const elements = this.#withoutTrailingEmptyParagraphs(Array.from(topLevelElements));
7691
+ if (elements.length === 0) {
7692
+ this.#removeStandaloneEmptyParagraph();
7693
+ this.insertAtCursor(newNodeFn());
7694
+ return
7695
+ }
7677
7696
 
7678
7697
  const wrappingNode = newNodeFn();
7679
7698
  elements[0].insertBefore(wrappingNode);
@@ -7685,7 +7704,7 @@ class Contents {
7685
7704
  });
7686
7705
  }
7687
7706
 
7688
- #removeTrailingEmptyParagraphs(elements) {
7707
+ #withoutTrailingEmptyParagraphs(elements) {
7689
7708
  let lastNonEmptyIndex = elements.length - 1;
7690
7709
 
7691
7710
  // Find the last non-empty paragraph
@@ -7709,6 +7728,16 @@ class Contents {
7709
7728
  return children.length === 0 || children.every(child => jn(child))
7710
7729
  }
7711
7730
 
7731
+ #removeStandaloneEmptyParagraph() {
7732
+ const root = No();
7733
+ if (root.getChildrenSize() === 1) {
7734
+ const firstChild = root.getFirstChild();
7735
+ if (firstChild && Ii(firstChild) && this.#isElementEmpty(firstChild)) {
7736
+ firstChild.remove();
7737
+ }
7738
+ }
7739
+ }
7740
+
7712
7741
  #insertNodeWrappingAllSelectedLines(newNodeFn) {
7713
7742
  this.editor.update(() => {
7714
7743
  const selection = Lr();
Binary file
Binary file