This commit is contained in:
parent
f628ac35f8
commit
03d0773959
3 changed files with 31 additions and 14 deletions
|
@ -101,7 +101,7 @@ const openFile = (options: IOpenFileOptions) => {
|
|||
const initData = item.headElement?.getAttribute("data-initdata");
|
||||
if (initData) {
|
||||
const initObj = JSON.parse(initData);
|
||||
if (initObj.rootID === options.rootID || initObj.blockId === options.rootID) {
|
||||
if (initObj.rootId === options.rootID || initObj.blockId === options.rootID) {
|
||||
initObj.blockId = options.id
|
||||
initObj.mode = options.mode
|
||||
if (options.zoomIn) {
|
||||
|
|
|
@ -322,7 +322,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
|||
json.instance = "Tab";
|
||||
} else if (layout instanceof Editor) {
|
||||
json.blockId = layout.editor.protyle.block.id;
|
||||
json.rootID = layout.editor.protyle.block.rootID;
|
||||
json.rootId = layout.editor.protyle.block.rootID;
|
||||
json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview";
|
||||
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : "";
|
||||
json.instance = "Editor";
|
||||
|
@ -482,6 +482,15 @@ export const copyTab = (tab: Tab) => {
|
|||
tab: newTab,
|
||||
text: tab.model.text
|
||||
});
|
||||
} else if (!tab.model && tab.headElement) {
|
||||
const initData = JSON.parse(tab.headElement.getAttribute("data-initdata") || "{}");
|
||||
model = new Editor({
|
||||
tab: newTab,
|
||||
blockId: initData.rootId || initData.blockId,
|
||||
mode: initData.mode,
|
||||
action: typeof initData.action === "string" ? [initData.action] : initData.action,
|
||||
scrollAttr: initData.scrollAttr,
|
||||
});
|
||||
}
|
||||
newTab.addModel(model);
|
||||
}
|
||||
|
|
|
@ -156,21 +156,29 @@ const splitSubMenu = (tab: Tab) => {
|
|||
export const initTabMenu = (tab: Tab) => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
closeMenu(tab);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.split,
|
||||
submenu: splitSubMenu(tab)
|
||||
}).element);
|
||||
const model = tab.model;
|
||||
if (model) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.split,
|
||||
submenu: splitSubMenu(tab)
|
||||
}).element);
|
||||
if (model instanceof Editor) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy,
|
||||
icon: "iconCopy",
|
||||
type: "submenu",
|
||||
submenu: copySubMenu(model.editor.protyle.block.rootID, "", false)
|
||||
}).element);
|
||||
let rootId;
|
||||
if ((model && model instanceof Editor)) {
|
||||
rootId = model.editor.protyle.block.rootID
|
||||
} else {
|
||||
const initData = tab.headElement.getAttribute("data-initdata")
|
||||
if (initData) {
|
||||
const initDataObj = JSON.parse(initData);
|
||||
rootId = initDataObj.rootId || initDataObj.blockId
|
||||
}
|
||||
}
|
||||
if (rootId) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy,
|
||||
icon: "iconCopy",
|
||||
type: "submenu",
|
||||
submenu: copySubMenu(rootId, "", false)
|
||||
}).element);
|
||||
}
|
||||
if (tab.headElement.classList.contains("item--pin")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.unpin,
|
||||
|
|
Loading…
Add table
Reference in a new issue