super-productivity/packages/plugin-dev/document-mode
Johannes Millan b7140027d9 fix(document-mode): tolerant delete, safe logging, subtask drag clamp
Three issues hit while editing subtasks; all fixed in one pass:

- PluginAPI.log is declared on the type but never assigned in the
  iframe's runtime PluginAPI (see plugin-iframe.util.ts). Every
  PluginAPI.log.err call inside a .catch() callback then threw
  "Cannot read properties of undefined (reading 'err')", which
  surfaced as the user-visible crash on double-Enter on an empty
  subtask. Replace all usages with a logErr helper that calls
  PluginAPI.log?.err?.() and always falls back to console.error.

- deleteTask rejects with "Task data not found" when a stale chip
  points at a task already removed in the host (sync removal, etc.).
  The unhandled rejection cascaded with the log bug. Add
  deleteTaskTolerant: skip if the task isn't in the local cache,
  swallow "not found" responses, log anything else.

- After setParagraph() on an empty taskRef/subTaskRef, the selection
  remained a NodeSelection on the new paragraph. A follow-up Enter
  on a NodeSelection takes a different path in ProseMirror and could
  resolve a bad position. Chain setTextSelection(nodePos + 1) so the
  caret lands inside the paragraph as text.

- Subtask drag now stays inside the parent's group. Adds
  validInsertRange(draggingPos): for a subTaskRef, returns the
  [parentIdx+1, groupEnd] range. computeDropTarget clamps the
  candidate insertion index and recomputes the indicator Y so the
  drop line follows the clamped target. Top-level taskRef drag is
  unchanged for now.
2026-05-21 18:58:02 +02:00
..
scripts feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
src fix(document-mode): tolerant delete, safe logging, subtask drag clamp 2026-05-21 18:58:02 +02:00
.gitignore feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
package-lock.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
package.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
tsconfig.json feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00