FLESHNOTE / DOCS / CORE EDITOR / ANNOTATIONS & #TODO

Annotations, QuickNotes & #TODO Engine

INLINE TOOLS

Non-destructive prose commentary: the zero-width space #TODO decoration plugin, semantic color-coded QuickNotes, and automated export stripping diagnostics.

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:

TodoHighlighter.js — Zero-Width Space Boundary
// 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-highlight CSS class dynamically over the text range.
  • Boundary Precision: Typing past the \u200B invisible 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:

  1. backend/export/strip.py executes strip_todo(text) matching _TODO_PATTERN = re.compile(r'#TODO.*?(?=\u200B|</p>|<br>|<br/>|\n|$)', re.IGNORECASE).
  2. The export pipeline counts all stripped tags.
  3. 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.
On This Page