mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fix: Not possible to collapse code block at beginning of doc (#12381)
This commit is contained in:
@@ -480,7 +480,7 @@ export default class CodeFence extends Node<CodeFenceOptions> {
|
||||
// Click handler for toggle button + auto-expand on focus
|
||||
new Plugin({
|
||||
key: new PluginKey("collapse-toggle"),
|
||||
appendTransaction: (transactions, _oldState, newState) => {
|
||||
appendTransaction: (transactions, oldState, newState) => {
|
||||
const hasCollapseMeta = transactions.some((tr) =>
|
||||
tr.getMeta(collapseKey)
|
||||
);
|
||||
@@ -498,6 +498,14 @@ export default class CodeFence extends Node<CodeFenceOptions> {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only auto-expand when the selection moved INTO the block. If the
|
||||
// selection was already inside this block (e.g. after the user just
|
||||
// clicked Collapse while the cursor was inside), don't re-expand.
|
||||
const oldCodeBlock = findParentNode(isCode)(oldState.selection);
|
||||
if (oldCodeBlock?.pos === codeBlock.pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return newState.tr
|
||||
.setMeta(collapseKey, { expand: codeBlock.pos })
|
||||
.setMeta("addToHistory", false);
|
||||
|
||||
Reference in New Issue
Block a user