Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): slash-menu image preview + wiki-link overflow hint (#1563)

Abraham223996bb53b7
diff --git a/packages/app/src/editor/extensions/wiki-link-suggestion.ts b/packages/app/src/editor/extensions/wiki-link-suggestion.ts
index 2a88e523d..ce3c97229 100644
--- a/packages/app/src/editor/extensions/wiki-link-suggestion.ts
+++ b/packages/app/src/editor/extensions/wiki-link-suggestion.ts
@@ -386,8 +386,10 @@ export function configureWikiLinkSuggestion(editor: Editor) {
: mode === 'anchor'
? !cachedHeadings.has(pageTarget)
: !pagesLoaded;
+ const items = props.items ?? [];
+ const onlyCreateFallback = items.length === 1 && items[0]?.kind === 'create';
return {
- items: props.items,
+ items,
query: props.query ?? '',
selectedIndex,
onSelect: onSelectCb,
@@ -396,6 +398,7 @@ export function configureWikiLinkSuggestion(editor: Editor) {
mode,
pageTarget,
anchorQuery,
+ hasMore: !onlyCreateFallback && items.length >= MAX_ITEMS,
};
}
diff --git a/packages/app/src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx b/packages/app/src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
index ac533295b..978377a2c 100644
--- a/packages/app/src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
+++ b/packages/app/src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
@@ -13,6 +13,7 @@ interface WikiLinkSuggestionMenuProps {
mode?: 'page' | 'anchor';
pageTarget?: string;
anchorQuery?: string;
+ hasMore?: boolean;
}
function itemKey(item: WikiLinkSuggestionItem): string {
@@ -43,6 +44,7 @@ export function WikiLinkSuggestionMenu({
mode = 'page',
pageTarget = '',
anchorQuery = '',
+ hasMore = false,
}: WikiLinkSuggestionMenuProps) {
const { t } = useLingui();
const containerRef = useRef<HTMLDivElement>(null);
@@ -198,6 +200,16 @@ export function WikiLinkSuggestionMenu({
</button>
);
})}
+ {hasMore && (
+ <div
+ data-prop-suggestion-more-hint=""
+ className="border-t border-border mt-1 px-2 py-1.5 text-xs text-muted-foreground"
+ >
+ {mode === 'anchor'
+ ? t`Showing top ${items.length} headings — keep typing to narrow`
+ : t`Showing top ${items.length} matches — keep typing to narrow`}
+ </div>
+ )}
</div>
);
}
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index 82caeed6b..4612bb1ca 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -130,6 +130,7 @@
"3Ib6FN": ["Move down"],
"3J7d2N": ["Big section heading."],
"3JYy1p": ["Branch ", ["0"], " no longer exists. Cloned to default branch."],
+ "3MnvrL": ["Showing top ", ["0"], " matches — keep typing to narrow"],
"3Mwaly": ["Could not initialize ", ["0"], "."],
"3SDfZl": [
"<0>Mirror — pick a source.</0> Set <1>src</1> + <2>anchor</2> via the property panel to point at a <3><MirrorSource></3> elsewhere."
@@ -1866,6 +1867,7 @@
],
"yjExfe": ["Branch <0>", ["shareBranch"], "</0> is checked out in:"],
"ynIa4S": ["Visual editor list item"],
+ "ypw6My": ["Showing top ", ["0"], " headings — keep typing to narrow"],
"ysxgu8": ["project"],
"ytlX5Z": [
"Chrome uses this for browser find. Open Knowledge overrides it in visual editor mode."
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 9b876cec2..561515f3b 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -5043,6 +5043,16 @@ msgstr "Showing first {truncatedShownCount} items — use search to find others"
#~ msgid "Showing first {truncatedShownCount} items (truncated)"
#~ msgstr "Showing first {truncatedShownCount} items (truncated)"
+#. placeholder {0}: items.length
+#: src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
+msgid "Showing top {0} headings — keep typing to narrow"
+msgstr "Showing top {0} headings — keep typing to narrow"
+
+#. placeholder {0}: items.length
+#: src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
+msgid "Showing top {0} matches — keep typing to narrow"
+msgstr "Showing top {0} matches — keep typing to narrow"
+
#: src/editor/extensions/CodeBlockView.tsx
msgid "Shows above the code body. Round-trips as `title=\"...\"` in markdown."
msgstr "Shows above the code body. Round-trips as `title=\"...\"` in markdown."
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 51ca0b5c6..45a2295c8 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -130,6 +130,7 @@
"3Ib6FN": ["Ḿōvē ďōŵń"],
"3J7d2N": ["ßĩĝ śēćţĩōń ĥēàďĩńĝ."],
"3JYy1p": ["ßŕàńćĥ ", ["0"], " ńō ĺōńĝēŕ ēxĩśţś. Ćĺōńēď ţō ďēƒàũĺţ ƀŕàńćĥ."],
+ "3MnvrL": ["Śĥōŵĩńĝ ţōƥ ", ["0"], " ḿàţćĥēś — ķēēƥ ţŷƥĩńĝ ţō ńàŕŕōŵ"],
"3Mwaly": ["Ćōũĺď ńōţ ĩńĩţĩàĺĩźē ", ["0"], "."],
"3SDfZl": [
"<0>Ḿĩŕŕōŕ — ƥĩćķ à śōũŕćē.</0> Śēţ <1>śŕć</1> + <2>àńćĥōŕ</2> vĩà ţĥē ƥŕōƥēŕţŷ ƥàńēĺ ţō ƥōĩńţ àţ à <3><MirrorSource></3> ēĺśēŵĥēŕē."
@@ -1866,6 +1867,7 @@
],
"yjExfe": ["ßŕàńćĥ <0>", ["shareBranch"], "</0> ĩś ćĥēćķēď ōũţ ĩń:"],
"ynIa4S": ["Vĩśũàĺ ēďĩţōŕ ĺĩśţ ĩţēḿ"],
+ "ypw6My": ["Śĥōŵĩńĝ ţōƥ ", ["0"], " ĥēàďĩńĝś — ķēēƥ ţŷƥĩńĝ ţō ńàŕŕōŵ"],
"ysxgu8": ["ƥŕōĴēćţ"],
"ytlX5Z": [
"Ćĥŕōḿē ũśēś ţĥĩś ƒōŕ ƀŕōŵśēŕ ƒĩńď. Ōƥēń Ķńōŵĺēďĝē ōvēŕŕĩďēś ĩţ ĩń vĩśũàĺ ēďĩţōŕ ḿōďē."
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index e93f00d5b..c165f5d0d 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -5038,6 +5038,16 @@ msgstr ""
#~ msgid "Showing first {truncatedShownCount} items (truncated)"
#~ msgstr ""
+#. placeholder {0}: items.length
+#: src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
+msgid "Showing top {0} headings — keep typing to narrow"
+msgstr ""
+
+#. placeholder {0}: items.length
+#: src/editor/wiki-link-suggestion/WikiLinkSuggestionMenu.tsx
+msgid "Showing top {0} matches — keep typing to narrow"
+msgstr ""
+
#: src/editor/extensions/CodeBlockView.tsx
msgid "Shows above the code body. Round-trips as `title=\"...\"` in markdown."
msgstr ""
diff --git a/packages/app/src/server/hocuspocus-plugin.ts b/packages/app/src/server/hocuspocus-plugin.ts
index 909eee484..0ec2d3a70 100644
--- a/packages/app/src/server/hocuspocus-plugin.ts
+++ b/packages/app/src/server/hocuspocus-plugin.ts
@@ -290,6 +290,7 @@ export function hocuspocusPlugin(): Plugin {
path.startsWith('/@id/') ||
path === '/@react-refresh' ||
path.startsWith('/node_modules/') ||
+ path.startsWith('/src/') ||
path === '/favicon.svg' ||
params?.has('import') ||
params?.has('html-proxy')