fix: Cannot select doc text in version history (#12268)

* fix: Cannot select doc text in version history

* PR feedback, use deco cache
This commit is contained in:
Tom Moor
2026-05-05 08:35:26 -04:00
committed by GitHub
parent 0df6c4947a
commit e7623eeade
+12 -7
View File
@@ -144,20 +144,25 @@ export default class Diff extends Extension<DiffOptions> {
key: pluginKey,
state: {
init: (_, state) => this.createDecorations(state.doc),
apply: (tr) => this.createDecorations(tr.doc),
apply: (tr, prev) => {
if (!tr.docChanged && !tr.getMeta(pluginKey)) {
return prev;
}
return this.createDecorations(tr.doc);
},
},
props: {
decorations(state) {
return this.getState(state);
},
},
// Allow meta transactions to bypass filtering
// Block doc-changing transactions to keep the diff immutable, but
// allow selection updates and a few cooperating plugins through.
filterTransaction: (tr) =>
tr.getMeta("codeHighlighting") ||
tr.getMeta(pluginKey) ||
tr.getMeta(toggleFoldPluginKey)
? true
: false,
!tr.docChanged ||
!!tr.getMeta("codeHighlighting") ||
!!tr.getMeta(pluginKey) ||
!!tr.getMeta(toggleFoldPluginKey),
}),
];
}