Skip to content

docs(openspec): propose clipboard paste for plain text and EditorJS payload - #191

Draft
ilyamore88 wants to merge 2 commits into
claude/undo-group-by-task-implfrom
claude/clipboard-paste-research-2c2573
Draft

ilyamore88 wants to merge 2 commits into
claude/undo-group-by-task-implfrom
claude/clipboard-paste-research-2c2573

Conversation

@ilyamore88

@ilyamore88 ilyamore88 commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

What

Planning only. This PR adds the clipboard-paste-plain-and-editorjs OpenSpec change, the first slice of #137. It contains no code changes. It is stacked on #203, the implementation of undo-group-by-task (proposed in #201). That change makes core record all changes of one browser task as one undo step.

The change touches sdk, ui and clipboard-plugin:

  • New event. PasteUIEvent (ui:paste), which BlocksUI forwards from the native paste event.
  • What paste reads. ClipboardPlugin prefers application/x-editor-js and falls back to text/plain.
    • Payload entries with unregistered tools are dropped, and block ids are discarded.
    • Multi-line text becomes one default-tool block per line, built with the default tool's importTextContent. Blank lines are skipped.
  • Where content goes. Placement depends on the caret: start, middle (split) or end of a block, or replacing an empty default block. The whole paste is applied synchronously in the ui:paste handler, so core's per-task grouping records it as one undo step. The plugin uses no grouping API.
  • Handing back to the browser. The plugin doesn't call preventDefault when it can't handle the paste: no clipboard data, nothing usable, or a selection across several inputs. The existing insertFromPaste path then runs unchanged.
  • Copy (breaking change to the clipboard format).
    • Payload entries no longer include ids.
    • application/x-editor-js is written only for whole-block or multi-block selections. A selection inside one block copies as text/plain and text/html only.

Why

Paste currently goes through beforeinput → insertFromPaste as plain text only. Multi-line text ends up in a single block, and the EditorJS payload written on copy is never read. Copy also has two problems that would break paste once the payload is read:

  • It writes block ids, and re-inserting them throws BlockAlreadyExistsError.
  • It writes whole blocks even when the selection is inside a single input.

Notes for reviewers

  • Deferred from Paste plugin #137: HTML and sanitizing, files, patterns, the tag registry, pasteConfig, read-only mode, deleting a selection across blocks, cut, drop, and clipping partially selected blocks when copying.
  • Open question: should pasting over a whole-block selection replace that block? The design currently inserts after it.
  • Collaboration. With collaboration-manager registered, a paste undoes in several steps. This comes from undo-group-by-task's non-goal.
  • The change is not archived. Implementation happens via /opsx:apply clipboard-paste-plain-and-editorjs after undo-group-by-task.


## What Changes

- Add `api.document.group(fn)` to the SDK `DocumentAPI` contract and implement it in core. Model changes made synchronously inside `fn` by the local user form exactly one undo step:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear why do we need to expose this to the public API

@ilyamore88
ilyamore88 force-pushed the claude/clipboard-paste-research-2c2573 branch from 0b07cc4 to 0922150 Compare October 10, 2026 11:49
@ilyamore88
ilyamore88 changed the base branch from main to claude/undo-grouping-proposal October 10, 2026 11:49
@ilyamore88
ilyamore88 added this pull request to stack #202 October 10, 2026 11:49
@ilyamore88 ilyamore88 changed the title docs(openspec): propose undo grouping and clipboard paste (plain text + EditorJS) docs(openspec): propose clipboard paste for plain text and EditorJS payload Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Unit Tests

Package Coverage Delta
@editorjs/ot-server N/A N/A
@editorjs/editorjs 100% 0% ⚪️
@editorjs/core 73.87% +0.73% 🟢
@editorjs/model N/A N/A
@editorjs/shortcuts-plugin N/A N/A
@editorjs/dom-adapters N/A N/A
@editorjs/collaboration-manager N/A N/A
@editorjs/clipboard-plugin N/A N/A
@editorjs/model-types N/A N/A

Mutation Tests

Package Mutation score Dashboard URL
@editorjs/core 86.00% 🟢 Dashboard

@github-actions

Copy link
Copy Markdown
Contributor

Unit Tests

Package Coverage Delta
@editorjs/collaboration-manager N/A N/A

Mutation Tests

Package Mutation score Dashboard URL

@ilyamore88
ilyamore88 force-pushed the claude/clipboard-paste-research-2c2573 branch from 0922150 to 3194244 Compare October 10, 2026 12:00
…ayload

Add the clipboard-paste-plain-and-editorjs OpenSpec change: paste of
text/plain and application/x-editor-js in ClipboardPlugin, id-free copy
payload, and the whole-block rule for the EditorJS payload. Builds on
undo-grouping (#137).
Drop api.document.group from the clipboard paste change: the paste is
applied synchronously in the ui:paste handler and undo-group-by-task
records it as one undo step.
@ilyamore88
ilyamore88 removed this pull request from stack #202 October 10, 2026 12:25
@ilyamore88
ilyamore88 force-pushed the claude/clipboard-paste-research-2c2573 branch from 3194244 to a10f34f Compare October 10, 2026 12:26
@ilyamore88
ilyamore88 changed the base branch from claude/undo-grouping-proposal to claude/undo-group-by-task-impl October 10, 2026 12:26
@ilyamore88
ilyamore88 added this pull request to stack #204 October 10, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants