mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
f68857fda5
commit
ebd399c018
11 changed files with 13 additions and 81 deletions
|
|
@ -4,7 +4,6 @@ import {transaction} from "../../wysiwyg/transaction";
|
||||||
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
const menu = new Menu("av-header-add");
|
const menu = new Menu("av-header-add");
|
||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
|
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
icon: "iconAlignLeft",
|
icon: "iconAlignLeft",
|
||||||
label: window.siyuan.languages.text,
|
label: window.siyuan.languages.text,
|
||||||
|
|
@ -14,14 +13,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Text",
|
name: "Text",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
type: "text",
|
type: "text",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -34,14 +31,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Number",
|
name: "Number",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
type: "number",
|
type: "number",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -54,14 +49,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Select",
|
name: "Select",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
type: "select",
|
type: "select",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -74,14 +67,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Multi-select",
|
name: "Multi-select",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
type: "mSelect",
|
type: "mSelect",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -94,14 +85,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Date",
|
name: "Date",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
type: "date",
|
type: "date",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC
|
||||||
}
|
}
|
||||||
const avMaskElement = document.querySelector(".av__mask");
|
const avMaskElement = document.querySelector(".av__mask");
|
||||||
const cellId = cellElement.getAttribute("data-id");
|
const cellId = cellElement.getAttribute("data-id");
|
||||||
const avId = blockElement.getAttribute("data-av-id");
|
const colId = cellElement.getAttribute("data-col-id");
|
||||||
const rowId = rowElement.getAttribute("data-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
let inputValue: string | number = (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value;
|
let inputValue: string | number = (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value;
|
||||||
let oldValue: string | number = cellElement.textContent.trim();
|
let oldValue: string | number = cellElement.textContent.trim();
|
||||||
if (type === "number") {
|
if (type === "number") {
|
||||||
|
|
@ -67,16 +67,16 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
avID,
|
||||||
parentID: avId,
|
keyID: colId,
|
||||||
data: {
|
data: {
|
||||||
[type]: {content: inputValue}
|
[type]: {content: inputValue}
|
||||||
}
|
}
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
avID,
|
||||||
parentID: avId,
|
keyID: colId,
|
||||||
data: {
|
data: {
|
||||||
[type]: {content: oldValue}
|
[type]: {content: oldValue}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
const type = cellElement.getAttribute("data-dtype") as TAVCol;
|
const type = cellElement.getAttribute("data-dtype") as TAVCol;
|
||||||
const colId = cellElement.getAttribute("data-col-id");
|
const colId = cellElement.getAttribute("data-col-id");
|
||||||
const avId = blockElement.getAttribute("data-av-id");
|
const avId = blockElement.getAttribute("data-av-id");
|
||||||
const viewId = blockElement.querySelector(".item--focus").getAttribute("data-id");
|
|
||||||
const menu = new Menu("av-header-cell", () => {
|
const menu = new Menu("av-header-cell", () => {
|
||||||
const newValue = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
|
const newValue = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
|
||||||
if (newValue === cellElement.textContent.trim()) {
|
if (newValue === cellElement.textContent.trim()) {
|
||||||
|
|
@ -76,14 +75,12 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
name: newValue,
|
name: newValue,
|
||||||
type,
|
type,
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
name: cellElement.textContent.trim(),
|
name: cellElement.textContent.trim(),
|
||||||
type,
|
type,
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -110,7 +107,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
|
||||||
data: [{
|
data: [{
|
||||||
column: colId,
|
column: colId,
|
||||||
order: "ASC"
|
order: "ASC"
|
||||||
|
|
@ -118,7 +114,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
|
||||||
data: response.data.view.sorts
|
data: response.data.view.sorts
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
@ -132,7 +127,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
|
||||||
data: [{
|
data: [{
|
||||||
column: colId,
|
column: colId,
|
||||||
order: "DESC"
|
order: "DESC"
|
||||||
|
|
@ -140,7 +134,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
|
||||||
data: response.data.view.sorts
|
data: response.data.view.sorts
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
@ -169,12 +162,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: avData.viewID,
|
|
||||||
data: [filter]
|
data: [filter]
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: avData.viewID,
|
|
||||||
data: []
|
data: []
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
@ -197,13 +188,11 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: true
|
data: true
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: false
|
data: false
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
@ -223,12 +212,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
}], [{
|
}], [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: cellElement.textContent.trim(),
|
name: cellElement.textContent.trim(),
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
type: type,
|
type: type,
|
||||||
id: colId
|
id: colId
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -247,13 +234,11 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "setAttrViewColWrap",
|
action: "setAttrViewColWrap",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: inputElement.checked
|
data: inputElement.checked
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewColWrap",
|
action: "setAttrViewColWrap",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: !inputElement.checked
|
data: !inputElement.checked
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,10 @@ export const setFilter = (options: {
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: options.data.view.filters
|
data: options.data.view.filters
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: oldFilters
|
data: oldFilters
|
||||||
}]);
|
}]);
|
||||||
const menuElement = hasClosestByClassName(options.target, "b3-menu");
|
const menuElement = hasClosestByClassName(options.target, "b3-menu");
|
||||||
|
|
@ -177,12 +175,10 @@ export const setFilter = (options: {
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: options.data.view.filters
|
data: options.data.view.filters
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: oldFilters
|
data: oldFilters
|
||||||
}]);
|
}]);
|
||||||
const menuElement = hasClosestByClassName(options.target, "b3-menu");
|
const menuElement = hasClosestByClassName(options.target, "b3-menu");
|
||||||
|
|
@ -255,12 +251,10 @@ export const addFilter = (options: {
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: options.data.view.filters
|
data: options.data.view.filters
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: oldFilters
|
data: oldFilters
|
||||||
}]);
|
}]);
|
||||||
options.menuElement.innerHTML = getFiltersHTML(options.data.view);
|
options.menuElement.innerHTML = getFiltersHTML(options.data.view);
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: changeData
|
data: changeData
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: oldData
|
data: oldData
|
||||||
}]);
|
}]);
|
||||||
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
|
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
|
||||||
|
|
@ -175,12 +173,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: changeData
|
data: changeData
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: oldData
|
data: oldData
|
||||||
}]);
|
}]);
|
||||||
menuElement.innerHTML = getFiltersHTML(data.view);
|
menuElement.innerHTML = getFiltersHTML(data.view);
|
||||||
|
|
@ -189,13 +185,11 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||||
id: sourceId,
|
id: sourceId,
|
||||||
}], [{
|
}], [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
|
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
|
||||||
id: sourceId,
|
id: sourceId,
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -281,12 +275,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: []
|
data: []
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: data.view.sorts
|
data: data.view.sorts
|
||||||
}]);
|
}]);
|
||||||
data.view.sorts = [];
|
data.view.sorts = [];
|
||||||
|
|
@ -310,12 +302,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: data.view.sorts
|
data: data.view.sorts
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: oldSorts
|
data: oldSorts
|
||||||
}]);
|
}]);
|
||||||
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
|
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
|
||||||
|
|
@ -332,12 +322,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: []
|
data: []
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: data.view.filters
|
data: data.view.filters
|
||||||
}]);
|
}]);
|
||||||
data.view.filters = [];
|
data.view.filters = [];
|
||||||
|
|
@ -361,12 +349,10 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: data.view.filters
|
data: data.view.filters
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: oldFilters
|
data: oldFilters
|
||||||
}]);
|
}]);
|
||||||
menuElement.innerHTML = getFiltersHTML(data.view);
|
menuElement.innerHTML = getFiltersHTML(data.view);
|
||||||
|
|
@ -407,14 +393,12 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: item.id,
|
id: item.id,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: false
|
data: false
|
||||||
});
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: item.id,
|
id: item.id,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: true
|
data: true
|
||||||
});
|
});
|
||||||
item.hidden = false;
|
item.hidden = false;
|
||||||
|
|
@ -436,14 +420,12 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: item.id,
|
id: item.id,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: true
|
data: true
|
||||||
});
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: item.id,
|
id: item.id,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: false
|
data: false
|
||||||
});
|
});
|
||||||
item.hidden = true;
|
item.hidden = true;
|
||||||
|
|
@ -462,13 +444,11 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: true
|
data: true
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: false
|
data: false
|
||||||
}]);
|
}]);
|
||||||
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = true;
|
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = true;
|
||||||
|
|
@ -482,13 +462,11 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: false
|
data: false
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewColHidden",
|
action: "setAttrViewColHidden",
|
||||||
id: colId,
|
id: colId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: data.viewID,
|
|
||||||
data: true
|
data: true
|
||||||
}]);
|
}]);
|
||||||
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = false;
|
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = false;
|
||||||
|
|
|
||||||
|
|
@ -85,13 +85,13 @@ export const removeSelectCell = (protyle: IProtyle, data: IAVTable, options: {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
keyID: colId,
|
||||||
parentID: data.id,
|
parentID: data.id,
|
||||||
data: cellData.value
|
data: cellData.value
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
keyID: colId,
|
||||||
parentID: data.id,
|
parentID: data.id,
|
||||||
data: {
|
data: {
|
||||||
[colData.type]: oldValue
|
[colData.type]: oldValue
|
||||||
|
|
@ -403,7 +403,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
|
||||||
}, {
|
}, {
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
keyID: colId,
|
||||||
parentID: data.id,
|
parentID: data.id,
|
||||||
data: cellData.value
|
data: cellData.value
|
||||||
}], [{
|
}], [{
|
||||||
|
|
@ -416,13 +416,13 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
keyID: colId,
|
||||||
parentID: data.id,
|
parentID: data.id,
|
||||||
data: cellData.value
|
data: cellData.value
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
id: cellId,
|
id: cellId,
|
||||||
rowID: rowId,
|
keyID: colId,
|
||||||
parentID: data.id,
|
parentID: data.id,
|
||||||
data: {
|
data: {
|
||||||
[colData.type]: oldValue
|
[colData.type]: oldValue
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,10 @@ export const addSort = (options: {
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: options.data.view.sorts
|
data: options.data.view.sorts
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: options.data.id,
|
avID: options.data.id,
|
||||||
viewID: options.data.viewID,
|
|
||||||
data: oldSorts
|
data: oldSorts
|
||||||
}]);
|
}]);
|
||||||
options.menuElement.innerHTML = getSortsHTML(options.data.view.columns, options.data.view.sorts);
|
options.menuElement.innerHTML = getSortsHTML(options.data.view.columns, options.data.view.sorts);
|
||||||
|
|
@ -74,12 +72,10 @@ export const bindSortsEvent = (protyle: IProtyle, menuElement: HTMLElement, data
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: data.id,
|
avID: data.id,
|
||||||
viewID: data.viewID,
|
|
||||||
data: data.view.sorts
|
data: data.view.sorts
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: data.id,
|
avID: data.id,
|
||||||
viewID: data.viewID,
|
|
||||||
data: oldSort
|
data: oldSort
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -824,17 +824,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-av-id");
|
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||||
id: gutterTypes[2],
|
id: gutterTypes[2],
|
||||||
}], [{
|
}], [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
||||||
id: gutterTypes[2],
|
id: gutterTypes[2],
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -853,7 +850,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
||||||
}
|
}
|
||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
|
|
||||||
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
|
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
|
||||||
// 行内拖拽
|
// 行内拖拽
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
|
|
@ -863,14 +859,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
previousID,
|
previousID,
|
||||||
id: item,
|
id: item,
|
||||||
});
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
avID,
|
avID,
|
||||||
viewID,
|
|
||||||
previousID: undoPreviousId,
|
previousID: undoPreviousId,
|
||||||
id: item,
|
id: item,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,6 @@ export class WYSIWYG {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const avId = nodeElement.getAttribute("data-av-id");
|
const avId = nodeElement.getAttribute("data-av-id");
|
||||||
const viewId = (nodeElement.querySelector(".item--focus") as HTMLElement).dataset.id;
|
|
||||||
const dragElement = target.parentElement;
|
const dragElement = target.parentElement;
|
||||||
const oldWidth = dragElement.clientWidth;
|
const oldWidth = dragElement.clientWidth;
|
||||||
const dragColId = dragElement.getAttribute("data-col-id");
|
const dragColId = dragElement.getAttribute("data-col-id");
|
||||||
|
|
@ -375,13 +374,11 @@ export class WYSIWYG {
|
||||||
action: "setAttrViewColWidth",
|
action: "setAttrViewColWidth",
|
||||||
id: dragColId,
|
id: dragColId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: newWidth
|
data: newWidth
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewColWidth",
|
action: "setAttrViewColWidth",
|
||||||
id: dragColId,
|
id: dragColId,
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: viewId,
|
|
||||||
data: oldWidth + "px"
|
data: oldWidth + "px"
|
||||||
}]);
|
}]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import {addLoading, setPadding} from "../protyle/ui/initUI";
|
||||||
import {getIconByType} from "../editor/getIcon";
|
import {getIconByType} from "../editor/getIcon";
|
||||||
import {unicode2Emoji} from "../emoji";
|
import {unicode2Emoji} from "../emoji";
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
import {isCtrl, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||||
import {newFileByName} from "../util/newFile";
|
import {newFileByName} from "../util/newFile";
|
||||||
import {matchHotKey} from "../protyle/util/hotKey";
|
import {matchHotKey} from "../protyle/util/hotKey";
|
||||||
import {filterMenu, getKeyByLiElement, initCriteriaMenu, moreMenu, queryMenu, saveCriterion} from "./menu";
|
import {filterMenu, getKeyByLiElement, initCriteriaMenu, moreMenu, queryMenu, saveCriterion} from "./menu";
|
||||||
|
|
|
||||||
3
app/src/types/index.d.ts
vendored
3
app/src/types/index.d.ts
vendored
|
|
@ -308,7 +308,7 @@ interface IOperation {
|
||||||
action: TOperation, // move, delete 不需要传 data
|
action: TOperation, // move, delete 不需要传 data
|
||||||
id?: string,
|
id?: string,
|
||||||
avID?: string, // av
|
avID?: string, // av
|
||||||
viewID?: string, // av
|
keyID?: string // updateAttrViewCell 专享
|
||||||
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
||||||
parentID?: string
|
parentID?: string
|
||||||
previousID?: string
|
previousID?: string
|
||||||
|
|
@ -317,7 +317,6 @@ interface IOperation {
|
||||||
srcIDs?: string[] // insertAttrViewBlock 专享
|
srcIDs?: string[] // insertAttrViewBlock 专享
|
||||||
name?: string // addAttrViewCol 专享
|
name?: string // addAttrViewCol 专享
|
||||||
type?: TAVCol // addAttrViewCol 专享
|
type?: TAVCol // addAttrViewCol 专享
|
||||||
rowID?: string // updateAttrViewCell 专享
|
|
||||||
deckID?: string // add/removeFlashcards 专享
|
deckID?: string // add/removeFlashcards 专享
|
||||||
blockIDs?: string[] // add/removeFlashcards 专享
|
blockIDs?: string[] // add/removeFlashcards 专享
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue