mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
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");
|
const initData = item.headElement?.getAttribute("data-initdata");
|
||||||
if (initData) {
|
if (initData) {
|
||||||
const initObj = JSON.parse(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.blockId = options.id
|
||||||
initObj.mode = options.mode
|
initObj.mode = options.mode
|
||||||
if (options.zoomIn) {
|
if (options.zoomIn) {
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
||||||
json.instance = "Tab";
|
json.instance = "Tab";
|
||||||
} else if (layout instanceof Editor) {
|
} else if (layout instanceof Editor) {
|
||||||
json.blockId = layout.editor.protyle.block.id;
|
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.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview";
|
||||||
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : "";
|
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : "";
|
||||||
json.instance = "Editor";
|
json.instance = "Editor";
|
||||||
|
|
@ -482,6 +482,15 @@ export const copyTab = (tab: Tab) => {
|
||||||
tab: newTab,
|
tab: newTab,
|
||||||
text: tab.model.text
|
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);
|
newTab.addModel(model);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,21 +156,29 @@ const splitSubMenu = (tab: Tab) => {
|
||||||
export const initTabMenu = (tab: Tab) => {
|
export const initTabMenu = (tab: Tab) => {
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
closeMenu(tab);
|
closeMenu(tab);
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
label: window.siyuan.languages.split,
|
||||||
|
submenu: splitSubMenu(tab)
|
||||||
|
}).element);
|
||||||
const model = tab.model;
|
const model = tab.model;
|
||||||
if (model) {
|
let rootId;
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
if ((model && model instanceof Editor)) {
|
||||||
label: window.siyuan.languages.split,
|
rootId = model.editor.protyle.block.rootID
|
||||||
submenu: splitSubMenu(tab)
|
} else {
|
||||||
}).element);
|
const initData = tab.headElement.getAttribute("data-initdata")
|
||||||
if (model instanceof Editor) {
|
if (initData) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
const initDataObj = JSON.parse(initData);
|
||||||
label: window.siyuan.languages.copy,
|
rootId = initDataObj.rootId || initDataObj.blockId
|
||||||
icon: "iconCopy",
|
|
||||||
type: "submenu",
|
|
||||||
submenu: copySubMenu(model.editor.protyle.block.rootID, "", false)
|
|
||||||
}).element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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")) {
|
if (tab.headElement.classList.contains("item--pin")) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.unpin,
|
label: window.siyuan.languages.unpin,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue