@37signals/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.
- package/dist/lexxy.esm.js +41 -11
- package/package.json +1 -1
package/dist/lexxy.esm.js
CHANGED
|
@@ -2542,14 +2542,24 @@ function normalizeFilteredText(string) {
|
|
|
2542
2542
|
.normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove diacritics
|
|
2543
2543
|
}
|
|
2544
2544
|
|
|
2545
|
-
function
|
|
2546
|
-
|
|
2545
|
+
function filterMatchPosition(text, potentialMatch) {
|
|
2546
|
+
const normalizedText = normalizeFilteredText(text);
|
|
2547
|
+
const normalizedMatch = normalizeFilteredText(potentialMatch);
|
|
2548
|
+
|
|
2549
|
+
if (!normalizedMatch) return 0
|
|
2550
|
+
|
|
2551
|
+
const match = normalizedText.match(new RegExp(`(?:^|\\b)${escapeForRegExp(normalizedMatch)}`));
|
|
2552
|
+
return match ? match.index : -1
|
|
2547
2553
|
}
|
|
2548
2554
|
|
|
2549
2555
|
function upcaseFirst(string) {
|
|
2550
2556
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
2551
2557
|
}
|
|
2552
2558
|
|
|
2559
|
+
function escapeForRegExp(string) {
|
|
2560
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2553
2563
|
// Parses a value that may arrive as a boolean or as a string (e.g. from DOM
|
|
2554
2564
|
// getAttribute) into a proper boolean. Ensures "false" doesn't evaluate as truthy.
|
|
2555
2565
|
function parseBoolean(value) {
|
|
@@ -7370,7 +7380,7 @@ class LinkDropdown extends ToolbarDropdown {
|
|
|
7370
7380
|
get #selectedLinkUrl() {
|
|
7371
7381
|
return this.editor.getEditorState().read(() => {
|
|
7372
7382
|
const linkNode = this.editorElement.selection.nearestNodeOfType(LinkNode);
|
|
7373
|
-
return linkNode?.
|
|
7383
|
+
return linkNode?.getURL() ?? ""
|
|
7374
7384
|
})
|
|
7375
7385
|
}
|
|
7376
7386
|
}
|
|
@@ -7534,21 +7544,41 @@ class LocalFilterSource extends BaseSource {
|
|
|
7534
7544
|
}
|
|
7535
7545
|
|
|
7536
7546
|
#buildListItemsFromPromptItems(promptItems, filter) {
|
|
7537
|
-
const listItems = [];
|
|
7538
7547
|
this.promptItemByListItem = new WeakMap();
|
|
7539
7548
|
|
|
7540
|
-
|
|
7541
|
-
|
|
7549
|
+
if (!filter) {
|
|
7550
|
+
return this.#buildAllListItems(promptItems)
|
|
7551
|
+
}
|
|
7542
7552
|
|
|
7553
|
+
const matches = [];
|
|
7554
|
+
for (const promptItem of promptItems) {
|
|
7543
7555
|
const searchableText = promptItem.getAttribute("search");
|
|
7544
|
-
|
|
7545
|
-
if (
|
|
7546
|
-
|
|
7547
|
-
this.promptItemByListItem.set(listItem, promptItem);
|
|
7548
|
-
listItems.push(listItem);
|
|
7556
|
+
const position = filterMatchPosition(searchableText, filter);
|
|
7557
|
+
if (position >= 0) {
|
|
7558
|
+
matches.push({ promptItem, position });
|
|
7549
7559
|
}
|
|
7550
7560
|
}
|
|
7551
7561
|
|
|
7562
|
+
matches.sort((a, b) => a.position - b.position);
|
|
7563
|
+
|
|
7564
|
+
const listItems = [];
|
|
7565
|
+
for (const { promptItem } of matches) {
|
|
7566
|
+
if (listItems.length >= MAX_RENDERED_SUGGESTIONS$1) break
|
|
7567
|
+
const listItem = this.buildListItemElementFor(promptItem);
|
|
7568
|
+
this.promptItemByListItem.set(listItem, promptItem);
|
|
7569
|
+
listItems.push(listItem);
|
|
7570
|
+
}
|
|
7571
|
+
return listItems
|
|
7572
|
+
}
|
|
7573
|
+
|
|
7574
|
+
#buildAllListItems(promptItems) {
|
|
7575
|
+
const listItems = [];
|
|
7576
|
+
for (const promptItem of promptItems) {
|
|
7577
|
+
if (listItems.length >= MAX_RENDERED_SUGGESTIONS$1) break
|
|
7578
|
+
const listItem = this.buildListItemElementFor(promptItem);
|
|
7579
|
+
this.promptItemByListItem.set(listItem, promptItem);
|
|
7580
|
+
listItems.push(listItem);
|
|
7581
|
+
}
|
|
7552
7582
|
return listItems
|
|
7553
7583
|
}
|
|
7554
7584
|
}
|