mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
1c9594be8e
commit
5a761ab54a
2 changed files with 111 additions and 90 deletions
|
|
@ -397,6 +397,13 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
||||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
|
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
|
||||||
item.removeAttribute("data-render");
|
item.removeAttribute("data-render");
|
||||||
const updateRow = item.querySelector('.av__row[data-need-update="true"]');
|
const updateRow = item.querySelector('.av__row[data-need-update="true"]');
|
||||||
|
if (operation.action === "sortAttrViewCol" || operation.action === "sortAttrViewRow") {
|
||||||
|
item.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
|
||||||
|
item.classList.remove("av__cell--active");
|
||||||
|
item.querySelector(".av__drag-fill")?.remove();
|
||||||
|
});
|
||||||
|
addDragFill(item.querySelector(".av__cell--select"));
|
||||||
|
}
|
||||||
avRender(item, protyle, () => {
|
avRender(item, protyle, () => {
|
||||||
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] div[data-av-id="${operation.avID}"]`) as HTMLElement;
|
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] div[data-av-id="${operation.avID}"]`) as HTMLElement;
|
||||||
if (attrElement) {
|
if (attrElement) {
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,26 @@ import {input} from "../wysiwyg/input";
|
||||||
import {objEquals} from "../../util/functions";
|
import {objEquals} from "../../util/functions";
|
||||||
|
|
||||||
const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => {
|
const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
|
const tempElement = document.createElement("template")
|
||||||
|
tempElement.innerHTML = html;
|
||||||
|
let values: IAVCellValue[] = [];
|
||||||
if (html.endsWith("]") && html.startsWith("[")) {
|
if (html.endsWith("]") && html.startsWith("[")) {
|
||||||
try {
|
try {
|
||||||
const values = JSON.parse(html);
|
values = JSON.parse(html);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("insert cell: JSON.parse error");
|
||||||
|
}
|
||||||
|
} else if (tempElement.content.querySelector("table")) {
|
||||||
|
tempElement.content.querySelectorAll("tr").forEach(item => {
|
||||||
|
Array.from(item.children).forEach(cell => {
|
||||||
|
values.push({
|
||||||
|
text: {content: cell.textContent},
|
||||||
|
type: "text"
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (values && Array.isArray(values) && values.length > 0) {
|
||||||
const cellElements: Element[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];
|
const cellElements: Element[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];
|
||||||
if (cellElements.length === 0) {
|
if (cellElements.length === 0) {
|
||||||
blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(rowElement => {
|
blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(rowElement => {
|
||||||
|
|
@ -104,9 +121,6 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
transaction(protyle, doOperations, undoOperations);
|
transaction(protyle, doOperations, undoOperations);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
|
||||||
console.warn("insert cell: JSON.parse error");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const text = protyle.lute.BlockDOM2EscapeMarkerContent(html);
|
const text = protyle.lute.BlockDOM2EscapeMarkerContent(html);
|
||||||
const cellsElement: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--select"));
|
const cellsElement: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--select"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue