mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 09:14:20 +01:00
This commit is contained in:
parent
2d1618e639
commit
419683fe5a
3 changed files with 29 additions and 7 deletions
|
|
@ -68,11 +68,31 @@ export class Undo {
|
|||
hideElements(["hint", "gutter"], protyle);
|
||||
protyle.wysiwyg.lastHTMLs = {};
|
||||
if (!redo) {
|
||||
state.undoOperations.forEach(item => {
|
||||
for (let i = state.undoOperations.length - 1; i >= 0; i--) {
|
||||
if (state.undoOperations[i].action === "insert") {
|
||||
if (state.undoOperations[i].context) {
|
||||
state.undoOperations[i].context.setRange = "true";
|
||||
} else {
|
||||
state.undoOperations[i].context = {setRange: "true"};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.undoOperations.forEach((item) => {
|
||||
onTransaction(protyle, item, true);
|
||||
});
|
||||
transaction(protyle, state.undoOperations);
|
||||
} else {
|
||||
for (let i = state.doOperations.length - 1; i >= 0; i--) {
|
||||
if (state.doOperations[i].action === "insert") {
|
||||
if (state.doOperations[i].context) {
|
||||
state.doOperations[i].context.setRange = "true";
|
||||
} else {
|
||||
state.doOperations[i].context = {setRange: "true"};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.doOperations.forEach(item => {
|
||||
onTransaction(protyle, item, true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -874,11 +874,13 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
|||
blockRender(protyle, item);
|
||||
const wbrElement = item.querySelector("wbr");
|
||||
if (isUndo) {
|
||||
const range = getEditorRange(item);
|
||||
if (wbrElement) {
|
||||
focusByWbr(item, range);
|
||||
} else {
|
||||
focusBlock(item);
|
||||
if (operation.context?.setRange === "true") {
|
||||
const range = getEditorRange(item);
|
||||
if (wbrElement) {
|
||||
focusByWbr(item, range);
|
||||
} else {
|
||||
focusBlock(item);
|
||||
}
|
||||
}
|
||||
} else if (wbrElement) {
|
||||
wbrElement.remove();
|
||||
|
|
|
|||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -552,7 +552,7 @@ interface ISiyuan {
|
|||
interface IOperation {
|
||||
action: TOperation, // move, delete 不需要传 data
|
||||
id?: string,
|
||||
context?: IObject,
|
||||
context?: IObject, // focusId, message, ignoreProcess, setRange
|
||||
blockID?: string,
|
||||
isTwoWay?: boolean, // 是否双向关联
|
||||
backRelationKeyID?: string, // 双向关联的目标关联列 ID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue