This commit is contained in:
parent
5dce035c47
commit
6430783877
7 changed files with 85 additions and 42 deletions
|
@ -310,14 +310,15 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.general.addToDatabase.custom, event)) {
|
||||
if (protyle.title?.editElement.contains(range.startContainer)) {
|
||||
openSearchAV("", protyle.breadcrumb.element, (listItemElement) => {
|
||||
const sourceIds: string[] = [protyle.block.rootID];
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
ignoreFillFilter: true,
|
||||
srcIDs: sourceIds,
|
||||
isDetached: false,
|
||||
srcs: [{
|
||||
id: protyle.block.rootID,
|
||||
isDetached: false
|
||||
}],
|
||||
blockID: listItemElement.dataset.nodeId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -325,7 +326,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
data: dayjs().format("YYYYMMDDHHmmss"),
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
srcIDs: [protyle.block.rootID],
|
||||
avID,
|
||||
}]);
|
||||
focusByRange(range);
|
||||
|
@ -342,17 +343,21 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
}
|
||||
}
|
||||
openSearchAV("", selectElement[0] as HTMLElement, (listItemElement) => {
|
||||
const sourceIds: string[] = [];
|
||||
const srcIDs: string[] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
selectElement.forEach(item => {
|
||||
sourceIds.push(item.getAttribute("data-node-id"));
|
||||
srcIDs.push(item.getAttribute("data-node-id"));
|
||||
srcs.push({
|
||||
id: item.getAttribute("data-node-id"),
|
||||
isDetached: false
|
||||
});
|
||||
});
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
ignoreFillFilter: true,
|
||||
srcIDs: sourceIds,
|
||||
isDetached: false,
|
||||
srcs,
|
||||
blockID: listItemElement.dataset.blockId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -360,7 +365,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
data: dayjs().format("YYYYMMDDHHmmss"),
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
srcIDs,
|
||||
avID,
|
||||
}]);
|
||||
focusByRange(range);
|
||||
|
|
|
@ -101,7 +101,7 @@ export class Gutter {
|
|||
if (item.querySelector("iframe")) {
|
||||
const embedElement = genEmptyElement();
|
||||
embedElement.classList.add("protyle-wysiwyg--select");
|
||||
getContenteditableElement(embedElement).innerHTML = `<svg class="svg"><use xlink:href="${ buttonElement.querySelector("use").getAttribute("xlink:href")}"></use></svg> ${getLangByType(type)}`;
|
||||
getContenteditableElement(embedElement).innerHTML = `<svg class="svg"><use xlink:href="${buttonElement.querySelector("use").getAttribute("xlink:href")}"></use></svg> ${getLangByType(type)}`;
|
||||
ghostElement.append(embedElement);
|
||||
} else {
|
||||
ghostElement.append(item.cloneNode(true));
|
||||
|
@ -235,8 +235,11 @@ export class Gutter {
|
|||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID,
|
||||
srcIDs,
|
||||
isDetached: true,
|
||||
srcs: [{
|
||||
id: srcIDs[0],
|
||||
isDetached: true,
|
||||
content: ""
|
||||
}],
|
||||
blockID: id,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -817,17 +820,21 @@ export class Gutter {
|
|||
icon: "iconDatabase",
|
||||
click: () => {
|
||||
openSearchAV("", selectsElement[0] as HTMLElement, (listItemElement) => {
|
||||
const sourceIds: string[] = [];
|
||||
const srcIDs: string[] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
selectsElement.forEach(item => {
|
||||
sourceIds.push(item.getAttribute("data-node-id"));
|
||||
srcIDs.push(item.getAttribute("data-node-id"));
|
||||
srcs.push({
|
||||
id:item.getAttribute("data-node-id"),
|
||||
isDetached: false,
|
||||
});
|
||||
});
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
srcIDs: sourceIds,
|
||||
srcs,
|
||||
ignoreFillFilter: true,
|
||||
isDetached: false,
|
||||
blockID: listItemElement.dataset.blockId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -835,7 +842,7 @@ export class Gutter {
|
|||
data: dayjs().format("YYYYMMDDHHmmss"),
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
srcIDs,
|
||||
avID,
|
||||
}]);
|
||||
focusByRange(range);
|
||||
|
@ -1285,14 +1292,15 @@ export class Gutter {
|
|||
icon: "iconDatabase",
|
||||
click: () => {
|
||||
openSearchAV("", nodeElement as HTMLElement, (listItemElement) => {
|
||||
const sourceIds: string[] = [id];
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
srcIDs: sourceIds,
|
||||
srcs:[{
|
||||
id,
|
||||
isDetached: false
|
||||
}],
|
||||
ignoreFillFilter: true,
|
||||
isDetached: false,
|
||||
blockID: listItemElement.dataset.blockId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -1300,7 +1308,7 @@ export class Gutter {
|
|||
data: dayjs().format("YYYYMMDDHHmmss"),
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
srcIDs: [id],
|
||||
avID,
|
||||
}]);
|
||||
focusByRange(range);
|
||||
|
|
|
@ -52,14 +52,15 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
icon: "iconDatabase",
|
||||
click: () => {
|
||||
openSearchAV("", protyle.breadcrumb.element, (listItemElement) => {
|
||||
const sourceIds: string[] = [response.data.rootID];
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
ignoreFillFilter: true,
|
||||
srcIDs: sourceIds,
|
||||
isDetached: false,
|
||||
srcs: [{
|
||||
id: response.data.rootID,
|
||||
isDetached: false
|
||||
}],
|
||||
blockID: listItemElement.dataset.nodeId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -67,7 +68,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
data: dayjs().format("YYYYMMDDHHmmss"),
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
srcIDs: [response.data.rootID],
|
||||
avID,
|
||||
}]);
|
||||
focusByRange(range);
|
||||
|
|
|
@ -4,7 +4,7 @@ import {transaction} from "../../wysiwyg/transaction";
|
|||
import {openEditorTab} from "../../../menus/util";
|
||||
import {copySubMenu} from "../../../menus/commonMenuItem";
|
||||
import {
|
||||
addDragFill,
|
||||
addDragFill, genCellValueByElement,
|
||||
getCellText,
|
||||
getTypeByCellElement,
|
||||
popTextCell,
|
||||
|
@ -277,13 +277,15 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
icon: "iconDatabase",
|
||||
click() {
|
||||
openSearchAV(blockElement.getAttribute("data-av-id"), rowElements[0] as HTMLElement, (listItemElement) => {
|
||||
const srcs: { id: string, content: string }[] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
const sourceIds: string[] = [];
|
||||
rowElements.forEach(item => {
|
||||
const rowId = item.getAttribute("data-id")
|
||||
const rowId = item.getAttribute("data-id")
|
||||
const blockValue = genCellValueByElement("block", item.querySelector(".av__cell[data-block-id]"));
|
||||
srcs.push({
|
||||
content: item.querySelector(".av__cell[data-block-id] .av__celltext").textContent.trim(),
|
||||
id: rowId
|
||||
content: blockValue.block.content,
|
||||
id: rowId,
|
||||
isDetached: blockValue.isDetached,
|
||||
});
|
||||
sourceIds.push(rowId);
|
||||
})
|
||||
|
@ -293,7 +295,6 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
avID,
|
||||
ignoreFillFilter: true,
|
||||
srcs,
|
||||
isDetached: false,
|
||||
blockID: listItemElement.dataset.nodeId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
|
|
@ -319,12 +319,16 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
|||
blockIds.push(item.querySelector(".av__cell[data-block-id]").getAttribute("data-block-id"));
|
||||
});
|
||||
rowElements.forEach(item => {
|
||||
const blockValue = genCellValueByElement("block", item.querySelector(".av__cell[data-block-id]"));
|
||||
undoOperations.push({
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID: item.previousElementSibling?.getAttribute("data-id") || "",
|
||||
srcIDs: [item.getAttribute("data-id")],
|
||||
isDetached: item.querySelector('.av__cell[data-detached="true"]') ? true : false,
|
||||
srcs: [{
|
||||
id: item.getAttribute("data-id"),
|
||||
isDetached: blockValue.isDetached,
|
||||
content: blockValue.block.content
|
||||
}],
|
||||
blockID: blockElement.dataset.nodeId
|
||||
});
|
||||
});
|
||||
|
@ -354,16 +358,22 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
|||
export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count: number, previousID: string) => {
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const srcIDs: string[] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
new Array(count).fill(0).forEach(() => {
|
||||
srcIDs.push(Lute.NewNodeID());
|
||||
const newNodeID = Lute.NewNodeID();
|
||||
srcIDs.push(newNodeID);
|
||||
srcs.push({
|
||||
id: newNodeID,
|
||||
isDetached: true,
|
||||
content: "",
|
||||
});
|
||||
});
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID,
|
||||
srcIDs,
|
||||
isDetached: true,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
|
|
@ -799,6 +799,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
|
||||
const sourceIds: string [] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
sourceElements.forEach(item => {
|
||||
item.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
|
||||
item.removeAttribute("select-start");
|
||||
|
@ -807,7 +808,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
|
||||
markItem.outerHTML = markItem.innerHTML;
|
||||
});
|
||||
sourceIds.push(item.getAttribute("data-node-id"));
|
||||
const id = item.getAttribute("data-node-id")
|
||||
sourceIds.push(id);
|
||||
srcs.push({
|
||||
id,
|
||||
isDetached: false,
|
||||
})
|
||||
});
|
||||
|
||||
hideElements(["gutter"], protyle);
|
||||
|
@ -900,8 +906,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID,
|
||||
srcIDs: sourceIds,
|
||||
isDetached: false,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
@ -967,12 +972,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
ids.forEach(id => {
|
||||
srcs.push({
|
||||
id,
|
||||
isDetached: false,
|
||||
});
|
||||
});
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID,
|
||||
srcIDs: ids,
|
||||
isDetached: false,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
|
|
9
app/src/types/index.d.ts
vendored
9
app/src/types/index.d.ts
vendored
|
@ -480,13 +480,20 @@ interface IOperation {
|
|||
isDetached?: boolean // insertAttrViewBlock 专享
|
||||
ignoreFillFilter?: boolean // insertAttrViewBlock 专享
|
||||
srcIDs?: string[] // removeAttrViewBlock 专享
|
||||
srcs?: { id: string, content: string }[] // insertAttrViewBlock 专享
|
||||
srcs?: IOperationSrcs[] // insertAttrViewBlock 专享
|
||||
name?: string // addAttrViewCol 专享
|
||||
type?: TAVCol // addAttrViewCol 专享
|
||||
deckID?: string // add/removeFlashcards 专享
|
||||
blockIDs?: string[] // add/removeFlashcards 专享
|
||||
}
|
||||
|
||||
interface IOperationSrcs {
|
||||
id: string,
|
||||
content?: string,
|
||||
isDetached: boolean
|
||||
}
|
||||
|
||||
|
||||
interface IObject {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue