Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
PRD-9709 Show the create placeholder on pages that don't exist yet (#7067)
Andrew Mikofalvy880927984409
diff --git a/.changeset/missing-page-placeholder.md b/.changeset/missing-page-placeholder.mdnew file mode 100644index 000000000..dd07bcb18--- /dev/null+++ b/.changeset/missing-page-placeholder.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++A page that doesn't exist yet now shows "Start writing to create this page" until you type.diff --git a/packages/app/src/editor/TiptapEditor.tsx b/packages/app/src/editor/TiptapEditor.tsxindex 3a43c1253..e754738c6 100644--- a/packages/app/src/editor/TiptapEditor.tsx+++ b/packages/app/src/editor/TiptapEditor.tsx@@ -367,7 +367,7 @@ function admitFocusedTextCaret(view: PMEditorView, event: KeyboardEvent): void {}function buildEditorOptions(args: BuildEditorOptionsArgs): Partial<EditorOptions> {- const { provider, clipboard, ctorStart } = args;+ const { provider, placeholder, clipboard, ctorStart } = args;return {onBeforeCreate: ({ editor }) => {editorCtorStartTimes.set(editor, ctorStart);@@ -390,6 +390,7 @@ function buildEditorOptions(args: BuildEditorOptionsArgs): Partial<EditorOptionseditorProps: {attributes: {class: 'pt-4 pb-4 h-full',+ ...(placeholder === undefined ? {} : { 'data-empty-placeholder': placeholder }),},clipboardTextParser: (text, _context, _plain, view) => {const json = clipboard.mdManager.parse(text);diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex f2ed66b5e..9223150c4 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -2538,14 +2538,22 @@ section[data-editor-pane-id] {}}-.ProseMirror p.is-empty::before {- content: attr(data-placeholder);+.ProseMirror p.is-empty::before,+.ProseMirror[data-empty-placeholder]:empty::before {pointer-events: none;float: left;height: 0;@apply text-muted-foreground/60;}+.ProseMirror p.is-empty::before {+ content: attr(data-placeholder);+}++.ProseMirror[data-empty-placeholder]:empty::before {+ content: attr(data-empty-placeholder);+}+/* When any JSX prop panel is open in this editor, suppress the slash-command* placeholder on empty paragraphs — the placeholder competes for attention* with the focused panel. Scope is narrow on purpose: the trigger must livediff --git a/packages/app/tests/stress/missing-page-placeholder.e2e.ts b/packages/app/tests/stress/missing-page-placeholder.e2e.tsnew file mode 100644index 000000000..1aee396ab--- /dev/null+++ b/packages/app/tests/stress/missing-page-placeholder.e2e.ts@@ -0,0 +1,88 @@+import { existsSync, readFileSync } from 'node:fs';+import { join } from 'node:path';+import type { Locator, Page } from '@playwright/test';+import { expect, test } from './_helpers';++const PLACEHOLDER = 'Start writing to create this page';++function uniqueStamp(): string {+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;+}++const fileRow = (page: Page, fileName: string) =>+ page+ .locator('[data-slot="sidebar-container"]')+ .getByRole('treeitem', { name: fileName, exact: true });++const visibleEditor = (page: Page) =>+ page.locator('.ProseMirror:not(.composer-prosemirror)').filter({ visible: true }).first();++function emptyPlaceholder(editor: Locator): Promise<string> {+ return editor.evaluate((element) => getComputedStyle(element, '::before').content);+}++async function openMissingPage(page: Page, anchorDoc: string, missingDoc: string): Promise<void> {+ await page.goto(`/#/${anchorDoc}`);+ await fileRow(page, `${anchorDoc}.md`).waitFor({ state: 'visible', timeout: 15_000 });+ await page.evaluate((docName) => {+ window.location.hash = `#/${docName}`;+ }, missingDoc);+}++test('a page that does not exist yet shows the create placeholder and writes nothing while viewed', async ({+ page,+ api,+ workerServer,+}) => {+ const stamp = uniqueStamp();+ const anchorDoc = `placeholder-anchor-${stamp}`;+ const missingDoc = `placeholder-missing-${stamp}`;+ await api.createPage(`${anchorDoc}.md`);++ await openMissingPage(page, anchorDoc, missingDoc);++ const editor = visibleEditor(page);+ await expect.poll(() => emptyPlaceholder(editor), { timeout: 15_000 }).toBe(`"${PLACEHOLDER}"`);+ await expect(editor).toBeVisible();+ expect(await editor.evaluate((element) => element.childElementCount)).toBe(0);+ expect(existsSync(join(workerServer.contentDir, `${missingDoc}.md`))).toBe(false);+});++test('a cold load straight to a page that does not exist yet shows the create placeholder', async ({+ page,+ workerServer,+}) => {+ const missingDoc = `placeholder-cold-${uniqueStamp()}`;++ await page.goto(`/#/${missingDoc}`);++ const editor = visibleEditor(page);+ await expect.poll(() => emptyPlaceholder(editor), { timeout: 15_000 }).toBe(`"${PLACEHOLDER}"`);+ expect(existsSync(join(workerServer.contentDir, `${missingDoc}.md`))).toBe(false);+});++test('typing into a page that does not exist yet hides the placeholder and creates the page', async ({+ page,+ api,+ workerServer,+}) => {+ const stamp = uniqueStamp();+ const anchorDoc = `placeholder-anchor-${stamp}`;+ const missingDoc = `placeholder-typed-${stamp}`;+ const typed = `Created from the placeholder ${stamp}`;+ await api.createPage(`${anchorDoc}.md`);++ await openMissingPage(page, anchorDoc, missingDoc);++ const editor = visibleEditor(page);+ await expect.poll(() => emptyPlaceholder(editor), { timeout: 15_000 }).toBe(`"${PLACEHOLDER}"`);+ await editor.click();+ await page.keyboard.insertText(typed);++ await expect(editor).toContainText(typed, { timeout: 5_000 });+ await expect.poll(() => emptyPlaceholder(editor)).toBe('none');+ const path = join(workerServer.contentDir, `${missingDoc}.md`);+ await expect+ .poll(() => (existsSync(path) ? readFileSync(path, 'utf-8') : ''), { timeout: 15_000 })+ .toContain(typed);+});