Vanessa 2025-08-10 17:39:35 +08:00
parent 73b80d3c82
commit 5a1c885e76
9 changed files with 14 additions and 3 deletions

View file

@ -281,6 +281,7 @@ export class Gutter {
avID,
previousID,
srcs: [{
itemID: Lute.NewNodeID(),
id: srcIDs[0],
isDetached: true,
content: ""

View file

@ -571,6 +571,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
const rowId = item.getAttribute("data-id");
const blockValue = genCellValueByElement("block", item.querySelector('.av__cell[data-dtype="block"]'));
srcs.push({
itemID: Lute.NewNodeID(),
content: blockValue.block.content,
id: rowId,
isDetached: blockValue.isDetached,

View file

@ -10,6 +10,7 @@ export const addFilesToDatabase = (fileLiElements: Element[]) => {
const id = item.getAttribute("data-node-id");
if (id) {
srcs.push({
itemID: Lute.NewNodeID(),
id,
isDetached: false
});
@ -40,6 +41,7 @@ export const addEditorToDatabase = (protyle: IProtyle, range: Range, type?: stri
action: "insertAttrViewBlock",
avID,
srcs: [{
itemID: Lute.NewNodeID(),
id: protyle.block.rootID,
isDetached: false
}],
@ -81,6 +83,7 @@ export const addEditorToDatabase = (protyle: IProtyle, range: Range, type?: stri
ids.forEach(item => {
srcIDs.push(item);
srcs.push({
itemID: Lute.NewNodeID(),
id: item,
isDetached: false
});

View file

@ -425,6 +425,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector
action: "insertAttrViewBlock",
avID: menuElement.firstElementChild.getAttribute("data-av-id"),
srcs: [{
itemID: Lute.NewNodeID(),
id: rowId,
isDetached: true,
content

View file

@ -718,14 +718,14 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
const groupQuery = operation.groupID ? `[data-group-id="${operation.groupID}"]` : "";
if (item.getAttribute("data-av-type") === "gallery") {
operation.srcs.forEach(srcItem => {
const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.id}"]`)?.querySelector(".av__gallery-fields");
const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.itemID}"]`)?.querySelector(".av__gallery-fields");
if (filesElement && filesElement.querySelector('[data-dtype="block"]')?.getAttribute("data-empty") === "true") {
filesElement.classList.add("av__gallery-fields--edit");
}
});
}
if (operation.srcs.length === 1) {
const popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].id}"] .av__cell[data-dtype="block"]`) as HTMLElement;
const popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`) as HTMLElement;
if (popCellElement) {
popTextCell(protyle, [popCellElement], "block");
}

View file

@ -360,6 +360,7 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
avID,
previousID: item.previousElementSibling?.getAttribute("data-id") || "",
srcs: [{
itemID: Lute.NewNodeID(),
id: item.getAttribute("data-id"),
isDetached: blockValue.isDetached,
content: blockValue.block.content
@ -405,6 +406,7 @@ export const insertRows = (options: {
const newNodeID = Lute.NewNodeID();
srcIDs.push(newNodeID);
srcs.push({
itemID: Lute.NewNodeID(),
id: newNodeID,
isDetached: true,
content: "",

View file

@ -1023,6 +1023,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const id = item.getAttribute("data-node-id");
sourceIds.push(id);
srcs.push({
itemID: Lute.NewNodeID(),
id,
isDetached: false,
});
@ -1320,6 +1321,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const groupID = bodyElement && bodyElement.getAttribute("data-group-id");
ids.forEach(id => {
srcs.push({
itemID: Lute.NewNodeID(),
id,
isDetached: false,
});

View file

@ -854,7 +854,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
}
return;
}
if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
if (["addAttrViewCol", "updateAttrViewCol", "updateAttrViewColOptions",
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",

View file

@ -556,6 +556,7 @@ interface IOperation {
}
interface IOperationSrcs {
itemID: string,
id: string,
content?: string,
isDetached: boolean