Skip to content

Commit a83340c

Browse files
committed
fix(web): replace superseded composer boundary plugin
Use upstream's two caret stops as the single formatting boundary policy. Remove the competing plugin and retain paste, cut, history, and sustained formatting coverage under the upstream navigation semantics. Carry-Group: upstream-bugfixes Carry-Upstream: pingdotgg#13217 head 42ea6ff Carry-Supersedes: pingdotgg#13518 head cc1d991 Carry-Supersedes: #295 Carry-Observation: Upstream closed 13518 in favor of 13217. Remove the old marks plugin so it cannot fight the two-stop policy; preserve this removal when the nightly absorbs 13217.
1 parent a2c8a7b commit a83340c

4 files changed

Lines changed: 76 additions & 203 deletions

File tree

‎apps/web/src/components/ComposerPromptEditorTiptap.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
groupUndoByChangeKind,
6565
markAsClipboardEdit,
6666
} from "~/composer-undo-grouping";
67-
import { ComposerTypingMarksExtension } from "~/composer-typing-marks";
6867
import { collectInlineContextIds } from "~/lib/composerContextReferences";
6968
import { cn, isMacPlatform } from "~/lib/utils";
7069
import { basenameOfPath } from "~/pierre-icons";
@@ -837,7 +836,6 @@ function ComposerPromptEditorTiptapInner(props: ComposerPromptEditorProps) {
837836
ComposerMarkersExtension,
838837
...(richText
839838
? [
840-
ComposerTypingMarksExtension,
841839
ComposerCodeExtension,
842840
TaskList,
843841
ComposerTaskItemExtension.extend({

‎apps/web/src/composer-rich-text-doc.test.ts‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getSchemaByResolvedExtensions, Node, resolveExtensions } from "@tiptap/core";
22
import StarterKit from "@tiptap/starter-kit";
33
import { TaskList } from "@tiptap/extension-task-list";
4+
import { history, redo, undo, undoDepth } from "@tiptap/pm/history";
45
import { Node as ProseMirrorNode } from "@tiptap/pm/model";
56
import { EditorState, TextSelection } from "@tiptap/pm/state";
67
import { describe, expect, it } from "vite-plus/test";
@@ -378,6 +379,81 @@ describe("caret stops at styled edges", () => {
378379
return serializeEditorDoc(state.apply(state.tr.insertText(text)).doc).value;
379380
}
380381

382+
function typeCharacters(state: EditorState, text: string) {
383+
for (const character of text) state = state.apply(state.tr.insertText(character));
384+
return state;
385+
}
386+
387+
it("keeps typing plain after stepping outside pasted bold", () => {
388+
let state = stateAt("", 1);
389+
state = state.apply(
390+
state.tr
391+
.replaceSelectionWith(schema.text("bold", [schema.marks.bold!.create()]), false)
392+
.setMeta("uiEvent", "paste"),
393+
);
394+
state = state.apply(stepCaretAcrossStyledEdge(state, 1)!);
395+
state = typeCharacters(state, " plain");
396+
expect(serializeEditorDoc(state.doc).value).toBe("**bold** plain");
397+
});
398+
399+
it("can step outside bold after cutting its trailing plain text", () => {
400+
let state = stateAt("**b** plain", 8);
401+
state = state.apply(
402+
state.tr
403+
.setSelection(TextSelection.create(state.doc, 2, 8))
404+
.deleteRange(2, 8)
405+
.setMeta("uiEvent", "cut"),
406+
);
407+
state = state.apply(stepCaretAcrossStyledEdge(state, 1)!);
408+
state = typeCharacters(state, " again");
409+
expect(serializeEditorDoc(state.doc).value).toBe("**b** again");
410+
});
411+
412+
it("keeps caret steps out of history and can recover either stop after undo", () => {
413+
let state = stateAt("**b**", 2).reconfigure({ plugins: [history()] });
414+
state = state.apply(stepCaretAcrossStyledEdge(state, 1)!);
415+
expect(undoDepth(state)).toBe(0);
416+
state = typeCharacters(state, " plain");
417+
expect(undoDepth(state)).toBe(1);
418+
419+
expect(
420+
undo(state, (transaction) => {
421+
state = state.apply(transaction);
422+
}),
423+
).toBe(true);
424+
expect(serializeEditorDoc(state.doc).value).toBe("**b**");
425+
expect(state.selection.from).toBe(2);
426+
expect(undoDepth(state)).toBe(0);
427+
428+
expect(
429+
redo(state, (transaction) => {
430+
state = state.apply(transaction);
431+
}),
432+
).toBe(true);
433+
expect(serializeEditorDoc(state.doc).value).toBe("**b** plain");
434+
expect(state.selection.from).toBe(8);
435+
436+
expect(
437+
undo(state, (transaction) => {
438+
state = state.apply(transaction);
439+
}),
440+
).toBe(true);
441+
expect(typed(state, "x")).toBe("**bx**");
442+
state = state.apply(stepCaretAcrossStyledEdge(state, 1)!);
443+
expect(typed(state, "x")).toBe("**b**x");
444+
});
445+
446+
it("sustains explicit formatting toggles across several characters", () => {
447+
let state = stateAt("**b**", 2);
448+
state = state.apply(stepCaretAcrossStyledEdge(state, 1)!);
449+
state = state.apply(state.tr.addStoredMark(schema.marks.bold!.create()));
450+
state = typeCharacters(state, "xy");
451+
expect(serializeEditorDoc(state.doc).value).toBe("**bxy**");
452+
state = state.apply(state.tr.removeStoredMark(schema.marks.bold!));
453+
state = typeCharacters(state, " plain");
454+
expect(serializeEditorDoc(state.doc).value).toBe("**bxy** plain");
455+
});
456+
381457
it("lets the caret step out in front of bold that starts the line", () => {
382458
const inside = stateAt("**bold** tail", 1);
383459
expect(caretTakesMarksBefore(inside)).toBe(false);

‎apps/web/src/composer-typing-marks.test.ts‎

Lines changed: 0 additions & 163 deletions
This file was deleted.

‎apps/web/src/composer-typing-marks.ts‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)