Markup mode: `colorify` does not detect existing `{color}(...)` wrapper when switching colors
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
まず packages/editor/src/bundle/toolbar/markup/MToolbarColors.tsx と関連するマークアップコマンドの実装を読み、次に packages/editor/src/markup/commands/marks.test.ts の M3 ケースを確認します。M3 のアサーションを更新して、既存のカラーラッパーをネストせずに置き換えるケースをカバーし、マークアップコマンドの集中テストを実行します。Storybook で操作を確認します。{blue}(text) は {red}(text) に変化し、同じ色をクリックするとラッパーが削除されます。
索引モデルが issue の本文から書いたものです。
説明
Problem
In PR #840 the markup-mode colorify was switched from inlineWrapTo to toggleInlineMarkupFactory({before: '{${color}}(', after: ')'}) so that clicking the same color twice unwraps it.
The current implementation of toggleInlineMarkupFactory only detects an exact prefix/suffix match. That breaks color switching:
- doc:
{blue}(text), cursor insidetext - click Red → expected:
{red}(text) - actual: nested wrapping like
{red}({blue}(text)){red}(because{red}(is not present at the boundaries, so the helper falls through to the wrap branch).
The author marked this with a // TODO: @makhnatkin check markup mode in packages/editor/src/bundle/toolbar/markup/MToolbarColors.tsx.
A pinning test exists in packages/editor/src/markup/commands/marks.test.ts (case M3) that captures the current broken output, so a future fix will flip the assertion.
Suggested approaches
- Pre-strip any existing
{<word>}(...)wrapper around the selection before applyingcolorify. A small parser (regex^\{[a-z0-9-]+\}\(matching the prefix and\)$for the suffix) is sufficient. - Replace
toggleInlineMarkupFactoryfor color with a dedicated command that recognises the family of{*}(prefixes and either re-wraps with the new color or unwraps when the same color is clicked. - Reach back to
inlineWrapTo(no toggle), accepting that markup-mode color clicks always wrap. This loses the toggle-off UX but avoids the nested-wrapper bug.
Out of scope for #840
Fixing this requires command-level rework in markup mode and is independent from the wysiwyg toggle fix. PR #840 ships with the pinning test M3 documenting the known limitation; this issue tracks the follow-up.
Acceptance
- M3 in
packages/editor/src/markup/commands/marks.test.tsflips to assert the correct unwrapped/replaced result. - Storybook smoke: in markup mode,
{blue}(text)→ click Red →{red}(text)(no nesting).
- 主要言語
- TypeScript
- スター
- 428
- フォーク
- 48
- 平均マージ
- 5日 15時間
- マージ済み PR(30日)
- 47
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
gravity-ui/markdown-editor のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
gravity-ui/markdown-editor#1452 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gravity-ui/markdown-editor#1293 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
gravity-ui/markdown-editor#1450 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
gravity-ui/markdown-editor#1331 ·
メンテナーはふだん 1 日以内に返信
-
Shared `slotsTokenizer` for directive blocks対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
gravity-ui/markdown-editor#1301 ·
メンテナーはふだん 1 日以内に返信
gravity-ui/markdown-editor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tintinweb/pi-subagents#459 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
danielmiessler/LifeOS#2830 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
freshframework/fresh#3920 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: client enhancement priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
opensro-dev/opensro#3681 ·
メンテナーはふだん 1 日以内に返信