mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
5cad47203a
commit
a6ef304562
5 changed files with 12 additions and 53 deletions
|
|
@ -2,7 +2,6 @@ import {Constants} from "./constants";
|
||||||
import {Menus} from "./menus";
|
import {Menus} from "./menus";
|
||||||
import {Model} from "./layout/Model";
|
import {Model} from "./layout/Model";
|
||||||
import {onGetConfig} from "./boot/onGetConfig";
|
import {onGetConfig} from "./boot/onGetConfig";
|
||||||
import "./assets/scss/base.scss";
|
|
||||||
import {initBlockPopover} from "./block/popover";
|
import {initBlockPopover} from "./block/popover";
|
||||||
import {account} from "./config/account";
|
import {account} from "./config/account";
|
||||||
import {addScript, addScriptSync} from "./protyle/util/addScript";
|
import {addScript, addScriptSync} from "./protyle/util/addScript";
|
||||||
|
|
@ -28,6 +27,7 @@ import {updateEditModeElement} from "./layout/topBar";
|
||||||
import {getSearch} from "./util/functions";
|
import {getSearch} from "./util/functions";
|
||||||
import {hideAllElements} from "./protyle/ui/hideElements";
|
import {hideAllElements} from "./protyle/ui/hideElements";
|
||||||
import {loadPlugins} from "./plugin/loader";
|
import {loadPlugins} from "./plugin/loader";
|
||||||
|
import "./assets/scss/base.scss";
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
public plugins: import("./plugin").Plugin[] = [];
|
public plugins: import("./plugin").Plugin[] = [];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {openEditorTab} from "../../../menus/util";
|
||||||
import {copySubMenu} from "../../../menus/commonMenuItem";
|
import {copySubMenu} from "../../../menus/commonMenuItem";
|
||||||
import {popTextCell} from "./cell";
|
import {popTextCell} from "./cell";
|
||||||
|
|
||||||
const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement, cellElement: HTMLElement) => {
|
export const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement, cellElement: HTMLElement) => {
|
||||||
const type = cellElement.getAttribute("data-dtype") as TAVCol;
|
const type = cellElement.getAttribute("data-dtype") as TAVCol;
|
||||||
const menu = new Menu("av-header-cell");
|
const menu = new Menu("av-header-cell");
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
|
@ -104,7 +104,7 @@ const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
|
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
|
||||||
const blockElement = hasClosestBlock(event.target);
|
const blockElement = hasClosestBlock(event.target);
|
||||||
if (!blockElement) {
|
if (!blockElement) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
||||||
if (addElement) {
|
if (addElement) {
|
||||||
|
|
@ -126,7 +126,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
parentID: blockElement.getAttribute("data-av-id"),
|
||||||
}]);
|
}]);
|
||||||
addCol(protyle, blockElement, id, type);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const addRect = addElement.getBoundingClientRect();
|
const addRect = addElement.getBoundingClientRect();
|
||||||
|
|
@ -180,7 +179,7 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
|
||||||
const rowId = rowElement.getAttribute("data-id");
|
const rowId = rowElement.getAttribute("data-id");
|
||||||
const menu = new Menu("av-row");
|
const menu = new Menu("av-row");
|
||||||
if (menu.isOpen) {
|
if (menu.isOpen) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
rowElement.classList.add("av__row--select");
|
rowElement.classList.add("av__row--select");
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
|
@ -246,29 +245,6 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addCol = (protyle: IProtyle, blockElement: HTMLElement, id: string, type: TAVCol) => {
|
|
||||||
let index = "0";
|
|
||||||
blockElement.querySelectorAll(".av__row--header .av__cell").forEach((item) => {
|
|
||||||
const dataIndex = item.getAttribute("data-index");
|
|
||||||
if (dataIndex > index) {
|
|
||||||
index = dataIndex;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
blockElement.querySelectorAll(".av__row").forEach((item, index) => {
|
|
||||||
let html = "";
|
|
||||||
if (index === 0) {
|
|
||||||
html = `<div class="av__cell" data-index="${index}" data-id="${id}" data-dtype="${type}" data-wrap="false" style="width: 200px;">
|
|
||||||
<svg><use xlink:href="#iconAlignLeft"></use></svg>
|
|
||||||
<span>Text</span>
|
|
||||||
</div>`;
|
|
||||||
} else {
|
|
||||||
html = `<div class="av__cell" data-index="${index}" style="width: 200px;"></div>`;
|
|
||||||
}
|
|
||||||
item.lastElementChild.insertAdjacentHTML("beforebegin", html);
|
|
||||||
});
|
|
||||||
showHeaderCellMenu(protyle, blockElement, blockElement.querySelector(".av__row--header").lastElementChild.previousElementSibling as HTMLElement);
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeCol = (cellElement: HTMLElement) => {
|
const removeCol = (cellElement: HTMLElement) => {
|
||||||
const index = cellElement.getAttribute("data-index");
|
const index = cellElement.getAttribute("data-index");
|
||||||
const blockElement = hasClosestBlock(cellElement);
|
const blockElement = hasClosestBlock(cellElement);
|
||||||
|
|
@ -276,23 +252,6 @@ const removeCol = (cellElement: HTMLElement) => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
blockElement.querySelectorAll(".av__row").forEach((item) => {
|
blockElement.querySelectorAll(".av__row").forEach((item) => {
|
||||||
item.querySelector(`[data-index="${index}"]`).remove;
|
item.querySelector(`[data-index="${index}"]`).remove();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const addAVRow = (blockElement: HTMLElement, ids: string[], previousID: string) => {
|
|
||||||
const rowElement = previousID ? blockElement.querySelector(`[data-id=${previousID}]`) : blockElement.querySelector(".av__row--header");
|
|
||||||
let html = "";
|
|
||||||
ids.forEach((id) => {
|
|
||||||
html += "<div class=\"av__row\"><div class=\"av__firstcol\"><svg><use xlink:href=\"#iconUncheck\"></use></svg></div>";
|
|
||||||
Array.from(rowElement.children).forEach((item: HTMLElement, index) => {
|
|
||||||
if (index === 0 || index === rowElement.childElementCount - 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
html += `<div class="av__cell" data-index="${index}" style="width: ${item.style.width};>${id}</div>`;
|
|
||||||
});
|
|
||||||
html += "<div></div></div>";
|
|
||||||
});
|
|
||||||
rowElement.insertAdjacentHTML("afterend", html);
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import {uploadLocalFiles} from "../upload";
|
||||||
import {insertHTML} from "./insertHTML";
|
import {insertHTML} from "./insertHTML";
|
||||||
import {isBrowser} from "../../util/functions";
|
import {isBrowser} from "../../util/functions";
|
||||||
import {hideElements} from "../ui/hideElements";
|
import {hideElements} from "../ui/hideElements";
|
||||||
import {addAVRow} from "../render/av/action";
|
|
||||||
|
|
||||||
const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
|
const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
|
||||||
isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
|
isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
|
||||||
|
|
@ -814,7 +813,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
id: targetElement.getAttribute("data-node-id"),
|
id: targetElement.getAttribute("data-node-id"),
|
||||||
parentID: targetElement.getAttribute("data-av-id"),
|
parentID: targetElement.getAttribute("data-av-id"),
|
||||||
}]);
|
}]);
|
||||||
addAVRow(blockElement, sourceIds, previousID);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export const resize = (protyle: IProtyle) => {
|
||||||
const avHeaderElement = item.firstElementChild.firstElementChild as HTMLElement;
|
const avHeaderElement = item.firstElementChild.firstElementChild as HTMLElement;
|
||||||
avHeaderElement.style.paddingLeft = paddingLeft;
|
avHeaderElement.style.paddingLeft = paddingLeft;
|
||||||
avHeaderElement.style.paddingRight = paddingRight;
|
avHeaderElement.style.paddingRight = paddingRight;
|
||||||
const avBodyElement = item.querySelector(".av__scroll").firstElementChild as HTMLElement
|
const avBodyElement = item.querySelector(".av__scroll").firstElementChild as HTMLElement;
|
||||||
avBodyElement.style.paddingLeft = paddingLeft;
|
avBodyElement.style.paddingLeft = paddingLeft;
|
||||||
avBodyElement.style.paddingRight = paddingRight;
|
avBodyElement.style.paddingRight = paddingRight;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@ import {onGet} from "../util/onGet";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {getAllModels} from "../../layout/getAll";
|
import {getAllModels} from "../../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
import {avRender, refreshAV} from "../render/av/render";
|
||||||
import {removeFoldHeading} from "../util/heading";
|
import {removeFoldHeading} from "../util/heading";
|
||||||
import {genEmptyElement, genSBElement} from "../../block/util";
|
import {genEmptyElement, genSBElement} from "../../block/util";
|
||||||
import {hideElements} from "../ui/hideElements";
|
import {hideElements} from "../ui/hideElements";
|
||||||
import {reloadProtyle} from "../util/reload";
|
import {reloadProtyle} from "../util/reload";
|
||||||
import {countBlockWord} from "../../layout/status";
|
import {countBlockWord} from "../../layout/status";
|
||||||
import {needSubscribe} from "../../util/needSubscribe";
|
import {needSubscribe} from "../../util/needSubscribe";
|
||||||
import {avRender} from "../render/av/render";
|
|
||||||
|
|
||||||
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
|
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
|
||||||
// 移动到其他文档中,该块需移除
|
// 移动到其他文档中,该块需移除
|
||||||
|
|
@ -289,6 +289,8 @@ const promiseTransaction = () => {
|
||||||
// });
|
// });
|
||||||
// 更新引用块
|
// 更新引用块
|
||||||
updateRef(protyle, operation.id);
|
updateRef(protyle, operation.id);
|
||||||
|
} else if (["addAttrViewCol", "insertAttrViewBlock"].includes(operation.action)) {
|
||||||
|
refreshAV(protyle, operation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -649,10 +651,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||||
});
|
});
|
||||||
// 更新 ws 引用块
|
// 更新 ws 引用块
|
||||||
updateRef(protyle, operation.id);
|
updateRef(protyle, operation.id);
|
||||||
return;
|
} else if (operation.action === "append") {
|
||||||
}
|
|
||||||
if (operation.action === "append") {
|
|
||||||
reloadProtyle(protyle, false);
|
reloadProtyle(protyle, false);
|
||||||
|
} else if (["addAttrViewCol", "insertAttrViewBlock"].includes(operation.action)) {
|
||||||
|
refreshAV(protyle, operation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue