lexxy 0.9.14.beta → 0.9.15.alpha.1

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: a6400fe4f84e273a2028af153efe203474e103a0f507d1b72ddd4096ed292e52
4
- data.tar.gz: a2f2ca9843421ea5a9fba94b22da2d95c218e5c96744d7f182ed471efdcb5556
3
+ metadata.gz: 2d9a254f888998ed62a3d7af0cbf6644a0b82fde3ca02d0eefc604c512e12ba9
4
+ data.tar.gz: b0d14ac32727c31eaf0709f16f178ad1056d38e30959141ef3e8b2cbb3f170fe
5
5
  SHA512:
6
- metadata.gz: 5ca317b2a76ab77e177c30113c9568eea2a035a472ee465c4aa479948e9e74e1ebed7354e61a62438bc66a7d079d80df625038d8d4da815bcc31205a022c1726
7
- data.tar.gz: 9cfe9d96efcbda91237d913f6a07df984390d012a97644534a74aff6175fdabdb6820944e70a4614f747e1975b9726f82548c1ae6dd95b5da33d4a44d0511d75
6
+ metadata.gz: 3964a7317fdaf7ac44d2c31f546e073a13942bd3a3839be20f9a32a6159e4bc0daf7db35579a21fba551caaa4f136435be392ef70e99c3461eb40ccf3dfdb6c2
7
+ data.tar.gz: f3ea71f58d2a94b6226f9c0e4ace4b08f3ab0fb3d08eaff38159c38f736667661db6e60b0918d3e69a9563c89b244c1d8d3d5b052f8e7f0ea2da298d6011dc1d
@@ -7803,14 +7803,15 @@ function $isShadowRoot(node) {
7803
7803
  return Wi(node) && Is(node) && !Vi(node)
7804
7804
  }
7805
7805
 
7806
+ function $isSafeForRoot(node) {
7807
+ return (Wi(node) || ji(node)) && !node.isParentRequired()
7808
+ }
7809
+
7806
7810
  function $makeSafeForRoot(node) {
7807
- if (Tr(node)) {
7808
- return Tt$4(node, eo)
7809
- } else if (node.isParentRequired()) {
7810
- const parent = node.createRequiredParent();
7811
- return Tt$4(node, parent)
7812
- } else {
7811
+ if ($isSafeForRoot(node)) {
7813
7812
  return node
7813
+ } else {
7814
+ return Tt$4(node, () => node.createParentElementNode())
7814
7815
  }
7815
7816
  }
7816
7817
 
@@ -7925,6 +7926,39 @@ function $isListItemStructurallyEmpty(listItem) {
7925
7926
  return true
7926
7927
  }
7927
7928
 
7929
+ // Returns the document text up to `offset` inside `targetNode`. Non-inline
7930
+ // element siblings are joined with `\n\n`, matching Lexical's own
7931
+ // ElementNode.getTextContent behavior.
7932
+ function $textBeforeOffset(targetNode, offset) {
7933
+ const parts = [];
7934
+ let done = false;
7935
+
7936
+ function visit(node) {
7937
+ if (done) return
7938
+ if (node === targetNode) {
7939
+ parts.push(node.getTextContent().slice(0, offset));
7940
+ done = true;
7941
+ return
7942
+ }
7943
+ if (Wi(node)) {
7944
+ const children = node.getChildren();
7945
+ for (let i = 0; i < children.length; i++) {
7946
+ visit(children[i]);
7947
+ if (done) return
7948
+ const child = children[i];
7949
+ if (Wi(child) && !child.isInline() && i < children.length - 1) {
7950
+ parts.push("\n\n");
7951
+ }
7952
+ }
7953
+ } else {
7954
+ parts.push(node.getTextContent());
7955
+ }
7956
+ }
7957
+
7958
+ visit(Zo());
7959
+ return parts.join("")
7960
+ }
7961
+
7928
7962
  function isAttachmentSpacerTextNode(node, previousNode, index, childCount) {
7929
7963
  return Tr(node)
7930
7964
  && node.getTextContent() === " "
@@ -14950,6 +14984,9 @@ class RemoteFilterSource extends BaseSource {
14950
14984
  const NOTHING_FOUND_DEFAULT_MESSAGE = "Nothing found";
14951
14985
  const FILTER_DEBOUNCE_INTERVAL = 50;
14952
14986
 
14987
+ // Start of line, or after a space or newline.
14988
+ const DEFAULT_ONLY_AT_PATTERN = "^|[ \\n]";
14989
+
14953
14990
  class LexicalPromptElement extends HTMLElement {
14954
14991
  #globalListeners = new ListenerBin()
14955
14992
  #popoverListeners = new ListenerBin()
@@ -14995,6 +15032,10 @@ class LexicalPromptElement extends HTMLElement {
14995
15032
  return this.hasAttribute("supports-space-in-searches")
14996
15033
  }
14997
15034
 
15035
+ get onlyAt() {
15036
+ return this.getAttribute("only-at")
15037
+ }
15038
+
14998
15039
  get open() {
14999
15040
  return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible")
15000
15041
  }
@@ -15038,14 +15079,10 @@ class LexicalPromptElement extends HTMLElement {
15038
15079
  if (offset >= triggerLength) {
15039
15080
  const textBeforeCursor = fullText.slice(offset - triggerLength, offset);
15040
15081
 
15041
- // Check if trigger is at the start of the text node (new line case) or preceded by space or newline
15042
15082
  if (textBeforeCursor === this.trigger) {
15043
- const isAtStart = offset === triggerLength;
15044
-
15045
- const charBeforeTrigger = offset > triggerLength ? fullText[offset - triggerLength - 1] : null;
15046
- const isPrecededBySpaceOrNewline = charBeforeTrigger === " " || charBeforeTrigger === "\n";
15083
+ const textBeforeTrigger = $textBeforeOffset(node, offset - triggerLength);
15047
15084
 
15048
- if (isAtStart || isPrecededBySpaceOrNewline) {
15085
+ if (this.#onlyAtRegExp.test(textBeforeTrigger)) {
15049
15086
  this.#popoverListeners.dispose();
15050
15087
  this.#showPopover();
15051
15088
  }
@@ -15056,7 +15093,15 @@ class LexicalPromptElement extends HTMLElement {
15056
15093
  }));
15057
15094
  }
15058
15095
 
15096
+ get #onlyAtRegExp() {
15097
+ return new RegExp(`(?:${this.onlyAt ?? DEFAULT_ONLY_AT_PATTERN})$`)
15098
+ }
15099
+
15059
15100
  get #promptContentTypePermitted() {
15101
+ // `insert-editable-text` prompts never create attachments, so the
15102
+ // editor's attachment support and content-type allowlist don't apply.
15103
+ if (this.hasAttribute("insert-editable-text")) return true
15104
+
15060
15105
  const el = this.#editorElement;
15061
15106
  if (!el.supportsAttachments) {
15062
15107
  return false
Binary file
Binary file