lexxy 0.9.7.beta → 0.9.8.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: d626ffd428a2d550fb3439d9ee89e2e71a86f6bdaa3a990d5c5f8954394e5529
4
- data.tar.gz: 98f0d3b26df745b0a6477e508de91bf2f9be89c079fccf3f3d53648c92d311b6
3
+ metadata.gz: 35be558d191256d60a92fd727768d719247399dfa0f017d54560a4a7eb775666
4
+ data.tar.gz: 3f568f51b50c2cf790aa0ae1803dcd6350e22c9a09a354f0048473df1b41e831
5
5
  SHA512:
6
- metadata.gz: 286a01f5de6b3d69347a1a40f54709718e245c4de7f3cca176635a2acb44fcea5e19d78f5fac1b9aaef66c1671d920073700c28918350d3d62f20e71931fa6dd
7
- data.tar.gz: 0003b9f77dc7c231067a69ca758626941df4cec24393d3f897b6705b3526e5e8260f290f9fa8591bf7a3d982e4fac3e2033a9aaa16ce33b9665a60f2d4f9c4fd
6
+ metadata.gz: bf76840177aee96461993510ebce333a632b8c8781a81ed973ee9231d29b63817e3a22e0f7be73c1175f1868e4d7d5bf1a23dd506f2fc1c3c2e0df0a7f360634
7
+ data.tar.gz: b87a831bc8e1d4ec5a558ea3df22a19ea0c9fda29d3e7dde772aaffb31202f1746810ad8b029f59310e4a6722ff4a1d017394a47accf208e247535ebd314d59e
@@ -8921,14 +8921,24 @@ function normalizeFilteredText(string) {
8921
8921
  .normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove diacritics
8922
8922
  }
8923
8923
 
8924
- function filterMatches(text, potentialMatch) {
8925
- return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch))
8924
+ function filterMatchPosition(text, potentialMatch) {
8925
+ const normalizedText = normalizeFilteredText(text);
8926
+ const normalizedMatch = normalizeFilteredText(potentialMatch);
8927
+
8928
+ if (!normalizedMatch) return 0
8929
+
8930
+ const match = normalizedText.match(new RegExp(`(?:^|\\b)${escapeForRegExp(normalizedMatch)}`));
8931
+ return match ? match.index : -1
8926
8932
  }
8927
8933
 
8928
8934
  function upcaseFirst(string) {
8929
8935
  return string.charAt(0).toUpperCase() + string.slice(1)
8930
8936
  }
8931
8937
 
8938
+ function escapeForRegExp(string) {
8939
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
8940
+ }
8941
+
8932
8942
  // Parses a value that may arrive as a boolean or as a string (e.g. from DOM
8933
8943
  // getAttribute) into a proper boolean. Ensures "false" doesn't evaluate as truthy.
8934
8944
  function parseBoolean(value) {
@@ -13821,7 +13831,7 @@ class LinkDropdown extends ToolbarDropdown {
13821
13831
  get #selectedLinkUrl() {
13822
13832
  return this.editor.getEditorState().read(() => {
13823
13833
  const linkNode = this.editorElement.selection.nearestNodeOfType(M$5);
13824
- return linkNode?.getUrl() ?? null
13834
+ return linkNode?.getURL() ?? ""
13825
13835
  })
13826
13836
  }
13827
13837
  }
@@ -13985,21 +13995,41 @@ class LocalFilterSource extends BaseSource {
13985
13995
  }
13986
13996
 
13987
13997
  #buildListItemsFromPromptItems(promptItems, filter) {
13988
- const listItems = [];
13989
13998
  this.promptItemByListItem = new WeakMap();
13990
13999
 
13991
- for (const promptItem of promptItems) {
13992
- if (listItems.length >= MAX_RENDERED_SUGGESTIONS$1) break
14000
+ if (!filter) {
14001
+ return this.#buildAllListItems(promptItems)
14002
+ }
13993
14003
 
14004
+ const matches = [];
14005
+ for (const promptItem of promptItems) {
13994
14006
  const searchableText = promptItem.getAttribute("search");
13995
-
13996
- if (!filter || filterMatches(searchableText, filter)) {
13997
- const listItem = this.buildListItemElementFor(promptItem);
13998
- this.promptItemByListItem.set(listItem, promptItem);
13999
- listItems.push(listItem);
14007
+ const position = filterMatchPosition(searchableText, filter);
14008
+ if (position >= 0) {
14009
+ matches.push({ promptItem, position });
14000
14010
  }
14001
14011
  }
14002
14012
 
14013
+ matches.sort((a, b) => a.position - b.position);
14014
+
14015
+ const listItems = [];
14016
+ for (const { promptItem } of matches) {
14017
+ if (listItems.length >= MAX_RENDERED_SUGGESTIONS$1) break
14018
+ const listItem = this.buildListItemElementFor(promptItem);
14019
+ this.promptItemByListItem.set(listItem, promptItem);
14020
+ listItems.push(listItem);
14021
+ }
14022
+ return listItems
14023
+ }
14024
+
14025
+ #buildAllListItems(promptItems) {
14026
+ const listItems = [];
14027
+ for (const promptItem of promptItems) {
14028
+ if (listItems.length >= MAX_RENDERED_SUGGESTIONS$1) break
14029
+ const listItem = this.buildListItemElementFor(promptItem);
14030
+ this.promptItemByListItem.set(listItem, promptItem);
14031
+ listItems.push(listItem);
14032
+ }
14003
14033
  return listItems
14004
14034
  }
14005
14035
  }
Binary file
Binary file