Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(web): composer serializes each draft doc once per keystroke #26720

Mergedhieu-lee(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/26720/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 20 additions and 6 deletions.

x
0 of 2 viewed, 2 left
2 additions and 2 deletionsapps/web/src/components/ComposerPromptEditorTiptap.tsxModified
View file
@@ -1013,7 +1013,7 @@
const handleEditorChange = (updated: TiptapEditor) => {
const map = serializeEditorDoc(updated.state.doc);
- const contextIds = literalText ? [] : map.contextIds;
+ const contextIds = literalText ? [] : [...map.contextIds];
const { from, to } = updated.state.selection;
const fromFlat = pmToFlat(map, from);
const toFlat = pmToFlat(map, to);
@@ -1468,7 +1468,7 @@
value: map.value,
cursor: collapseExpandedComposerCursor(map.value, expandedCursor, literalText),
expandedCursor,
- contextIds: literalText ? [] : map.contextIds,
+ contextIds: literalText ? [] : [...map.contextIds],
const toFlat = pmToFlat(map, to);
selectionRangeRef.current = {
18 additions and 4 deletionsapps/web/src/composer-rich-text-doc.tsModified
View file
@@ -811,11 +811,12 @@
nodeName?: string;
​
+// Shared by every caller that serializes the same doc, so it must not be mutated.
export interface RichDocMap {
- value: string;