mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-11 22:51:20 +08:00
This commit is contained in:
parent
a6728a5db5
commit
f132067952
@ -44,7 +44,7 @@ export const openMenuPanel = (protyle: IProtyle,
|
|||||||
if (options && options.cellElement) {
|
if (options && options.cellElement) {
|
||||||
const cellRect = options.cellElement.getBoundingClientRect();
|
const cellRect = options.cellElement.getBoundingClientRect();
|
||||||
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
|
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
|
||||||
bindSelectEvent(protyle, data.view, menuElement, options);
|
bindSelectEvent(protyle, data, menuElement, options);
|
||||||
menuElement.querySelector("input").select();
|
menuElement.querySelector("input").select();
|
||||||
menuElement.querySelector("input").focus();
|
menuElement.querySelector("input").focus();
|
||||||
} else {
|
} else {
|
||||||
@ -110,7 +110,7 @@ export const openMenuPanel = (protyle: IProtyle,
|
|||||||
data: oldData,
|
data: oldData,
|
||||||
}]);
|
}]);
|
||||||
menuElement.innerHTML = getSelectHTML(data.view, options);
|
menuElement.innerHTML = getSelectHTML(data.view, options);
|
||||||
bindSelectEvent(protyle, data.view, menuElement, options);
|
bindSelectEvent(protyle, data, menuElement, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sourceId = sourceElement.dataset.id;
|
const sourceId = sourceElement.dataset.id;
|
||||||
@ -475,11 +475,11 @@ export const openMenuPanel = (protyle: IProtyle,
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "setSelectCol") {
|
} else if (type === "setSelectCol") {
|
||||||
setSelectCol(protyle, data.view, options, target);
|
setSelectCol(protyle, data, options, target);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "addSelectColAndCell") {
|
} else if (type === "addSelectColAndCell") {
|
||||||
addSelectColAndCell(protyle, data.view, options, target, menuElement);
|
addSelectColAndCell(protyle, data, options, target, menuElement);
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
@ -101,7 +101,7 @@ export const removeSelectCell = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
}]);
|
}]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
export const setSelectCol = (protyle: IProtyle, data: IAV, options: {
|
||||||
cellElement: HTMLElement;
|
cellElement: HTMLElement;
|
||||||
}, target: HTMLElement,) => {
|
}, target: HTMLElement,) => {
|
||||||
const menuElement = hasClosestByClassName(target, "b3-menu");
|
const menuElement = hasClosestByClassName(target, "b3-menu");
|
||||||
@ -133,7 +133,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
newName: name
|
newName: name
|
||||||
},
|
},
|
||||||
}]);
|
}]);
|
||||||
data.columns.find(column => {
|
data.view.columns.find(column => {
|
||||||
if (column.id === colId) {
|
if (column.id === colId) {
|
||||||
column.options.find((item) => {
|
column.options.find((item) => {
|
||||||
if (item.name === name) {
|
if (item.name === name) {
|
||||||
@ -144,7 +144,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data.rows.find(row => {
|
data.view.rows.find(row => {
|
||||||
if (row.id === options.cellElement.parentElement.dataset.id) {
|
if (row.id === options.cellElement.parentElement.dataset.id) {
|
||||||
row.cells.find(cell => {
|
row.cells.find(cell => {
|
||||||
if (cell.id === options.cellElement.dataset.id) {
|
if (cell.id === options.cellElement.dataset.id) {
|
||||||
@ -160,7 +160,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuElement.innerHTML = getSelectHTML(data, options);
|
menuElement.innerHTML = getSelectHTML(data.view, options);
|
||||||
bindSelectEvent(protyle, data, menuElement, options);
|
bindSelectEvent(protyle, data, menuElement, options);
|
||||||
});
|
});
|
||||||
if (menu.isOpen) {
|
if (menu.isOpen) {
|
||||||
@ -177,7 +177,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
click() {
|
click() {
|
||||||
confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.confirmDelete, () => {
|
confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.confirmDelete, () => {
|
||||||
let colOptions: { name: string, color: string }[] = [];
|
let colOptions: { name: string, color: string }[] = [];
|
||||||
data.columns.find(column => {
|
data.view.columns.find(column => {
|
||||||
if (column.id === colId) {
|
if (column.id === colId) {
|
||||||
colOptions = column.options;
|
colOptions = column.options;
|
||||||
return true;
|
return true;
|
||||||
@ -187,7 +187,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "removeAttrViewColOption",
|
action: "removeAttrViewColOption",
|
||||||
id: colId,
|
id: colId,
|
||||||
parentID: data.id,
|
avID: data.id,
|
||||||
data: newName,
|
data: newName,
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewColOptions",
|
action: "updateAttrViewColOptions",
|
||||||
@ -201,7 +201,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data.rows.find(row => {
|
data.view.rows.find(row => {
|
||||||
if (row.id === options.cellElement.parentElement.dataset.id) {
|
if (row.id === options.cellElement.parentElement.dataset.id) {
|
||||||
row.cells.find(cell => {
|
row.cells.find(cell => {
|
||||||
if (cell.id === options.cellElement.dataset.id) {
|
if (cell.id === options.cellElement.dataset.id) {
|
||||||
@ -217,7 +217,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuElement.innerHTML = getSelectHTML(data, options);
|
menuElement.innerHTML = getSelectHTML(data.view, options);
|
||||||
bindSelectEvent(protyle, data, menuElement, options);
|
bindSelectEvent(protyle, data, menuElement, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
},
|
},
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
data.columns.find(column => {
|
data.view.columns.find(column => {
|
||||||
if (column.id === colId) {
|
if (column.id === colId) {
|
||||||
column.options.find((item) => {
|
column.options.find((item) => {
|
||||||
if (item.name === name) {
|
if (item.name === name) {
|
||||||
@ -268,7 +268,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data.rows.find(row => {
|
data.view.rows.find(row => {
|
||||||
if (row.id === options.cellElement.parentElement.dataset.id) {
|
if (row.id === options.cellElement.parentElement.dataset.id) {
|
||||||
row.cells.find(cell => {
|
row.cells.find(cell => {
|
||||||
if (cell.id === options.cellElement.dataset.id) {
|
if (cell.id === options.cellElement.dataset.id) {
|
||||||
@ -287,7 +287,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
});
|
});
|
||||||
name = inputElement.value;
|
name = inputElement.value;
|
||||||
color = (index + 1).toString();
|
color = (index + 1).toString();
|
||||||
menuElement.innerHTML = getSelectHTML(data, options);
|
menuElement.innerHTML = getSelectHTML(data.view, options);
|
||||||
bindSelectEvent(protyle, data, menuElement, options);
|
bindSelectEvent(protyle, data, menuElement, options);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -304,13 +304,13 @@ export const setSelectCol = (protyle: IProtyle, data: IAVTable, options: {
|
|||||||
inputElement.select();
|
inputElement.select();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const bindSelectEvent = (protyle: IProtyle, data: IAVTable, menuElement: HTMLElement, options: {
|
export const bindSelectEvent = (protyle: IProtyle, data: IAV, menuElement: HTMLElement, options: {
|
||||||
cellElement: HTMLElement
|
cellElement: HTMLElement
|
||||||
}) => {
|
}) => {
|
||||||
const inputElement = menuElement.querySelector("input");
|
const inputElement = menuElement.querySelector("input");
|
||||||
const colId = options.cellElement.dataset.colId;
|
const colId = options.cellElement.dataset.colId;
|
||||||
let colData: IAVColumn;
|
let colData: IAVColumn;
|
||||||
data.columns.find((item: IAVColumn) => {
|
data.view.columns.find((item: IAVColumn) => {
|
||||||
if (item.id === colId) {
|
if (item.id === colId) {
|
||||||
colData = item;
|
colData = item;
|
||||||
return;
|
return;
|
||||||
@ -342,19 +342,19 @@ export const bindSelectEvent = (protyle: IProtyle, data: IAVTable, menuElement:
|
|||||||
}
|
}
|
||||||
addSelectColAndCell(protyle, data, options, currentElement, menuElement);
|
addSelectColAndCell(protyle, data, options, currentElement, menuElement);
|
||||||
} else if (event.key === "Backspace" && inputElement.value === "") {
|
} else if (event.key === "Backspace" && inputElement.value === "") {
|
||||||
removeSelectCell(protyle, data, options, inputElement.previousElementSibling as HTMLElement);
|
removeSelectCell(protyle, data.view, options, inputElement.previousElementSibling as HTMLElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options: {
|
export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
|
||||||
cellElement: HTMLElement
|
cellElement: HTMLElement
|
||||||
}, currentElement: HTMLElement, menuElement: HTMLElement) => {
|
}, currentElement: HTMLElement, menuElement: HTMLElement) => {
|
||||||
const rowID = options.cellElement.parentElement.dataset.id;
|
const rowID = options.cellElement.parentElement.dataset.id;
|
||||||
const colId = options.cellElement.dataset.colId;
|
const colId = options.cellElement.dataset.colId;
|
||||||
const cellId = options.cellElement.dataset.id;
|
const cellId = options.cellElement.dataset.id;
|
||||||
let colData: IAVColumn;
|
let colData: IAVColumn;
|
||||||
data.columns.find((item: IAVColumn) => {
|
data.view.columns.find((item: IAVColumn) => {
|
||||||
if (item.id === colId) {
|
if (item.id === colId) {
|
||||||
colData = item;
|
colData = item;
|
||||||
return;
|
return;
|
||||||
@ -364,7 +364,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
|
|||||||
colData.options = [];
|
colData.options = [];
|
||||||
}
|
}
|
||||||
let cellData: IAVCell;
|
let cellData: IAVCell;
|
||||||
data.rows.find(row => {
|
data.view.rows.find(row => {
|
||||||
if (row.id === rowID) {
|
if (row.id === rowID) {
|
||||||
row.cells.find(cell => {
|
row.cells.find(cell => {
|
||||||
if (cell.id === cellId) {
|
if (cell.id === cellId) {
|
||||||
@ -423,7 +423,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
|
|||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewColOption",
|
action: "removeAttrViewColOption",
|
||||||
id: colId,
|
id: colId,
|
||||||
parentID: data.id,
|
avID: data.id,
|
||||||
data: currentElement.dataset.name,
|
data: currentElement.dataset.name,
|
||||||
}]);
|
}]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -653,7 +653,8 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||||||
reloadProtyle(protyle, false);
|
reloadProtyle(protyle, false);
|
||||||
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
||||||
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
||||||
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName"].includes(operation.action)) {
|
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
|
||||||
|
"setAttrViewSorts"].includes(operation.action)) {
|
||||||
refreshAV(protyle, operation);
|
refreshAV(protyle, operation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user