This commit is contained in:
parent
9157a6e6e6
commit
a2635a5520
5 changed files with 20 additions and 11 deletions
|
@ -214,10 +214,18 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
} else {
|
||||
protyle = activeTab.model.editors.unRefEdit.protyle;
|
||||
}
|
||||
} else if (activeTab.model instanceof Custom && activeTab.model.data?.editor instanceof Protyle) {
|
||||
protyle = activeTab.model.data.editor.protyle;
|
||||
} else {
|
||||
return false;
|
||||
} else if (activeTab.model instanceof Custom && activeTab.model.editors?.length > 0) {
|
||||
if (range) {
|
||||
activeTab.model.editors.find(item => {
|
||||
if (item.protyle.element.contains(range.startContainer)) {
|
||||
protyle = item.protyle;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if (!protyle) {
|
||||
return;
|
||||
}
|
||||
} else if (!protyle) {
|
||||
if (!protyle && range) {
|
||||
|
|
|
@ -45,7 +45,7 @@ export const newCardModel = (options: {
|
|||
cardsData: options.data.cardsData,
|
||||
index: options.data.index,
|
||||
});
|
||||
this.data.editor = editor;
|
||||
customObj.editors.push(editor);
|
||||
// https://github.com/siyuan-note/siyuan/issues/9561#issuecomment-1794473512
|
||||
delete options.data.cardsData;
|
||||
delete options.data.index;
|
||||
|
@ -75,7 +75,8 @@ export const newCardModel = (options: {
|
|||
cardType: this.data.cardType,
|
||||
cardsData,
|
||||
});
|
||||
customObj.data.editor = editor;
|
||||
|
||||
customObj.editors.push(editor);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Tab} from "../Tab";
|
||||
import {Model} from "../Model";
|
||||
import {App} from "../../index";
|
||||
import {Protyle} from "../../protyle";
|
||||
|
||||
export class Custom extends Model {
|
||||
public element: Element;
|
||||
|
@ -12,6 +13,7 @@ export class Custom extends Model {
|
|||
public beforeDestroy: () => void;
|
||||
public resize: () => void;
|
||||
public update: () => void;
|
||||
public editors: Protyle[] = [];
|
||||
|
||||
constructor(options: {
|
||||
app: App,
|
||||
|
|
|
@ -24,9 +24,9 @@ export const getAllEditor = () => {
|
|||
editors.push(item.editors.unRefEdit);
|
||||
});
|
||||
models.custom.forEach(item => {
|
||||
if (item.data?.editor instanceof Protyle) {
|
||||
editors.push(item.data.editor);
|
||||
}
|
||||
item.editors?.forEach(eItem => {
|
||||
editors.push(eItem)
|
||||
})
|
||||
});
|
||||
models.backlink.forEach(item => {
|
||||
item.editors.forEach(editorItem => {
|
||||
|
|
|
@ -579,8 +579,6 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, brea
|
|||
json.instance = "Custom";
|
||||
json.customModelType = layout.type;
|
||||
json.customModelData = Object.assign({}, layout.data);
|
||||
// https://github.com/siyuan-note/siyuan/issues/9250
|
||||
delete json.customModelData.editor;
|
||||
}
|
||||
|
||||
if (layout instanceof Layout || layout instanceof Wnd) {
|
||||
|
|
Loading…
Add table
Reference in a new issue