Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Remove duplicate data-type attribute tags when converting inline elements to text https://github.com/siyuan-note/siyuan/issues/17292 (#17297)

Jeffrey Chen3ba6d51a62a1
diff --git a/app/src/protyle/toolbar/util.ts b/app/src/protyle/toolbar/util.ts
index c49c9483a0..bfcd737c1f 100644
--- a/app/src/protyle/toolbar/util.ts
+++ b/app/src/protyle/toolbar/util.ts
@@ -66,20 +66,14 @@ export const removeSearchMark = (element: HTMLElement) => {
};
export const removeInlineType = (inlineElement: HTMLElement, type: string, range?: Range) => {
- const types = inlineElement.getAttribute("data-type").split(" ");
- if (types.length === 1) {
+ const types = (inlineElement.getAttribute("data-type") || "").split(" ").filter((item) => item !== "" && item !== type);
+ if (types.length === 0) {
const linkParentElement = inlineElement.parentElement;
inlineElement.outerHTML = inlineElement.innerHTML.replace(Constants.ZWSP, "") + "<wbr>";
if (range) {
focusByWbr(linkParentElement, range);
}
} else {
- types.find((itemType, index) => {
- if (type === itemType) {
- types.splice(index, 1);
- return true;
- }
- });
inlineElement.setAttribute("data-type", types.join(" "));
if (type === "a") {
inlineElement.removeAttribute("data-href");