🎨 Remove the av-names attribute from block elements (#16424)

This commit is contained in:
Jeffrey Chen 2025-11-23 10:45:04 +08:00 committed by GitHub
parent f6611ccc7f
commit 8a1703e34a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 8 deletions

View file

@ -8,7 +8,6 @@ export const clearBlockElement = (element: Element) => {
element.querySelector(".protyle-attr--av")?.remove();
element.querySelector(".protyle-attr--refcount")?.remove();
element.removeAttribute("custom-avs");
element.removeAttribute("av-names");
element.getAttributeNames().forEach(attr => {
if (attr.startsWith("custom-sy-av-s-text-")) {
element.removeAttribute(attr);

View file

@ -152,7 +152,7 @@ export class WYSIWYG {
}
}
ialKeys.forEach((key: string) => {
if (!["title-img", "title", "updated", "icon", "id", "type", "class", "spellcheck", "contenteditable", "data-doc-type", "style", "data-realwidth", "data-readonly"].includes(key)) {
if (!["title-img", "title", "updated", "icon", "id", "type", "class", "spellcheck", "contenteditable", "data-doc-type", "style", "data-realwidth", "data-readonly", "av-names"].includes(key)) {
this.element.setAttribute(key, ial[key]);
}
});

View file

@ -611,13 +611,14 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
data.new.style += ";animation:addCard 450ms linear";
}
Object.keys(data.new).forEach(key => {
if ("id" === key) {
if ("id" === key || "av-names" === key) {
// 设置属性以后不应该给块元素添加 id 属性 No longer add the `id` attribute to block elements after setting the attribute https://github.com/siyuan-note/siyuan/issues/15327
// av-names 属性仅用于生成角标,不添加到元素
return;
}
item.setAttribute(key, data.new[key]);
if (key === Constants.CUSTOM_RIFF_DECKS && data.new[Constants.CUSTOM_RIFF_DECKS] !== data.old[Constants.CUSTOM_RIFF_DECKS]) {
if (key === Constants.CUSTOM_RIFF_DECKS && key !== data.old[Constants.CUSTOM_RIFF_DECKS]) {
item.style.animation = "addCard 450ms linear";
setTimeout(() => {
if (item.parentElement) {