An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support choosing a save location when creating a document reference https://github.com/siyuan-note/siyuan/issues/19888
Danield4759bf1719d
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 38128e561b..be7861616d 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "اختيار الموقع وإنشاء مستند...","oidcClaimRulesRequired": "يجب إعداد قاعدة مطالبة واحدة على الأقل ما لم تُمنح صلاحيات المسؤول لجميع المستخدمين المصادق عليهم","oidcGitHubClaimRulesTip": "مثال GitHub (استبدل YOUR_GITHUB_USERNAME باسم مستخدم GitHub الخاص بك): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "تعليمات مخصصة",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 571fbe0832..7bc2b36d30 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Speicherort wählen und Dokument erstellen...","oidcClaimRulesRequired": "Mindestens eine Claim-Regel ist erforderlich, sofern nicht alle authentifizierten Benutzer Administratorrechte erhalten","oidcGitHubClaimRulesTip": "GitHub-Beispiel (YOUR_GITHUB_USERNAME durch Ihren GitHub-Benutzernamen ersetzen): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Benutzerdefinierte Anweisungen",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 2a2acf7876..70c55c9cfe 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Choose location and create doc...","oidcClaimRulesRequired": "At least one claim rule is required unless administrator access is granted to all authenticated users","oidcGitHubClaimRulesTip": "GitHub example (replace YOUR_GITHUB_USERNAME with your GitHub username): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Custom instructions",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 5e4f54e0ce..3b06cd8091 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Elegir ubicación y crear documento...","oidcClaimRulesRequired": "Se requiere al menos una regla de atributos si no se concede acceso de administrador a todos los usuarios autenticados","oidcGitHubClaimRulesTip": "Ejemplo de GitHub (sustituye YOUR_GITHUB_USERNAME por tu nombre de usuario de GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Instrucciones personalizadas",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 196f8a348d..16c9107cbf 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Choisir un emplacement et créer un document...","oidcClaimRulesRequired": "Au moins une règle de revendication est requise si les droits administrateur ne sont pas accordés à tous les utilisateurs authentifiés","oidcGitHubClaimRulesTip": "Exemple GitHub (remplacez YOUR_GITHUB_USERNAME par votre nom d’utilisateur GitHub) : [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Instructions personnalisées",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex b1e4da11f5..782a729cdc 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "בחירת מיקום ויצירת מסמך...","oidcClaimRulesRequired": "נדרש לפחות כלל הצהרה אחד אם לא ניתנות הרשאות מנהל לכל המשתמשים המאומתים","oidcGitHubClaimRulesTip": "דוגמת GitHub (יש להחליף את YOUR_GITHUB_USERNAME בשם המשתמש שלך ב-GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "הוראות מותאמות אישית",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex cddb72da9e..f341f3e720 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "स्थान चुनें और दस्तावेज़ बनाएँ...","oidcClaimRulesRequired": "यदि सभी प्रमाणित उपयोगकर्ताओं को व्यवस्थापक पहुँच नहीं दी गई है, तो कम से कम एक क्लेम नियम आवश्यक है","oidcGitHubClaimRulesTip": "GitHub उदाहरण (YOUR_GITHUB_USERNAME को अपने GitHub उपयोगकर्ता नाम से बदलें): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "कस्टम निर्देश",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 568084d609..53ddd3f797 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Pilih lokasi dan buat dokumen...","oidcClaimRulesRequired": "Setidaknya satu aturan klaim diperlukan jika akses administrator tidak diberikan kepada semua pengguna terautentikasi","oidcGitHubClaimRulesTip": "Contoh GitHub (ganti YOUR_GITHUB_USERNAME dengan nama pengguna GitHub Anda): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Instruksi khusus",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 527583a91d..ebec19ffc8 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Scegli posizione e crea documento...","oidcClaimRulesRequired": "È necessaria almeno una regola sui claim se non si concede accesso amministratore a tutti gli utenti autenticati","oidcGitHubClaimRulesTip": "Esempio GitHub (sostituisci YOUR_GITHUB_USERNAME con il tuo nome utente GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Istruzioni personalizzate",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 8cfc94bac6..005ca00afe 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "保存先を選択してドキュメントを作成...","oidcClaimRulesRequired": "認証済みの全ユーザーに管理者権限を付与しない場合、少なくとも1つのクレームルールが必要です","oidcGitHubClaimRulesTip": "GitHub の例(YOUR_GITHUB_USERNAME を自分の GitHub ユーザー名に置き換えてください):[{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "カスタム指示",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex d6e9740be9..82fddb0208 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "위치 선택 후 문서 만들기...","oidcClaimRulesRequired": "인증된 모든 사용자에게 관리자 권한을 부여하지 않는 경우 클레임 규칙을 하나 이상 설정해야 합니다","oidcGitHubClaimRulesTip": "GitHub 예시 (YOUR_GITHUB_USERNAME을 본인의 GitHub 사용자 이름으로 바꾸세요): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "사용자 지정 지침",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex b6b442a0e1..e54cd41bf1 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Locatie kiezen en document maken...","oidcClaimRulesRequired": "Minstens één claimregel is vereist als niet alle geauthenticeerde gebruikers beheerderstoegang krijgen","oidcGitHubClaimRulesTip": "GitHub-voorbeeld (vervang YOUR_GITHUB_USERNAME door uw GitHub-gebruikersnaam): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Aangepaste instructies",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 1d4e302bab..0540ec7bbb 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Wybierz lokalizację i utwórz dokument...","oidcClaimRulesRequired": "Wymagana jest co najmniej jedna reguła oświadczeń, jeśli nie przyznano uprawnień administratora wszystkim uwierzytelnionym użytkownikom","oidcGitHubClaimRulesTip": "Przykład GitHub (zastąp YOUR_GITHUB_USERNAME swoją nazwą użytkownika GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Własne instrukcje",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex be0962ab8c..78facf3b25 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Escolher local e criar documento...","oidcClaimRulesRequired": "É necessária pelo menos uma regra de declarações se o acesso de administrador não for concedido a todos os usuários autenticados","oidcGitHubClaimRulesTip": "Exemplo do GitHub (substitua YOUR_GITHUB_USERNAME pelo seu nome de usuário do GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Instruções personalizadas",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 5b47f6e888..a8772b2ab1 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Выбрать расположение и создать документ...","oidcClaimRulesRequired": "Необходимо хотя бы одно правило утверждений, если права администратора не предоставлены всем прошедшим проверку пользователям","oidcGitHubClaimRulesTip": "Пример для GitHub (замените YOUR_GITHUB_USERNAME своим именем пользователя GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Пользовательские инструкции",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex 086c0ca3f4..7a31cc371b 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Vybrať umiestnenie a vytvoriť dokument...","oidcClaimRulesRequired": "Ak nemajú všetci overení používatelia práva správcu, vyžaduje sa aspoň jedno pravidlo tvrdení","oidcGitHubClaimRulesTip": "Príklad pre GitHub (nahraďte YOUR_GITHUB_USERNAME svojím používateľským menom GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Vlastné pokyny",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex cb17ba04bc..53fcace1da 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Изабери локацију и направи документ...","oidcClaimRulesRequired": "Потребно је бар једно правило тврдњи ако администраторски приступ није додељен свим потврђеним корисницима","oidcGitHubClaimRulesTip": "GitHub пример (замените YOUR_GITHUB_USERNAME својим GitHub корисничким именом): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Прилагођена упутства",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 8542a9373e..07a6b8f01e 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "เลือกตำแหน่งและสร้างเอกสาร...","oidcClaimRulesRequired": "ต้องกำหนดกฎการอ้างสิทธิ์อย่างน้อยหนึ่งข้อ หากไม่ได้ให้สิทธิ์ผู้ดูแลระบบแก่ผู้ใช้ที่ยืนยันตัวตนแล้วทุกคน","oidcGitHubClaimRulesTip": "ตัวอย่าง GitHub (แทนที่ YOUR_GITHUB_USERNAME ด้วยชื่อผู้ใช้ GitHub ของคุณ): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "คำสั่งที่กำหนดเอง",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex f827479bc3..6176f237a1 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Konum seç ve belge oluştur...","oidcClaimRulesRequired": "Kimliği doğrulanmış tüm kullanıcılara yönetici erişimi verilmediyse en az bir talep kuralı gereklidir","oidcGitHubClaimRulesTip": "GitHub örneği (YOUR_GITHUB_USERNAME yerine GitHub kullanıcı adınızı yazın): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Özel talimatlar",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 3e153c9a95..d1bc2a113d 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "Вибрати розташування та створити документ...","oidcClaimRulesRequired": "Потрібне принаймні одне правило тверджень, якщо права адміністратора не надано всім автентифікованим користувачам","oidcGitHubClaimRulesTip": "Приклад GitHub (замініть YOUR_GITHUB_USERNAME своїм іменем користувача GitHub): [{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "Власні інструкції",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 28b466e96d..57db4f97fc 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "选择位置并新建...","oidcClaimRulesRequired": "未开启“授予所有已认证用户管理员权限”时,必须配置至少一条声明规则","oidcGitHubClaimRulesTip": "GitHub 示例(将 YOUR_GITHUB_USERNAME 替换为你的 GitHub 用户名):[{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "自定义指令",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 911d09e873..cd891c989a 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,5 @@{+ "newFileAtPath": "選擇位置並新增...","oidcClaimRulesRequired": "未開啟「授予所有已驗證使用者管理員權限」時,必須設定至少一條宣告規則","oidcGitHubClaimRulesTip": "GitHub 範例(將 YOUR_GITHUB_USERNAME 替換為你的 GitHub 使用者名稱):[{\"claim\": \"login\", \"operator\": \"equals\", \"values\": [\"YOUR_GITHUB_USERNAME\"]}]","agentInstructions": "自訂指令",diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101256-f8b1sbi.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101256-f8b1sbi.syindex e907460d15..4e29656fd3 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101256-f8b1sbi.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101256-f8b1sbi.sy@@ -6,7 +6,7 @@"id": "20200924101256-f8b1sbi","title": "Ref Content Block","type": "doc",- "updated": "20260803171606"+ "updated": "20260927091603"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20200924101312-jj4e0v3",- "updated": "20210512154431"+ "updated": "20260927091603"},"Children": [{@@ -56,6 +56,47 @@}]},+ {+ "ID": "20260927091603-y3kej6k",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260927091603-y3kej6k",+ "updated": "20260927091603"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "After entering "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "(("+ },+ {+ "Type": "NodeText",+ "Data": " or "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "[["+ },+ {+ "Type": "NodeText",+ "Data": " and a document title, choose "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Choose location and create doc..."+ },+ {+ "Type": "NodeText",+ "Data": " in the reference suggestions to select a notebook root or a parent document. Confirm to create the document there and insert its reference at the original position. This location applies only to this creation and does not change the default save path. Canceling creates no document. This is available on desktop and mobile."+ }+ ]+ },{"ID": "20210104091542-v1yca4p","Type": "NodeHeading",diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200813013559-sgbzl5k.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200813013559-sgbzl5k.syindex a5610b7903..a48a4868ea 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200813013559-sgbzl5k.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200813013559-sgbzl5k.sy@@ -6,7 +6,7 @@"id": "20200813013559-sgbzl5k","title": "引用内容块","type": "doc",- "updated": "20260820190627"+ "updated": "20260927091603"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20200817123136-in6y5m1",- "updated": "20210512154105"+ "updated": "20260927091603"},"Children": [{@@ -56,6 +56,47 @@}]},+ {+ "ID": "20260927091603-ca0ts26",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260927091603-ca0ts26",+ "updated": "20260927091603"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "输入 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "(("+ },+ {+ "Type": "NodeText",+ "Data": " 或 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "[["+ },+ {+ "Type": "NodeText",+ "Data": " 和文档标题后,可在引用候选列表中选择 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "选择位置并新建..."+ },+ {+ "Type": "NodeText",+ "Data": ",指定笔记本根目录或父文档。确认后将在该位置创建文档,并在原位置插入引用。所选位置仅对本次创建生效,不会修改默认保存路径;取消不会创建文档。桌面端和移动端均支持此操作。"+ }+ ]+ },{"ID": "20210104090557-841hf2w","Type": "NodeHeading",diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120247-63nd8y5.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120247-63nd8y5.syindex df7402e57a..2d83a554f5 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120247-63nd8y5.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120247-63nd8y5.sy@@ -6,7 +6,7 @@"id": "20211226120247-63nd8y5","title": "引用内容區塊","type": "doc",- "updated": "20260803163402"+ "updated": "20260927091603"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226120337-x5qwass",- "updated": "20250311195846"+ "updated": "20260927091603"},"Children": [{@@ -56,6 +56,47 @@}]},+ {+ "ID": "20260927091603-savpene",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260927091603-savpene",+ "updated": "20260927091603"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "輸入 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "(("+ },+ {+ "Type": "NodeText",+ "Data": " 或 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "[["+ },+ {+ "Type": "NodeText",+ "Data": " 和文件標題後,可在區塊引用候選清單中選擇 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "選擇位置並新增..."+ },+ {+ "Type": "NodeText",+ "Data": ",指定筆記本根目錄或父文件。確認後將在該位置建立文件,並在原位置插入區塊引用。所選位置僅對本次建立生效,不會修改預設儲存路徑;取消不會建立文件。桌面端和行動端均支援此操作。"+ }+ ]+ },{"ID": "20211226120337-nfx8mlg","Type": "NodeHeading",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-uxno1yp.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-uxno1yp.syindex 88b44b161c..08f2a205c8 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-uxno1yp.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-uxno1yp.sy@@ -7,7 +7,7 @@"id": "20240530101000-uxno1yp","title": "コンテンツブロックの参照","type": "doc",- "updated": "20260803163402"+ "updated": "20260927091603"},"Children": [{@@ -17,7 +17,7 @@"Properties": {"ID": "20240530101000-3mutq27","id": "20240530101000-ggy8jav",- "updated": "20240530101000"+ "updated": "20260927091603"},"Children": [{@@ -68,6 +68,43 @@}]},+ {+ "ID": "20260927091603-uttae8i",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260927091603-uttae8i",+ "updated": "20260927091603"+ },+ "Children": [+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "(("+ },+ {+ "Type": "NodeText",+ "Data": " または "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "code",+ "TextMarkTextContent": "[["+ },+ {+ "Type": "NodeText",+ "Data": " とドキュメントのタイトルを入力した後、参照候補から "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "保存先を選択してドキュメントを作成..."+ },+ {+ "Type": "NodeText",+ "Data": " を選ぶと、ノートブックのルートまたは親ドキュメントを指定できます。確定すると、その場所にドキュメントを作成し、元の位置に参照を挿入します。選択した保存先は今回の作成にのみ適用され、既定の保存先は変更されません。キャンセルするとドキュメントは作成されません。デスクトップ版とモバイル版の両方で利用できます。"+ }+ ]+ },{"ID": "20240530101000-avpxozm","Type": "NodeHeading",diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.tsindex 27298fd658..0ca63aa7c7 100644--- a/app/src/protyle/hint/extend.ts+++ b/app/src/protyle/hint/extend.ts@@ -613,6 +613,14 @@ export const hintRef = (key: string, protyle: IProtyle, source: THintSource): IH<span class="b3-list-item__text">${window.siyuan.languages.newSubDoc} <mark>${response.data.k}</mark></span></div>`,});createItemCount++;+ if (source !== "av") {+ dataList.push({+ value: `((newFileAtPath "${newFileName}"${Constants.ZWSP}'${newFileName}${Lute.Caret}'))`,+ html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFolder"></use></svg>+<span class="b3-list-item__text">${window.siyuan.languages.newFileAtPath} <mark>${response.data.k}</mark></span></div>`,+ });+ createItemCount++;+ }}response.data.blocks.forEach((item: IBlock) => {const name = item.name ? stripSearchMark(escapeSearchHighlight(item.name)) : item.refText.replace(new RegExp(Constants.ZWSP, "g"), "");diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.tsindex 11fd715dc8..a55b540d38 100644--- a/app/src/protyle/hint/index.ts+++ b/app/src/protyle/hint/index.ts@@ -23,6 +23,7 @@ import {getDocCreateTemplatePath,isConfiguredCreateTargetCurrentSubDoc,newFileByRefHint,+ newFileByRefHintAtPath,newFileBySelectRange,newFileInProtyle,newSubDocByRefHint@@ -679,6 +680,11 @@ export class Hint {const subDocRefText = `((newSubDoc "${oldValue}"${Constants.ZWSP}'${newFileName}${Lute.Caret}'))`;searchHTML += `<button style="width: calc(100% - 16px)" class="b3-list-item b3-list-item--two${hideConfiguredCreate && response.data.blocks.length === 0 ? " b3-list-item--focus" : ""}" data-value="${encodeURIComponent(subDocRefText)}"><div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newSubDoc} <mark>${response.data.k}</mark></span></div></button>`;+ if (source !== "av") {+ const pathRefText = `((newFileAtPath "${oldValue}"${Constants.ZWSP}'${newFileName}${Lute.Caret}'))`;+ searchHTML += `<button style="width: calc(100% - 16px)" class="b3-list-item b3-list-item--two" data-value="${encodeURIComponent(pathRefText)}"><div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFolder"></use></svg>+<span class="b3-list-item__text">${window.siyuan.languages.newFileAtPath} <mark>${response.data.k}</mark></span></div></button>`;+ }}response.data.blocks.forEach((item: IBlock, index: number) => {let blockRefHTML;@@ -880,12 +886,14 @@ ${genHintItemHTML(item)}return;}// 新建文件- if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar) && value.startsWith("((newFile ") && value.endsWith(`${Lute.Caret}'))`)) {- const fileNames = value.substring(11, value.length - 4).split(`"${Constants.ZWSP}'`);+ const choosePath = value.startsWith("((newFileAtPath ");+ if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar) && (value.startsWith("((newFile ") || choosePath) && value.endsWith(`${Lute.Caret}'))`)) {+ const prefix = choosePath ? "((newFileAtPath " : "((newFile ";+ const fileNames = value.substring(prefix.length + 1, value.length - 4).split(`"${Constants.ZWSP}'`);const realFileName = fileNames.length === 1 ? fileNames[0] : fileNames[1];- newFileByRefHint(protyle, realFileName, (id) => {+ const insertRef = (id: string, insertRange: Range) => {// https://github.com/siyuan-note/siyuan/issues/10133- protyle.toolbar.range = range;+ protyle.toolbar.range = insertRange;const refElement = protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {type: "id",color: `${id}${Constants.ZWSP}${refIsS ? "s" : "d"}${Constants.ZWSP}${getBlockRefAnchorText(refIsS ? fileNames[0] : realFileName)}`@@ -894,7 +902,12 @@ ${genHintItemHTML(item)}protyle.toolbar.range.setEnd(refElement[0].lastChild, refElement[0].lastChild.textContent.length);}protyle.toolbar.range.collapse(false);- });+ };+ if (choosePath) {+ newFileByRefHintAtPath(protyle, realFileName, range, insertRef);+ } else {+ newFileByRefHint(protyle, realFileName, (id) => insertRef(id, range));+ }return;}if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar)) {diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.tsindex cf0cf8af65..555e0e9a7c 100644--- a/app/src/util/newFile.ts+++ b/app/src/util/newFile.ts@@ -7,7 +7,7 @@ import {openFileById} from "../editor/util";import {getActiveTab, getDockByType} from "../layout/tabUtil";/// #endifimport {fetchPost, fetchSyncPost} from "./fetch";-import {getDisplayName, getOpenNotebookCount, pathPosix} from "./pathName";+import {getDisplayName, getOpenNotebookCount, isMoveTargetAllowed, movePathTo, pathPosix} from "./pathName";import {Constants} from "../constants";import {replaceFileName, validateName} from "../editor/rename";import {hideElements} from "../protyle/ui/hideElements";@@ -479,6 +479,48 @@ export const newFileByRefHint = (});};+/** 选择本次块引新建位置,创建前后均校验原文档和选区 */+export const newFileByRefHintAtPath = (+ protyle: IProtyle,+ name: string,+ range: Range,+ onCreated: (id: string, range: Range) => void,+) => {+ const context = createNewFileSelectionContext(protyle, range);+ const title = replaceFileName(name.trim());+ if (!context || !isNewFileSelectionValid(protyle, context) || (title && !validateName(title))) {+ return;+ }+ let submitted = false;+ movePathTo({+ title: window.siyuan.languages.newFileAtPath,+ flashcard: false,+ sourceNotebookIds: [context.notebookId],+ restoreFocus() {+ if (isNewFileSelectionValid(protyle, context)) {+ focusByRange(context.range);+ }+ },+ cb(paths, notebooks) {+ if (submitted || !paths[0] || !notebooks[0] || !isNewFileSelectionValid(protyle, context) ||+ !isMoveTargetAllowed([context.notebookId], notebooks[0])) {+ return;+ }+ submitted = true;+ createRefDocAsSubDoc({+ kind: "subDoc",+ targetNotebookId: notebooks[0],+ parentPath: paths[0],+ title,+ }, (id) => {+ if (isNewFileSelectionValid(protyle, context)) {+ onCreated(id, context.range);+ }+ });+ },+ });+};+/** 在当前文档下新建子文档,创建后仅回调插入引用或绑定数据库条目 */export const newSubDocByRefHint = (protyle: IProtyle,diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex 8231da6959..753137f569 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -253,6 +253,7 @@ export const movePathTo = (options: {cb: (toPath: string[], toNotebook: string[]) => void,paths?: string[],range?: Range,+ restoreFocus?: () => void,title?: string,flashcard: booleanrootIDs?: string[],@@ -289,7 +290,9 @@ export const movePathTo = (options: {width: isMobile() ? "92vw" : "50vw",height: isMobile() ? "80vh" : "70vh",destroyCallback() {- if (options.range) {+ if (options.restoreFocus) {+ options.restoreFocus();+ } else if (options.range) {focusByRange(options.range);}}@@ -367,6 +370,9 @@ export const movePathTo = (options: {dueFlashcardCount: string,flashcardCount: string}) => {+ if (!isMoveTargetAllowed(options.sourceNotebookIds, item.box)) {+ return;+ }let countHTML = "";if (options.flashcard) {countHTML = `<span class="counter counter--right b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.flashcardNewCard}">${item.newFlashcardCount}</span>diff --git a/app/tests/newRefDocAtPath.test.js b/app/tests/newRefDocAtPath.test.jsnew file mode 100644index 0000000000..3b61c2d627--- /dev/null+++ b/app/tests/newRefDocAtPath.test.js@@ -0,0 +1,214 @@+const assert = require("node:assert/strict");+const {readFileSync} = require("node:fs");+const path = require("node:path");+const {test} = require("node:test");+const ts = require("typescript");++const compiled = new Map();+const load = (name, dependencies, window, Lute) => {+ if (!compiled.has(name)) {+ compiled.set(name, ts.transpileModule(readFileSync(path.join(__dirname, "../src", name + ".ts"), "utf8"), {+ compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020},+ }).outputText);+ }+ const exports = {};+ new Function("require", "exports", "window", "Lute", compiled.get(name))(+ reference => dependencies[reference] || dependencies, exports, window, Lute);+ return exports;+};++const fixture = () => {+ const window = {siyuan: {+ languages: {newFileAtPath: "Choose location and create doc...", newFile: "Create doc", newSubDoc: "Create sub doc"},+ notebooks: [{id: "source"}, {id: "other"}, {id: "secret", encrypted: true}, {id: "secret2", encrypted: true}],+ config: {editor: {blockRefDynamicAnchorTextMaxLen: 64}},+ }};+ const Lute = {NewNodeID: () => "20260927120000-newdoc1", Caret: "‸", UnEscapeHTMLStr: value => value};+ const block = {outerHTML: "original", getAttribute: () => "block"};+ const text = {isConnected: true, textContent: "[[New title", block};+ const makeRange = () => ({+ startContainer: text, endContainer: text, startOffset: 0, endOffset: text.textContent.length,+ cloneRange: () => makeRange(),+ toString() { return text.textContent.slice(this.startOffset, this.endOffset); },+ collapse() {},+ });+ const range = makeRange();+ const protyle = {+ notebookId: "source", path: "/source.sy", block: {rootID: "sourceDoc"},+ wysiwyg: {element: {contains: node => node === text}}, toolbar: {range},+ element: {clientWidth: 800},+ };+ const requests = [];+ const inserted = [];+ const focused = [];+ let picker;+ const deps = {+ hasClosestBlock: node => node.block,+ Constants: {ZWSP: "\u200b", BLOCK_HINT_KEYS: ["((", "[[", "((", "【【"]},+ fetchPost: (url, data, cb) => requests.push({url, data, cb}),+ focusByRange: value => focused.push(value),+ getEditorRange: () => range,+ replaceFileName: value => value,+ validateName: () => true,+ hideElements: () => {},+ shouldCaptureHintUndoFocus: () => true,+ getUndoFocusContext: () => ({undoFocusId: "block"}),+ setPosition: () => {},+ registerBuiltinSlashHint: value => value,+ path: path,+ };+ const paths = load("util/pathName", {...deps, path}, window, Lute);+ Object.assign(deps, load("util/newFileSelection", deps, window, Lute), {+ ...paths,+ pathPosix: () => path.posix,+ movePathTo: options => { picker = options; },+ });+ const api = load("util/newFile", deps, window, Lute);+ Object.assign(deps, api);+ const hintAPI = load("protyle/hint/index", deps, window, Lute);+ const hint = Object.create(hintAPI.Hint.prototype);+ Object.assign(hint, {source: "hint", splitChar: "[[", lastIndex: -1, element: {+ lastElementChild: {innerHTML: ""}, style: {left: "0", right: "0"},+ }});+ hint.prepareCreateTarget = () => ({promise: Promise.resolve(false), isCurrent: () => true});+ hint.genLoading = () => {};+ hint.genHTML = items => { hint.items = items; };+ protyle.hint = hint;+ protyle.toolbar.setInlineMark = (...args) => { inserted.push(args); return []; };+ return {api, deps, paths, window, Lute, protyle, hint, range, text, requests, inserted, focused,+ get picker() { return picker; },+ open() { api.newFileByRefHintAtPath(protyle, "New title", range, (...args) => inserted.push(args)); },+ };+};++test("selected ID paths create at notebook root or the exact parent, without changing preferences", () => {+ for (const parent of ["/", "/same-name-one.sy", "/same-name-two.sy", "/ancestor/parent.sy"]) {+ const f = fixture();+ const config = JSON.stringify(f.window.siyuan.config);+ f.open();+ assert.equal(f.requests.length, 0);+ f.picker.cb([parent], ["other"]);+ assert.equal(f.requests.length, 1);+ assert.deepEqual(f.requests[0].data, {+ notebook: "other", path: path.posix.join(parent.replace(/\.sy$/, ""), "20260927120000-newdoc1.sy"),+ title: "New title", md: "",+ });+ assert.equal(f.requests[0].url, "/api/filetree/createDoc");+ assert.equal(f.inserted.length, 0);+ f.requests[0].cb({code: 0});+ assert.equal(f.inserted[0][0], "20260927120000-newdoc1");+ assert.notEqual(f.inserted[0][1], f.range);+ assert.equal(JSON.stringify(f.window.siyuan.config), config);+ f.picker.cb([parent], ["other"]);+ assert.equal(f.requests.length, 1);+ }+});++test("cancel restores the saved selection without creating or inserting anything", () => {+ const f = fixture();+ f.open();+ f.picker.restoreFocus();+ assert.equal(f.requests.length, 0);+ assert.equal(f.inserted.length, 0);+ assert.equal(f.focused.length, 1);+ assert.notEqual(f.focused[0], f.range);+});++test("changed, detached or navigated source contexts prevent creation and focus restoration", () => {+ for (const invalidate of [+ f => { f.text.isConnected = false; },+ f => { f.text.textContent = "different"; },+ f => { f.protyle.block.rootID = "different"; },+ f => { f.protyle.notebookId = "other"; },+ ]) {+ const f = fixture();+ f.open();+ invalidate(f);+ f.picker.cb(["/"], ["other"]);+ f.picker.restoreFocus();+ assert.equal(f.requests.length, 0);+ assert.equal(f.focused.length, 0);+ }+});++test("an invalidated source after creation starts does not receive a reference", () => {+ const f = fixture();+ f.open();+ f.picker.cb(["/"], ["other"]);+ f.protyle.block.rootID = "different";+ f.requests[0].cb({code: 0});+ assert.equal(f.inserted.length, 0);+});++test("a creation that never succeeds does not insert a reference", () => {+ const f = fixture();+ f.open();+ f.picker.cb(["/"], ["other"]);+ assert.equal(f.inserted.length, 0);+});++test("encrypted notebook boundaries apply to explicitly selected destinations", () => {+ for (const [source, target, allowed] of [+ ["source", "other", true], ["source", "secret", false],+ ["secret", "source", false], ["secret", "secret2", false], ["secret", "secret", true],+ ]) {+ const f = fixture();+ f.protyle.notebookId = source;+ f.open();+ assert.deepEqual(f.picker.sourceNotebookIds, [source]);+ f.picker.cb(["/"], [target]);+ assert.equal(f.requests.length, allowed ? 1 : 0);+ }+});++test("hint selection preserves reference subtype, anchor text and undo context", () => {+ for (const trigger of ["((", "[[", "((", "【【"]) {+ for (const staticRef of [true, false]) {+ const f = fixture();+ f.hint.splitChar = trigger;+ f.hint.fill(`((newFileAtPath "Original anchor"\u200b'New title${f.Lute.Caret}'))`, f.protyle, false, staticRef);+ assert.equal(f.inserted.length, 0);+ f.picker.cb(["/"], ["other"]);+ f.requests[0].cb({code: 0});+ assert.equal(f.inserted.length, 1);+ const args = f.inserted[0];+ assert.equal(args[3].color, `20260927120000-newdoc1\u200b${staticRef ? "s" : "d"}\u200b${staticRef ? "Original anchor" : "New title"}`);+ assert.equal(args[4], true);+ assert.deepEqual(args[5], {undoFocusId: "block"});+ assert.notEqual(f.protyle.toolbar.range, f.range);+ }+ }+});++test("typed and searched reference suggestions offer location selection, excluding database bindings", async () => {+ for (const source of ["hint", "search", "av"]) {+ for (const hideConfigured of [true, false]) {+ const f = fixture();+ f.hint.prepareCreateTarget = () => ({promise: Promise.resolve(hideConfigured), isCurrent: () => true});+ const extend = load("protyle/hint/extend", f.deps, f.window, f.Lute);+ extend.hintRef("New title", f.protyle, source);+ f.requests[0].cb({data: {newDoc: true, k: "New title", blocks: []}});+ await Promise.resolve();+ assert.equal(f.hint.items.some(item => item.value.startsWith("((newFileAtPath ")), source !== "av");+ assert.equal(f.hint.items.some(item => item.value.startsWith("((newFile ")), !hideConfigured);+ assert.equal(f.hint.items.some(item => item.value.startsWith("((newSubDoc ")), true);+ f.hint.genSearchHTML(f.protyle, {value: "New title"}, false, "Original anchor", source);+ f.requests[1].cb({data: {newDoc: true, k: "New title", blocks: []}});+ await Promise.resolve();+ assert.equal(f.hint.element.lastElementChild.innerHTML.includes("newFileAtPath"), source !== "av");+ }+ }+});++test("ordinary new document references still create directly with the original anchor", () => {+ const f = fixture();+ const created = [];+ f.deps.newFileByRefHint = (protyle, name, cb) => {+ created.push({protyle, name});+ cb("new-doc");+ };+ f.hint.fill(`((newFile "Original anchor"\u200b'New title${f.Lute.Caret}'))`, f.protyle, false, true);+ assert.deepEqual(created, [{protyle: f.protyle, name: "New title"}]);+ assert.equal(f.picker, undefined);+ assert.equal(f.inserted[0][3].color, "new-doc\u200bs\u200bOriginal anchor");+});diff --git a/app/tests/refDocPathPicker.test.js b/app/tests/refDocPathPicker.test.jsnew file mode 100644index 0000000000..b353ada657--- /dev/null+++ b/app/tests/refDocPathPicker.test.js@@ -0,0 +1,125 @@+const assert = require("node:assert/strict");+const fs = require("node:fs");+const os = require("node:os");+const path = require("node:path");++const runCases = async (sources, mobile) => {+ const check = require("node:assert/strict");+ const tick = () => new Promise(resolve => setTimeout(resolve, 20));+ const notebooks = [{id: "plain", name: "Plain"}, {id: "other", name: "Other"},+ {id: "secret", name: "Secret", encrypted: true}];+ const results = notebooks.map(item => ({box: item.id, path: "/parent.sy", hPath: item.name + "/Parent"}));+ window.siyuan = {+ dialogs: [], zIndex: 1, notebooks,+ languages: {cancel: "Cancel", confirm: "Confirm", searchPlaceholder: "Search", newFileAtPath: "Choose location and create doc..."},+ storage: {move: {k: "", keys: []}}, config: {search: {caseSensitive: false, limit: 20}},+ menus: {menu: {element: document.createElement("div"), remove() {}}},+ };+ let id = 0;+ const deps = {+ genUUID: () => String(++id), isAbove: () => false, moveResize() {}, isMobile: () => mobile,+ Constants: {LOCAL_MOVE_PATH: "move", TIMEOUT_OPENDIALOG: 0, TIMEOUT_DBLCLICK: 0},+ getFileTreeDefaultIconAttr: () => "", getFileTreeIconHTML: () => "",+ escapeHtml: text => text, escapeAriaLabel: text => text, updateHotkeyTip: text => text,+ highlightSearchText: text => text, addClearButton() {}, setStorageVal() {},+ isOnlyMeta: () => false, matchHotKey: () => false,+ fetchPost(url, data, cb) {+ if (url === "/api/notebook/lsNotebooks") {+ cb({data: {notebooks}});+ } else if (url === "/api/filetree/searchDocs") {+ cb({data: results});+ } else {+ throw new Error("Unexpected request " + url);+ }+ },+ };+ const load = name => {+ const exports = {};+ new Function("require", "exports", sources[name])(() => deps, exports);+ return exports;+ };+ Object.assign(deps, load("dialog/index"));+ const {movePathTo} = load("util/pathName");+ for (const source of ["plain", "secret"]) {+ for (const confirmBy of ["click", "enter", "cancel"]) {+ window.siyuan.storage.move.k = "";+ const calls = [];+ let restored = 0;+ movePathTo({title: window.siyuan.languages.newFileAtPath, flashcard: false, sourceNotebookIds: [source],+ cb: (...args) => calls.push(args), restoreFocus: () => restored++});+ const dialog = window.siyuan.dialogs[0];+ const container = dialog.element.querySelector(".b3-dialog__container");+ check.equal(container.style.width, mobile ? "92vw" : "50vw");+ const expected = source === "secret" ? ["secret"] : ["plain", "other"];+ const boxes = selector => Array.from(dialog.element.querySelectorAll(selector)).map(item => item.dataset.box);+ check.deepEqual(boxes("#foldTree li"), expected);+ check.equal(!!dialog.element.querySelector("#foldTree.b3-list--mobile"), mobile);+ const input = dialog.element.querySelector("input");+ input.value = "Parent";+ input.dispatchEvent(new Event("input", {bubbles: true}));+ check.deepEqual(boxes("#foldList li"), expected);+ if (confirmBy === "cancel") {+ dialog.element.querySelector(".b3-button--cancel").click();+ } else if (confirmBy === "enter") {+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true, cancelable: true}));+ } else {+ const items = dialog.element.querySelectorAll("#foldList li");+ items[items.length - 1].click();+ dialog.element.querySelector(".b3-button--text").click();+ }+ await tick();+ check.equal(restored, 1);+ check.equal(window.siyuan.dialogs.length, 0);+ if (confirmBy === "cancel") {+ check.equal(calls.length, 0);+ } else {+ check.deepEqual(calls, [[["/parent.sy"], [confirmBy === "click" ? expected[expected.length - 1] : expected[0]]]]);+ }+ }+ }+};++if (process.versions.electron && process.type === "browser") {+ const {app, BrowserWindow} = require("electron");+ app.setPath("userData", process.argv[2]);+ app.whenReady().then(async () => {+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false}});+ let code = 0;+ try {+ const ts = require("typescript");+ const preprocess = require("ifdef-loader/preprocessor").parse;+ for (const mobile of [false, true]) {+ await win.loadURL("data:text/html,<html><body></body></html>");+ const sources = {};+ for (const name of ["util/pathName", "dialog/index"]) {+ sources[name] = ts.transpileModule(preprocess(fs.readFileSync(path.join(__dirname, "../src", name + ".ts"), "utf8"),+ {MOBILE: mobile, BROWSER: true}, false, true), {+ compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020},+ }).outputText;+ }+ await win.webContents.executeJavaScript(`(${runCases.toString()})(${JSON.stringify(sources)}, ${mobile})`);+ }+ } catch (error) {+ console.error(error);+ code = 1;+ } finally {+ win.destroy();+ app.exit(code);+ }+ });+} else {+ const {test} = require("node:test");+ const {execFile} = require("node:child_process");+ const {promisify} = require("node:util");+ test("desktop and mobile path pickers filter encrypted destinations and support confirm and cancel", async () => {+ const profile = fs.mkdtempSync(path.join(os.tmpdir(), "siyuan-ref-doc-path-"));+ const env = {...process.env};+ delete env.ELECTRON_RUN_AS_NODE;+ try {+ await promisify(execFile)(require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 30000});+ } finally {+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));+ fs.rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});+ }+ });+}