mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 08:16:10 +01:00
This commit is contained in:
parent
407dd3836f
commit
4e8550beb9
3 changed files with 25 additions and 7 deletions
|
|
@ -516,7 +516,7 @@ const updateCellValueByInput = (protyle: IProtyle, type: TAVCol, blockElement: H
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, value?: any, cElements?: HTMLElement[],
|
export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, value?: any, cElements?: HTMLElement[],
|
||||||
columns?: IAVColumn[]) => {
|
columns?: IAVColumn[], html?: string) => {
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
const undoOperations: IOperation[] = [];
|
const undoOperations: IOperation[] = [];
|
||||||
|
|
||||||
|
|
@ -569,9 +569,27 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
|
||||||
if (type === "mAsset") {
|
if (type === "mAsset") {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value = oldValue.mAsset.concat(value);
|
value = oldValue.mAsset.concat(value);
|
||||||
} else if (typeof value !== "undefined") {
|
} else if (typeof value !== "undefined") { // 不传入为删除,传入字符串不进行处理
|
||||||
// 不传入为删除,传入字符串不进行处理
|
let link = protyle.lute.GetLinkDest(value);
|
||||||
return;
|
let name = "";
|
||||||
|
if (html) {
|
||||||
|
const tempElement = document.createElement("template")
|
||||||
|
tempElement.innerHTML = html
|
||||||
|
const aElement = tempElement.content.querySelector('[data-type~="a"]')
|
||||||
|
if (aElement) {
|
||||||
|
link = aElement.getAttribute("data-href");
|
||||||
|
name = aElement.textContent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!link && !name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 支持解析 https://github.com/siyuan-note/siyuan/issues/11463
|
||||||
|
value = oldValue.mAsset.concat({
|
||||||
|
type: "file",
|
||||||
|
content: link,
|
||||||
|
name
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (type === "mSelect") {
|
} else if (type === "mSelect") {
|
||||||
// 不传入为删除
|
// 不传入为删除
|
||||||
|
|
|
||||||
|
|
@ -176,9 +176,9 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
const rowsElement = blockElement.querySelector(".av__row--select");
|
const rowsElement = blockElement.querySelector(".av__row--select");
|
||||||
|
|
||||||
if (rowsElement) {
|
if (rowsElement) {
|
||||||
updateCellsValue(protyle, blockElement as HTMLElement, text, undefined, columns);
|
updateCellsValue(protyle, blockElement as HTMLElement, text, undefined, columns, html);
|
||||||
} else if (cellsElement.length > 0) {
|
} else if (cellsElement.length > 0) {
|
||||||
updateCellsValue(protyle, blockElement as HTMLElement, text, cellsElement, columns);
|
updateCellsValue(protyle, blockElement as HTMLElement, text, cellsElement, columns, html);
|
||||||
} else if (hasClosestByClassName(range.startContainer, "av__title")) {
|
} else if (hasClosestByClassName(range.startContainer, "av__title")) {
|
||||||
range.insertNode(document.createTextNode(text));
|
range.insertNode(document.createTextNode(text));
|
||||||
range.collapse(false);
|
range.collapse(false);
|
||||||
|
|
|
||||||
|
|
@ -1577,7 +1577,7 @@ export class WYSIWYG {
|
||||||
blockElement: hasClosestBlock(assetImgElement) as HTMLElement,
|
blockElement: hasClosestBlock(assetImgElement) as HTMLElement,
|
||||||
content: target.tagName === "IMG" ? target.getAttribute("src") : target.getAttribute("data-url"),
|
content: target.tagName === "IMG" ? target.getAttribute("src") : target.getAttribute("data-url"),
|
||||||
type: target.tagName === "IMG" ? "image" : "file",
|
type: target.tagName === "IMG" ? "image" : "file",
|
||||||
name: target.tagName === "IMG" ? "" : target.textContent,
|
name: target.tagName === "IMG" ? "" : target.getAttribute("data-name"),
|
||||||
index,
|
index,
|
||||||
rect: target.getBoundingClientRect()
|
rect: target.getBoundingClientRect()
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue