mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-11-22 11:04:56 +01:00
Replace the source editor with CodeMirror and reduce typing-time work. Virtualize note lists, apply targeted refreshes, and batch search indexing. Improve vault and in-note search, and bound graph layout work. Make saves revision-safe and flush pending changes before navigation or close. Preserve originating-vault ownership across async operations and detached windows. Harden sync, attachment writes, and notebook/tag appearance updates. Keep Trash previews read-only and skip restoring trashed notes. Update AI model presets and isolate streamed responses by request. Fix local image rendering and preserve portable image paths. Include regression tests for the changed behavior.
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
const { restoreTitleHeading, stripTitleHeading } = await import(
|
|
new URL('../src/lib/editor/titleVisibility.ts', import.meta.url)
|
|
);
|
|
|
|
test('keeps a hidden title through source to rich to source and save', () => {
|
|
const persisted = '# Note title\n\n## Something else\n\nBody\n';
|
|
const body = '## Something else\n\nBody\n';
|
|
|
|
const initialSource = stripTitleHeading(persisted, 'Note title', true);
|
|
const rich = stripTitleHeading(
|
|
restoreTitleHeading(initialSource.markdown, initialSource.hiddenTitle),
|
|
'Note title',
|
|
true
|
|
);
|
|
const toggledSource = stripTitleHeading(
|
|
restoreTitleHeading(rich.markdown, rich.hiddenTitle),
|
|
'Note title',
|
|
true
|
|
);
|
|
|
|
assert.equal(rich.markdown, body);
|
|
assert.equal(toggledSource.markdown, body);
|
|
assert.equal(restoreTitleHeading(toggledSource.markdown, toggledSource.hiddenTitle), persisted);
|
|
});
|
|
|
|
test('keeps a title-only note visually empty and saves one title heading', () => {
|
|
const initialSource = stripTitleHeading('# Note title\n', 'Note title', true);
|
|
const rich = stripTitleHeading(
|
|
restoreTitleHeading(initialSource.markdown, initialSource.hiddenTitle),
|
|
'Note title',
|
|
true
|
|
);
|
|
const saved = restoreTitleHeading(rich.markdown, rich.hiddenTitle);
|
|
|
|
assert.equal(initialSource.markdown, '');
|
|
assert.equal(rich.markdown, '');
|
|
assert.equal((saved.match(/^# Note title$/gm) ?? []).length, 1);
|
|
});
|
|
|
|
test('replaces hidden title state when an unrelated note loads', () => {
|
|
const markdown = '## Something else\n\nOther body\n';
|
|
|
|
assert.deepEqual(stripTitleHeading(markdown, 'Another note', true), {
|
|
markdown,
|
|
hiddenTitle: null
|
|
});
|
|
});
|
|
|
|
test('leaves the title visible when title hiding is disabled', () => {
|
|
const persisted = '# Note title\n\n## Something else\n';
|
|
|
|
assert.deepEqual(stripTitleHeading(persisted, 'Note title', false), {
|
|
markdown: persisted,
|
|
hiddenTitle: null
|
|
});
|
|
});
|