Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/8554

Vanessaace0528d1a80
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 3cfafa4b4b..278b1fe5db 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -275,7 +275,7 @@ const readLocalFile = async (protyle: IProtyle, localFiles: ILocalFiles[]) => {
uploadLocalFiles(localFiles, protyle, true);
};
-const convertPastedListItemSubtype = (listItemElement: HTMLElement, subtype: string) => {
+export const convertPastedListItemSubtype = (listItemElement: HTMLElement, subtype: string) => {
const actionElement = listItemElement.querySelector<HTMLElement>(".protyle-action");
if (!actionElement || !["u", "o", "t"].includes(subtype)) {
return;
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 56365f707d..a385b5b81e 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1,4 +1,11 @@
-import {beforePaste, enableLuteMarkdownSyntax, getTextStar, paste, restoreLuteMarkdownSyntax} from "../util/paste";
+import {
+ beforePaste,
+ convertPastedListItemSubtype,
+ enableLuteMarkdownSyntax,
+ getTextStar,
+ paste,
+ restoreLuteMarkdownSyntax
+} from "../util/paste";
import {
hasClosestBlock,
hasClosestByAttribute,
@@ -482,6 +489,16 @@ export class WYSIWYG {
item.append(attrElement.cloneNode(true));
}
});
+ const listItemElements = Array.from(element.children).filter(item =>
+ item.getAttribute("data-type") === "NodeListItem") as HTMLElement[];
+ const subtype = listItemElements[0]?.getAttribute("data-subtype");
+ if (subtype && listItemElements.length > 1 && listItemElements.length === element.childElementCount) {
+ listItemElements.forEach(item => {
+ if (item.getAttribute("data-subtype") !== subtype) {
+ convertPastedListItemSubtype(item, subtype);
+ }
+ });
+ }
}
private async writeSelectionClipboardForCut() {