Skip to content

[pull] develop from marktext:develop#82

Merged
pull[bot] merged 3 commits into
code:developfrom
marktext:develop
Jun 20, 2026
Merged

[pull] develop from marktext:develop#82
pull[bot] merged 3 commits into
code:developfrom
marktext:develop

Conversation

@pull

@pull pull Bot commented Jun 20, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

Jocs and others added 3 commits June 20, 2026 15:04
…nals (#4587)

* refactor(muya): move block-transform logic out of UI plugins into the engine

The core engine (`muya.ts`) imported block-transformation and turn-into
logic from inside two UI-plugin folders — a reversed dependency (engine →
src/ui). That logic is engine behavior, not UI, so it now lives in a new
engine module and both the engine and the UI plugins depend on it.

- Add `src/block/blockTransforms.ts` holding the document-editing helpers
  moved verbatim out of `ui/paragraphQuickInsertMenu/config.ts`:
  `frontmatterMeta`, `insertFrontMatterAtStart`, `buildReplacementBlock`
  (+ block builders), `replaceBlockByLabel`, `insertBlockBelowByLabel`,
  `showTablePicker`, and the caret helpers.
- Extract a pure `canTurnInto(block, label)` predicate (label regexes ported
  verbatim) into the new module; `canTurnIntoMenu` in
  `ui/paragraphFrontMenu/config.ts` is now a thin UI wrapper that filters the
  menu items through it, so the front menu keeps its icon-rich output while
  the engine consumes only the predicate.
- Repoint `muya.ts` and both paragraph plugins at the new module; prune the
  now-unused imports left behind in `paragraphQuickInsertMenu/config.ts`
  (which keeps only `MENU_CONFIG`, `IQuickInsertMenuItem`, `getLabelFromEvent`).
- Update the two specs that imported `replaceBlockByLabel` directly.

No behavior change: the moved functions are unchanged and `canTurnInto`
reproduces the previous filtering exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(muya): move float keydown interception into the UI layer

The block layer (`content.ts`) hardcoded a Set of nine UI-plugin names and
read `muya.ui.shownFloat` to decide whether to `preventDefault` navigation
keys while a float was open — so the block layer knew specific UI plugins by
name (there was even a `// TODO: move codes bellow to muya.ui ?`).

Each float now self-declares whether it captures the content navigation keys,
and the `Ui` registry — the architecture's sanctioned engine↔UI seam — owns
the decision:

- Add `capturesContentKeydown` to `BaseFloat` (default `false`) and override
  it to `true` on the nine plugins that previously sat in the allowlist
  (front/quick-insert menus, format/table/emoji/image pickers, table tools).
- Add `Ui.handleContentKeydown(event)`, which reproduces the prior semantics
  exactly: skip the block's handling whenever any float is shown for a nav
  key, and `preventDefault` only when a shown float opts in.
- `content.ts` drops `FLOAT_PREVENT_DEFAULT_NAMES` and
  `_handleShownFloatKeydown` and simply asks `this.muya.ui.handleContentKeydown`
  (kept below the `isKeyboardEvent` guard). It no longer knows any plugin name
  or touches `shownFloat`.
- Add a unit test covering the four keydown outcomes (no float / non-nav key /
  non-capturing float / capturing float), which was previously uncovered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…#4586)

* fix(clipboard): copy only the selected part of block-quotes and lists

A cross-block copy/cut whose endpoint landed inside a block-quote or list
carried the whole container/item instead of the selected portion: the
block-quote branch of `appendPartialState` pushed the entire quote state,
and the list branch sliced items by index without truncating the boundary
item's text. The same flaw applied when both selection boundaries stayed
inside one container (`collectSameOutMostBlockState`).

Reconstruct partial container state recursively instead:
- `buildPartialContainerState` keeps the siblings on the selected side of a
  single boundary leaf, recurses into nested containers, and truncates the
  boundary leaf's text (used for cross-block start/end endpoints).
- `buildRangeContainerState` keeps the range between two boundary leaves and
  truncates both (used when the selection stays within one container).
Both preserve each block's name and meta (e.g. a task item's checked flag).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(clipboard): truncate code/setext-heading endpoints instead of dumping whole

A cross-block copy/cut whose endpoint landed inside a leaf block other than
a paragraph mis-serialized the partial selection:
- code-block, html-block, math-block, frontmatter and diagram endpoints were
  copied whole regardless of the caret;
- a setext heading was flattened to a paragraph, losing its heading even when
  the whole heading was selected (its `===`/`---` underline lives in meta, so
  the paragraph fallback dropped it unconditionally).

For these blocks, keep the block's own name + meta and truncate only its text
to the caret — their serializers rebuild the fence/underline from meta, so a
partial body round-trips, and a fully-selected endpoint still yields the whole
block. A code fence's language line has no place in the body text, so it is
copied whole. atx headings keep the existing paragraph path: their `# ` marker
lives in the text and rides along with the substring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…line (#4591)

`_convertToSetextHeading` inverted the level: `/=/.test(underline) ? 2 : 1`
mapped a `===` underline to level 2 and `---` to level 1, the opposite of
the CommonMark rule (`=` → h1, `-` → h2). Typing `===` therefore rendered an
h2 until a source-mode round-trip re-parsed it (markdownToState derives the
level from the parser's depth, so the serialized markdown was already
correct, masking the bug).

Flip the mapping to `? 1 : 2`.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pull pull Bot locked and limited conversation to collaborators Jun 20, 2026
@pull pull Bot added the ⤵️ pull label Jun 20, 2026
@pull pull Bot merged commit 68075ac into code:develop Jun 20, 2026
5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant