The #TODO Tag Engine (`TodoHighlighter.js`) #
Writers frequently need to leave quick inline reminders while drafting (e.g. "#TODO describe the scent of the temple"). In traditional editors, custom tags clutter the underlying document schema or require complex markup.
FleshNote implements the #TODO Tag Engine as a lightweight ProseMirror DecorationSet plugin:
// Matches #TODO up to the invisible zero-width space token or line end
const regex = /#TODO[\s\S]*?(?=\u200B|$)/gi;
// Keyboard shortcut: Alt+T inserts the tag and boundary token
addKeyboardShortcuts() {
return {
'Alt-t': () => {
const { from } = this.editor.state.selection;
this.editor.chain()
.insertContent('#TODO \u200B')
.setTextSelection(from + 6)
.run();
return true;
}
}
}
Why Zero-Width Space (\u200B)?
- No Schema Bloat: The text remains pure string data without wrapping in heavy block elements.
- Clean Visual Highlight: ProseMirror applies the
.todo-highlightCSS class dynamically over the text range. - Boundary Precision: Typing past the
\u200Binvisible token immediately returns the cursor to normal text styling.
QuickNotes & Semantic Note Types #
QuickNotes are lightweight inline tags stored in the quick_notes database table and rendered via EntityLinkMark.js:
| Note Type | CSS Class | Color Accent | Intended Usage |
|---|---|---|---|
Idea |
.note-type-idea |
Yellow | Spontaneous worldbuilding brainstorms and character concepts. |
Todo |
.note-type-todo |
Orange | Research reminders, fact-checking tasks, and continuity items. |
Revision |
.note-type-revision |
Pink | Passage rewrites, pacing adjustments, and line edits. |
Lore |
.note-type-lore |
Purple | Inline world history snippets and magic system references. |
Export Stripping & Diagnostic Warnings #
During publication builds (DOCX, PDF, EPUB, TXT), draft commentary must never leak into the manuscript:
backend/export/strip.pyexecutesstrip_todo(text)matching_TODO_PATTERN = re.compile(r'#TODO.*?(?=\u200B|</p>|<br>|<br/>|\n|$)', re.IGNORECASE).- The export pipeline counts all stripped tags.
- If any tags were removed, the API returns a diagnostic alert:
"Removed X #TODO tag(s) from the exported text."so the author knows unresolved draft notes were present.