@dooc-dev/dooc 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +98 -56
- package/dist/compiler/asset-references.d.ts +4 -0
- package/dist/compiler/asset-references.js +117 -0
- package/dist/compiler/bundle-urls.d.ts +1 -1
- package/dist/compiler/bundle-urls.js +15 -5
- package/dist/compiler/check.js +8 -5
- package/dist/compiler/code-languages.js +7 -2
- package/dist/compiler/compile.d.ts +5 -0
- package/dist/compiler/compile.js +105 -10
- package/dist/compiler/config.js +2 -1
- package/dist/compiler/export.d.ts +4 -0
- package/dist/compiler/export.js +140 -0
- package/dist/compiler/figures.js +4 -0
- package/dist/compiler/files.d.ts +1 -0
- package/dist/compiler/files.js +96 -38
- package/dist/compiler/fonts.js +4 -1
- package/dist/compiler/icons.d.ts +1 -1
- package/dist/compiler/icons.js +11 -2
- package/dist/compiler/ignored-files.d.ts +3 -0
- package/dist/compiler/ignored-files.js +68 -0
- package/dist/compiler/locales.js +13 -8
- package/dist/compiler/manifest.d.ts +2 -0
- package/dist/compiler/manifest.js +9 -2
- package/dist/compiler/ops.d.ts +6 -0
- package/dist/compiler/ops.js +98 -7
- package/dist/compiler/subformats.d.ts +24 -0
- package/dist/compiler/subformats.js +299 -0
- package/dist/compiler/textfile.js +3 -0
- package/dist/compiler/theme-variants.js +5 -2
- package/dist/core/content-metadata.d.ts +15 -6
- package/dist/core/content-metadata.js +278 -17
- package/dist/core/content-types.d.ts +3 -1
- package/dist/core/figure-frame.js +19 -1
- package/dist/core/files.d.ts +2 -1
- package/dist/core/files.js +6 -8
- package/dist/core/flow-base-css.generated.js +1 -1
- package/dist/core/html.js +3 -3
- package/dist/core/icons.d.ts +3 -0
- package/dist/core/icons.js +3 -0
- package/dist/core/json-tools.d.ts +1 -0
- package/dist/core/json-tools.js +12 -0
- package/dist/core/routing.d.ts +5 -2
- package/dist/core/routing.js +17 -5
- package/dist/core/subformat-record.d.ts +3 -0
- package/dist/core/subformat-record.js +131 -0
- package/dist/core/subformats.d.ts +43 -0
- package/dist/core/subformats.js +81 -0
- package/dist/core/toc-ui.js +25 -23
- package/dist/edit.global.js +322 -95
- package/dist/mcp.js +50 -9
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/local-storage.js +3 -0
- package/dist/plugins/oauth.d.ts +1 -1
- package/dist/plugins/oauth.js +8 -2
- package/dist/plugins/runtime.d.ts +6 -0
- package/dist/plugins/runtime.js +166 -34
- package/dist/plugins/transport.d.ts +22 -0
- package/dist/plugins/transport.js +1 -0
- package/dist/plugins/types.d.ts +3 -1
- package/dist/plugins.global.js +128 -0
- package/dist/subformats.global.js +127 -0
- package/dist/ui.global.js +91 -38
- package/dist/viewer/build-plugins.d.ts +7 -0
- package/dist/viewer/build-plugins.js +70 -0
- package/dist/viewer/build.d.ts +9 -0
- package/dist/viewer/build.js +32 -5
- package/dist/viewer/editor-tools.d.ts +7 -7
- package/dist/viewer/editor-tools.js +36 -5
- package/dist/viewer/font-picker.js +5 -1
- package/dist/viewer/git-diff.d.ts +3 -0
- package/dist/viewer/git-diff.js +47 -0
- package/dist/viewer/hmr.js +4 -1
- package/dist/viewer/i18n.js +7 -5
- package/dist/viewer/language-picker.d.ts +2 -2
- package/dist/viewer/language-picker.js +26 -9
- package/dist/viewer/lazy-graph.d.ts +2 -0
- package/dist/viewer/lazy-graph.js +30 -0
- package/dist/viewer/locales/eng.json +74 -10
- package/dist/viewer/locales/jpn.json +75 -11
- package/dist/viewer/locales/zho.json +75 -11
- package/dist/viewer/nav-focus.js +8 -1
- package/dist/viewer/nav-update.d.ts +2 -0
- package/dist/viewer/nav-update.js +117 -0
- package/dist/viewer/plugin-style.d.ts +1 -0
- package/dist/viewer/plugin-style.js +82 -0
- package/dist/viewer/plugins.js +46 -3
- package/dist/viewer/resize.d.ts +0 -2
- package/dist/viewer/resize.js +2 -98
- package/dist/viewer/resource-library.d.ts +10 -8
- package/dist/viewer/resource-library.js +179 -30
- package/dist/viewer/search.d.ts +4 -2
- package/dist/viewer/search.js +252 -53
- package/dist/viewer/serve.d.ts +10 -5
- package/dist/viewer/serve.js +882 -287
- package/dist/viewer/site-icon.js +13 -6
- package/dist/viewer/site-title.d.ts +13 -0
- package/dist/viewer/site-title.js +50 -0
- package/dist/viewer/textfile.d.ts +3 -0
- package/dist/viewer/textfile.js +19 -2
- package/dist/viewer/theme-picker.d.ts +2 -0
- package/dist/viewer/theme-picker.js +24 -8
- package/dist/viewer/workspace.d.ts +2 -0
- package/dist/viewer/workspace.js +46 -1
- package/package.json +24 -9
- package/dist/compiler/bundle.d.ts +0 -2
- package/dist/compiler/bundle.js +0 -100
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"Site title": "サイト名",
|
|
3
|
+
"Edit site title": "サイト名を編集",
|
|
2
4
|
"Editor font": "エディターのフォント",
|
|
3
5
|
"Viewer font": "ビューアーのフォント",
|
|
4
6
|
"Default font": "標準フォント",
|
|
@@ -151,9 +153,14 @@
|
|
|
151
153
|
"{count} results": "{count} 件",
|
|
152
154
|
"Showing {shown} of {count} results": "{count} 件中 {shown} 件を表示",
|
|
153
155
|
"Add translation": "翻訳用の文書を追加",
|
|
154
|
-
"Folder": "フォルダー",
|
|
155
156
|
"Move search": "検索窓を移動",
|
|
156
157
|
"Resize search": "検索窓のサイズを変更",
|
|
158
|
+
"Matches text": "本文に一致",
|
|
159
|
+
"Matches file name": "ファイル名に一致",
|
|
160
|
+
"Matches folder name": "フォルダー名に一致",
|
|
161
|
+
"Close search": "検索窓を閉じる",
|
|
162
|
+
"Move search to sidebar": "検索窓をサイドバーに置く",
|
|
163
|
+
"Float search": "検索窓をフロートにする",
|
|
157
164
|
"Notice": "お知らせ",
|
|
158
165
|
"OK": "閉じる",
|
|
159
166
|
"Discard changes": "変更を破棄",
|
|
@@ -210,16 +217,21 @@
|
|
|
210
217
|
"File details": "ファイル情報",
|
|
211
218
|
"Show Git changes": "Git差分を表示",
|
|
212
219
|
"Resource views": "リソースの表示",
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
220
|
+
"Default": "既定値",
|
|
221
|
+
"Set as default": "既定値にする",
|
|
222
|
+
"Group by": "グループ化",
|
|
223
|
+
"Sort by": "並べ替え",
|
|
224
|
+
"Newest first": "新しい順",
|
|
225
|
+
"Oldest first": "古い順",
|
|
226
|
+
"Unassigned": "未設定",
|
|
227
|
+
"Records": "レコード",
|
|
228
|
+
"Codeblocks": "コードブロック",
|
|
229
|
+
"Format": "形式",
|
|
230
|
+
"URLs": "URL",
|
|
231
|
+
"URL previews": "URLプレビュー",
|
|
217
232
|
"Domain": "ドメイン",
|
|
218
233
|
"All": "すべて",
|
|
219
234
|
"references": "か所で使用",
|
|
220
|
-
"Definitions from term files and Markdown": "用語ファイルとMarkdown内の定義を横断して探せます",
|
|
221
|
-
"Code blocks collected from Markdown files": "Markdown内のコードを、言語や内容から探せます",
|
|
222
|
-
"External links and embeds with their source locations": "外部リンク・埋め込みURLと、その使用箇所を確認できます",
|
|
223
235
|
"Search resources": "リソースを検索",
|
|
224
236
|
"Files with errors": "読み取り・解析エラー",
|
|
225
237
|
"No matching resources": "該当するリソースはありません",
|
|
@@ -279,14 +291,21 @@
|
|
|
279
291
|
"Restore stash": "stashを復元",
|
|
280
292
|
"Stash changes": "変更をstashへ退避",
|
|
281
293
|
"Statics": "Statics",
|
|
294
|
+
"Subformats": "Subformats",
|
|
295
|
+
"Expand card": "カードを展開",
|
|
296
|
+
"Collapse card": "カードを折りたたむ",
|
|
297
|
+
"View details": "詳細を表示",
|
|
298
|
+
"Click for details; double-click to edit": "クリックで詳細、ダブルクリックで編集",
|
|
299
|
+
"No grouping": "グループ化なし",
|
|
300
|
+
"Ascending": "昇順",
|
|
301
|
+
"Descending": "降順",
|
|
302
|
+
"No subformats configured. Add subformats to dooc.yaml.": "subformat が未設定です。dooc.yaml に subformats を追加してください。",
|
|
282
303
|
"Workspace tools": "ワークスペース操作",
|
|
283
|
-
"Resize workspace tools": "下部カードの高さを変更",
|
|
284
304
|
"Git controls": "Git操作",
|
|
285
305
|
"Actions": "操作",
|
|
286
306
|
"Updated": "更新しました",
|
|
287
307
|
"Copy": "コピー",
|
|
288
308
|
"Edit": "編集",
|
|
289
|
-
"Saving…": "保存中…",
|
|
290
309
|
"Reload actions before saving again.": "再保存する前に再読み込みしてください。",
|
|
291
310
|
"Saved, but refresh failed. Reload actions before saving again.": "保存は完了しましたが、再取得に失敗しました。再保存する前に再読み込みしてください。",
|
|
292
311
|
"Actions could not be loaded.": "操作を取得できませんでした。",
|
|
@@ -313,5 +332,50 @@
|
|
|
313
332
|
"Sign out": "ログアウト",
|
|
314
333
|
"Not signed in": "未ログイン",
|
|
315
334
|
"Continue login": "ログインを続ける",
|
|
316
|
-
"Provided by viewer": "開発用プラグイン"
|
|
335
|
+
"Provided by viewer": "開発用プラグイン",
|
|
336
|
+
"Added": "新規",
|
|
337
|
+
"Modified": "変更",
|
|
338
|
+
"Add subformat…": "subformatを追加…",
|
|
339
|
+
"Add subformat": "subformatを追加",
|
|
340
|
+
"Extension": "拡張子",
|
|
341
|
+
"Storage format": "保存形式",
|
|
342
|
+
"Schema file (optional)": "スキーマファイル(任意)",
|
|
343
|
+
"Create automatically": "自動作成",
|
|
344
|
+
"Form": "フォーム",
|
|
345
|
+
"Enter a valid number.": "有効な数値を入力してください。",
|
|
346
|
+
"Value editing mode": "値の編集モード",
|
|
347
|
+
"{format} text": "{format}テキスト",
|
|
348
|
+
"Schema editing mode": "スキーマ編集モード",
|
|
349
|
+
"JSON text": "JSON text",
|
|
350
|
+
"Build kit": "Build kit",
|
|
351
|
+
"Field settings": "フィールド設定",
|
|
352
|
+
"Field name": "フィールド名",
|
|
353
|
+
"New field name": "新しいフィールド名",
|
|
354
|
+
"New field type": "新しいフィールドの型",
|
|
355
|
+
"Remove field": "フィールドを削除",
|
|
356
|
+
"Add field": "フィールドを追加",
|
|
357
|
+
"Required": "必須",
|
|
358
|
+
"Allow extra fields": "未定義のフィールドを許可",
|
|
359
|
+
"Choices (one per line)": "選択肢(1行に1つ)",
|
|
360
|
+
"Item type": "配列要素の型",
|
|
361
|
+
"Rename linked fields in JSON text.": "参照されるフィールド名はJSON textで変更してください。",
|
|
362
|
+
"Additional rules are preserved in JSON text.": "その他のルールはJSON textに保持されています。",
|
|
363
|
+
"Enter a field name.": "フィールド名を入力してください。",
|
|
364
|
+
"Enter a unique field name.": "重複しないフィールド名を入力してください。",
|
|
365
|
+
"A field with this name already exists.": "同じ名前のフィールドが既にあります。",
|
|
366
|
+
"Each choice must match the field type.": "選択肢の値をフィールドの型に合わせてください。",
|
|
367
|
+
"Choices must be unique.": "選択肢を重複させないでください。",
|
|
368
|
+
"Enter a value greater than {minimum}.": "{minimum}より大きい値を入力してください。",
|
|
369
|
+
"Page type": "ページの種類",
|
|
370
|
+
"Markdown page": "Markdown ページ",
|
|
371
|
+
"No subformats available to add.": "追加できる subformat はありません。",
|
|
372
|
+
"Add page": "ページを追加",
|
|
373
|
+
"Remove page": "ページを削除",
|
|
374
|
+
"Rename page": "ページ名を変更",
|
|
375
|
+
"Remove this page from the sidebar? The records will be kept.": "サイドバーからこのページを削除しますか? レコードは保持されます。",
|
|
376
|
+
"Constraints": "制約",
|
|
377
|
+
"Semantic": "意味情報",
|
|
378
|
+
"Items": "配列要素",
|
|
379
|
+
"Remove parameter": "パラメーターを削除",
|
|
380
|
+
"Check the parameter value.": "パラメーターの値を確認してください。"
|
|
317
381
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"Site title": "站点名称",
|
|
3
|
+
"Edit site title": "编辑站点名称",
|
|
2
4
|
"Editor font": "编辑器字体",
|
|
3
5
|
"Viewer font": "查看器字体",
|
|
4
6
|
"Default font": "默认字体",
|
|
@@ -151,9 +153,14 @@
|
|
|
151
153
|
"{count} results": "{count} 条结果",
|
|
152
154
|
"Showing {shown} of {count} results": "显示 {count} 条结果中的 {shown} 条",
|
|
153
155
|
"Add translation": "添加翻译文档",
|
|
154
|
-
"Folder": "文件夹",
|
|
155
156
|
"Move search": "移动搜索窗口",
|
|
156
157
|
"Resize search": "调整搜索窗口大小",
|
|
158
|
+
"Matches text": "匹配正文",
|
|
159
|
+
"Matches file name": "匹配文件名",
|
|
160
|
+
"Matches folder name": "匹配文件夹名",
|
|
161
|
+
"Close search": "关闭搜索窗口",
|
|
162
|
+
"Move search to sidebar": "将搜索窗口放到侧边栏",
|
|
163
|
+
"Float search": "让搜索窗口浮动",
|
|
157
164
|
"Notice": "提示",
|
|
158
165
|
"OK": "关闭",
|
|
159
166
|
"Discard changes": "放弃更改",
|
|
@@ -210,16 +217,21 @@
|
|
|
210
217
|
"File details": "文件信息",
|
|
211
218
|
"Show Git changes": "显示 Git 差异",
|
|
212
219
|
"Resource views": "资源视图",
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
220
|
+
"Default": "默认值",
|
|
221
|
+
"Set as default": "设为默认值",
|
|
222
|
+
"Group by": "分组依据",
|
|
223
|
+
"Sort by": "排序依据",
|
|
224
|
+
"Newest first": "从新到旧",
|
|
225
|
+
"Oldest first": "从旧到新",
|
|
226
|
+
"Unassigned": "未设置",
|
|
227
|
+
"Records": "记录",
|
|
228
|
+
"Codeblocks": "代码块",
|
|
229
|
+
"Format": "格式",
|
|
230
|
+
"URLs": "URL",
|
|
231
|
+
"URL previews": "URL 预览",
|
|
217
232
|
"Domain": "域名",
|
|
218
233
|
"All": "全部",
|
|
219
234
|
"references": "处引用",
|
|
220
|
-
"Definitions from term files and Markdown": "汇总术语文件和 Markdown 中的定义",
|
|
221
|
-
"Code blocks collected from Markdown files": "按语言和内容查找 Markdown 中的代码",
|
|
222
|
-
"External links and embeds with their source locations": "查看外部链接、嵌入 URL 及其来源",
|
|
223
235
|
"Search resources": "搜索资源",
|
|
224
236
|
"Files with errors": "读取或解析错误",
|
|
225
237
|
"No matching resources": "没有匹配的资源",
|
|
@@ -279,14 +291,21 @@
|
|
|
279
291
|
"Restore stash": "恢复 stash",
|
|
280
292
|
"Stash changes": "暂存更改",
|
|
281
293
|
"Statics": "Statics",
|
|
294
|
+
"Subformats": "Subformats",
|
|
295
|
+
"Expand card": "展开卡片",
|
|
296
|
+
"Collapse card": "折叠卡片",
|
|
297
|
+
"View details": "查看详情",
|
|
298
|
+
"Click for details; double-click to edit": "单击查看详情;双击编辑",
|
|
299
|
+
"No grouping": "不分组",
|
|
300
|
+
"Ascending": "升序",
|
|
301
|
+
"Descending": "降序",
|
|
302
|
+
"No subformats configured. Add subformats to dooc.yaml.": "尚未配置子格式。请在 dooc.yaml 中添加 subformats。",
|
|
282
303
|
"Workspace tools": "工作区工具",
|
|
283
|
-
"Resize workspace tools": "调整底部卡片高度",
|
|
284
304
|
"Git controls": "Git 操作",
|
|
285
305
|
"Actions": "操作",
|
|
286
306
|
"Updated": "已更新",
|
|
287
307
|
"Copy": "复制",
|
|
288
308
|
"Edit": "编辑",
|
|
289
|
-
"Saving…": "正在保存…",
|
|
290
309
|
"Reload actions before saving again.": "再次保存前请重新加载。",
|
|
291
310
|
"Saved, but refresh failed. Reload actions before saving again.": "保存已完成,但刷新失败。再次保存前请重新加载。",
|
|
292
311
|
"Actions could not be loaded.": "无法加载操作。",
|
|
@@ -313,5 +332,50 @@
|
|
|
313
332
|
"Sign out": "退出登录",
|
|
314
333
|
"Not signed in": "未登录",
|
|
315
334
|
"Continue login": "继续登录",
|
|
316
|
-
"Provided by viewer": "由查看器提供"
|
|
335
|
+
"Provided by viewer": "由查看器提供",
|
|
336
|
+
"Added": "新增",
|
|
337
|
+
"Modified": "修改",
|
|
338
|
+
"Add subformat…": "添加子格式…",
|
|
339
|
+
"Add subformat": "添加子格式",
|
|
340
|
+
"Extension": "扩展名",
|
|
341
|
+
"Storage format": "存储格式",
|
|
342
|
+
"Schema file (optional)": "模式文件(可选)",
|
|
343
|
+
"Create automatically": "自动创建",
|
|
344
|
+
"Form": "表单",
|
|
345
|
+
"Enter a valid number.": "请输入有效的数值。",
|
|
346
|
+
"Value editing mode": "值编辑模式",
|
|
347
|
+
"{format} text": "{format}文本",
|
|
348
|
+
"Schema editing mode": "模式编辑方式",
|
|
349
|
+
"JSON text": "JSON text",
|
|
350
|
+
"Build kit": "Build kit",
|
|
351
|
+
"Field settings": "字段设置",
|
|
352
|
+
"Field name": "字段名称",
|
|
353
|
+
"New field name": "新字段名称",
|
|
354
|
+
"New field type": "新字段类型",
|
|
355
|
+
"Remove field": "删除字段",
|
|
356
|
+
"Add field": "添加字段",
|
|
357
|
+
"Required": "必填",
|
|
358
|
+
"Allow extra fields": "允许额外字段",
|
|
359
|
+
"Choices (one per line)": "选项(每行一个)",
|
|
360
|
+
"Item type": "数组项类型",
|
|
361
|
+
"Rename linked fields in JSON text.": "请在JSON text中重命名关联字段。",
|
|
362
|
+
"Additional rules are preserved in JSON text.": "其他规则保留在JSON text中。",
|
|
363
|
+
"Enter a field name.": "请输入字段名称。",
|
|
364
|
+
"Enter a unique field name.": "请输入唯一的字段名称。",
|
|
365
|
+
"A field with this name already exists.": "已存在同名字段。",
|
|
366
|
+
"Each choice must match the field type.": "每个选项必须符合字段类型。",
|
|
367
|
+
"Choices must be unique.": "选项不能重复。",
|
|
368
|
+
"Enter a value greater than {minimum}.": "请输入大于{minimum}的值。",
|
|
369
|
+
"Page type": "页面类型",
|
|
370
|
+
"Markdown page": "Markdown 页面",
|
|
371
|
+
"No subformats available to add.": "没有可添加的子格式。",
|
|
372
|
+
"Add page": "添加页面",
|
|
373
|
+
"Remove page": "移除页面",
|
|
374
|
+
"Rename page": "重命名页面",
|
|
375
|
+
"Remove this page from the sidebar? The records will be kept.": "从侧边栏移除此页面?记录将被保留。",
|
|
376
|
+
"Constraints": "约束",
|
|
377
|
+
"Semantic": "语义信息",
|
|
378
|
+
"Items": "数组元素",
|
|
379
|
+
"Remove parameter": "移除参数",
|
|
380
|
+
"Check the parameter value.": "请检查参数值。"
|
|
317
381
|
}
|
package/dist/viewer/nav-focus.js
CHANGED
|
@@ -7,9 +7,16 @@ export const focusNavTree = (root) => {
|
|
|
7
7
|
for (let item = current; item; item = item.parentElement?.closest("[data-doc-id]")) {
|
|
8
8
|
path.unshift(item);
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const closed = document.body.classList.contains("sidebar-closed");
|
|
11
|
+
const width = closed
|
|
12
|
+
? Number(root.dataset.expandedWidth) ||
|
|
13
|
+
Number.parseFloat(getComputedStyle(root).getPropertyValue("--sidebar-width")) ||
|
|
14
|
+
260
|
|
15
|
+
: root.clientWidth;
|
|
11
16
|
if (!width)
|
|
12
17
|
return;
|
|
18
|
+
if (!closed)
|
|
19
|
+
root.dataset.expandedWidth = String(width);
|
|
13
20
|
const indent = 48 + Math.max(0, path.length - 2) * 29;
|
|
14
21
|
const ancestors = new Set(path.length > 2 && width < indent + 150 ? path.slice(0, -1) : []);
|
|
15
22
|
const items = [...root.querySelectorAll(".nav-item[data-doc-id]")];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Reconcile server navigation while retaining the user's tree and controls. */
|
|
2
|
+
export const updateNav = (root, html) => {
|
|
3
|
+
const template = root.ownerDocument.createElement("template");
|
|
4
|
+
template.innerHTML = html;
|
|
5
|
+
const key = (node) => {
|
|
6
|
+
if (!(node instanceof HTMLElement))
|
|
7
|
+
return;
|
|
8
|
+
if (node.dataset.docId)
|
|
9
|
+
return `doc:${node.dataset.docId}`;
|
|
10
|
+
if (node.dataset.nodeId)
|
|
11
|
+
return `tool:${node.dataset.nodeId}`;
|
|
12
|
+
if (node.id)
|
|
13
|
+
return `id:${node.id}`;
|
|
14
|
+
if (node.matches(".nav-list[data-parent]"))
|
|
15
|
+
return `list:${node.dataset.parent}`;
|
|
16
|
+
};
|
|
17
|
+
const keyed = new Map();
|
|
18
|
+
for (const node of root.querySelectorAll("[id], [data-doc-id], [data-node-id], .nav-list")) {
|
|
19
|
+
const id = key(node);
|
|
20
|
+
if (id)
|
|
21
|
+
keyed.set(id, node);
|
|
22
|
+
}
|
|
23
|
+
const active = root.contains(document.activeElement) ? document.activeElement : null;
|
|
24
|
+
const scroll = [
|
|
25
|
+
root.parentElement,
|
|
26
|
+
root.querySelector("#nav-docs"),
|
|
27
|
+
root.querySelector(".nav-tool-cards"),
|
|
28
|
+
]
|
|
29
|
+
.filter((node) => node instanceof HTMLElement)
|
|
30
|
+
.map((node) => ({ node, top: node.scrollTop, left: node.scrollLeft }));
|
|
31
|
+
const used = new Set();
|
|
32
|
+
const removed = [];
|
|
33
|
+
const sameType = (a, b) => a.nodeType === b.nodeType &&
|
|
34
|
+
(!(a instanceof Element) ||
|
|
35
|
+
(b instanceof Element &&
|
|
36
|
+
a.localName === b.localName &&
|
|
37
|
+
a.namespaceURI === b.namespaceURI));
|
|
38
|
+
const patch = (parent, source) => {
|
|
39
|
+
const previous = [...parent.childNodes];
|
|
40
|
+
let cursor = parent.firstChild;
|
|
41
|
+
for (const next of source.childNodes) {
|
|
42
|
+
const id = key(next);
|
|
43
|
+
const candidate = id
|
|
44
|
+
? keyed.get(id)
|
|
45
|
+
: previous.find((node) => !used.has(node) &&
|
|
46
|
+
!key(node) &&
|
|
47
|
+
!(node instanceof Element && node.matches(".nav-new-item")) &&
|
|
48
|
+
sameType(node, next));
|
|
49
|
+
const current = candidate && !used.has(candidate) && sameType(candidate, next)
|
|
50
|
+
? candidate
|
|
51
|
+
: next.cloneNode(false);
|
|
52
|
+
used.add(current);
|
|
53
|
+
if (current !== cursor) {
|
|
54
|
+
const container = parent;
|
|
55
|
+
if (current.isConnected && container.isConnected && container.moveBefore)
|
|
56
|
+
container.moveBefore(current, cursor);
|
|
57
|
+
else
|
|
58
|
+
parent.insertBefore(current, cursor);
|
|
59
|
+
}
|
|
60
|
+
if (current instanceof Element && next instanceof Element) {
|
|
61
|
+
const fresh = current !== candidate;
|
|
62
|
+
for (const name of new Set([
|
|
63
|
+
...current.getAttributeNames(),
|
|
64
|
+
...next.getAttributeNames(),
|
|
65
|
+
])) {
|
|
66
|
+
if (!fresh &&
|
|
67
|
+
(name === "inert" ||
|
|
68
|
+
(name === "open" && current.localName === "details") ||
|
|
69
|
+
(name === "style" && current.matches(".nav-list")) ||
|
|
70
|
+
(name === "aria-expanded" && current.matches(".nav-tree-toggle"))))
|
|
71
|
+
continue;
|
|
72
|
+
let value = next.getAttribute(name);
|
|
73
|
+
if (!fresh && name === "class" && current.matches(".nav-item")) {
|
|
74
|
+
const classes = new Set((value ?? "").split(/\s+/).filter(Boolean));
|
|
75
|
+
for (const state of ["open", "nav-ancestor", "dragging"])
|
|
76
|
+
if (current.classList.contains(state))
|
|
77
|
+
classes.add(state);
|
|
78
|
+
else
|
|
79
|
+
classes.delete(state);
|
|
80
|
+
value = [...classes].join(" ");
|
|
81
|
+
}
|
|
82
|
+
if (value === current.getAttribute(name))
|
|
83
|
+
continue;
|
|
84
|
+
if (value === null)
|
|
85
|
+
current.removeAttribute(name);
|
|
86
|
+
else
|
|
87
|
+
current.setAttribute(name, value);
|
|
88
|
+
}
|
|
89
|
+
if (current instanceof HTMLTemplateElement && next instanceof HTMLTemplateElement) {
|
|
90
|
+
if (current.innerHTML !== next.innerHTML)
|
|
91
|
+
current.innerHTML = next.innerHTML;
|
|
92
|
+
}
|
|
93
|
+
else if (!current.matches(".files-upload-status"))
|
|
94
|
+
patch(current, next);
|
|
95
|
+
}
|
|
96
|
+
else if (current.nodeValue !== next.nodeValue)
|
|
97
|
+
current.nodeValue = next.nodeValue;
|
|
98
|
+
cursor = current.nextSibling;
|
|
99
|
+
}
|
|
100
|
+
for (const node of previous)
|
|
101
|
+
if (!used.has(node) && !(node instanceof Element && node.matches(".nav-new-item")))
|
|
102
|
+
removed.push({ parent, node });
|
|
103
|
+
};
|
|
104
|
+
patch(root, template.content);
|
|
105
|
+
// Reparent descendants before deleting their old branch.
|
|
106
|
+
for (const { parent, node } of removed)
|
|
107
|
+
if (node.parentNode === parent && !used.has(node))
|
|
108
|
+
node.remove();
|
|
109
|
+
if (active instanceof HTMLElement && active.isConnected && document.activeElement !== active)
|
|
110
|
+
active.focus({ preventScroll: true });
|
|
111
|
+
for (const { node, top, left } of scroll) {
|
|
112
|
+
if (node.scrollTop !== top)
|
|
113
|
+
node.scrollTop = top;
|
|
114
|
+
if (node.scrollLeft !== left)
|
|
115
|
+
node.scrollLeft = left;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_BLOCK_CSS = "\n.plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border, #dde3eb); }\n.plugin-content th { background: var(--doc-bg-2, #f6f8fb); color: var(--doc-fg-2, #2a3140); font-size: 12px; font-weight: 600; }\n.plugin-content tr:last-child td { border-bottom: 0; }\n.plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }\n.plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }\n.plugin-blocks .plugin-block-heading { margin: 0 0 8px; padding: 0; border: 0; font: inherit; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--doc-fg, #000000); }\n.plugin-block-text { margin: 8px 0; white-space: pre-wrap; }\n.plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }\n.plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }\n.plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }\n.plugin-blocks > :last-child { margin-bottom: 0; }\n.plugin-blocks strong { font-weight: 600; }\n.plugin-blocks a { color: var(--doc-accent, #1b4994); text-underline-offset: 3px; }\n.plugin-blocks code { font-family: var(--doc-mono, ui-monospace, monospace); }\n.plugin-block-context { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0; color: var(--doc-fg-3, #5b6271); font-size: 11px; }\n.plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }\n.plugin-block-fields > div { min-width: 0; }\n.plugin-block-fields dt { color: var(--doc-fg-3, #5b6271); font-size: 10px; margin-bottom: 1px; }\n.plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }\n.plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }\n.plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }\n.plugin-block-columns aside { border-left: 1px solid var(--doc-border, #dde3eb); padding-left: 12px; }\n.plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }\n.plugin-block-section { border-top: 1px solid var(--doc-border, #dde3eb); padding-top: 6px; margin: 10px 0 0; min-width: 0; }\n.plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2, #2a3140); padding: 4px 0; }\n.plugin-block-note { color: var(--doc-warn, #b97600); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }\n.plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }\n.plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }\n.plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }\n.plugin-blocks .plugin-block-code { font: 12px/1.65 var(--doc-mono, ui-monospace, monospace); padding: 12px; margin: 10px 0; border: 1px solid var(--doc-border, #dde3eb); border-radius: 6px; max-height: 400px; overflow: auto; white-space: pre-wrap; }\n.plugin-block-diff code > span { display: inline-block; min-width: 100%; }\n.plugin-block-diff [data-tone=\"success\"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 8%, transparent); }\n.plugin-block-diff [data-tone=\"danger\"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 8%, transparent); }\n.plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border, #dde3eb); }\n.plugin-block-message:last-child { border-bottom: 0; }\n.plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n.plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3, #5b6271); font-size: 10px; }\n.plugin-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 12%, var(--doc-bg, #ffffff)); font-size: 10px; }\n.plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }\n.plugin-message-actions svg { display: block; width: 14px; height: 14px; }\n.plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3, #5b6271); }\n.plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }\n.plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }\n.plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }\n.plugin-reactions button { font: inherit; padding: 2px 8px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 12px; background: transparent; color: var(--doc-fg-2, #2a3140); cursor: pointer; }\n.plugin-reactions [aria-pressed=\"true\"] { border-color: var(--doc-accent, #1b4994); color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 8%, transparent); }\n.plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2, #2a3140); background: var(--doc-bg-2, #f6f8fb); }\n.plugin-badge[data-tone=\"accent\"] { color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"success\"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"warning\"] { color: var(--doc-warn, #b97600); background: color-mix(in srgb, var(--doc-warn, #b97600) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"danger\"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 10%, var(--doc-bg, #ffffff)); }\n.plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }\n.plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3, #5b6271); cursor: pointer; flex: none; }\n.plugin-copy svg { width: 14px; height: 14px; }\n.plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3, #5b6271); margin: 12px 0; }\n.plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent, #1b4994); }\n.plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }\n.plugin-block-actions:has([data-block-composer]) { display: block; }\n.plugin-block-button { font: inherit; font-size: 12px; padding: 5px 10px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 5px; color: var(--doc-fg, #000000); background: transparent; cursor: pointer; }\n.plugin-block-button:hover { background: var(--doc-bg-2, #f6f8fb); }\n.plugin-block-button:disabled { opacity: .5; cursor: wait; }\n.plugin-action[aria-pressed=\"true\"] { color: var(--doc-accent, #1b4994); background: var(--doc-bg-2, #f6f8fb); }\n.plugin-danger { color: var(--doc-danger, #b53030); }\n.plugin [data-plugin-edit-trigger]:focus-visible, .plugin :is(button, summary, input, select, textarea):focus-visible, .plugin-block-table:focus-visible { outline: 2px solid var(--doc-accent, #1b4994); outline-offset: 2px; }\n.plugin-editor { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font: inherit; font-size: 12px; line-height: 1.5; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); min-width: 0; }\n.plugin-editor label { display: grid; gap: 0; font-size: 0; }\n.plugin-editor :is(input, textarea, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; padding: 3px 6px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 4px; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); font: inherit; font-size: 12px; line-height: 1.5; }\n.plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }\n.plugin-editor .plugin-submit { background: var(--doc-accent, #1b4994); color: var(--doc-accent-fg, #ffffff); border-color: transparent; }\n.plugin-editor-notice { color: var(--doc-danger, #b53030); font-size: 11px; }\n.plugin-editor-notice:empty { display: none; }\n.plugin [hidden] { display: none !important; }\n@container (max-width: 600px) {\n .plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }\n .plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border, #dde3eb); padding: 14px 0 0; }\n .plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n .plugin-heading-context { display: none; }\n .plugin-blocks .plugin-block-heading { font-size: 16px; }\n .plugin-message-body, .plugin-reactions { margin-left: 0; }\n}\n";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const PLUGIN_BLOCK_CSS = `
|
|
2
|
+
.plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border, #dde3eb); }
|
|
3
|
+
.plugin-content th { background: var(--doc-bg-2, #f6f8fb); color: var(--doc-fg-2, #2a3140); font-size: 12px; font-weight: 600; }
|
|
4
|
+
.plugin-content tr:last-child td { border-bottom: 0; }
|
|
5
|
+
.plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
|
|
6
|
+
.plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }
|
|
7
|
+
.plugin-blocks .plugin-block-heading { margin: 0 0 8px; padding: 0; border: 0; font: inherit; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--doc-fg, #000000); }
|
|
8
|
+
.plugin-block-text { margin: 8px 0; white-space: pre-wrap; }
|
|
9
|
+
.plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }
|
|
10
|
+
.plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }
|
|
11
|
+
.plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }
|
|
12
|
+
.plugin-blocks > :last-child { margin-bottom: 0; }
|
|
13
|
+
.plugin-blocks strong { font-weight: 600; }
|
|
14
|
+
.plugin-blocks a { color: var(--doc-accent, #1b4994); text-underline-offset: 3px; }
|
|
15
|
+
.plugin-blocks code { font-family: var(--doc-mono, ui-monospace, monospace); }
|
|
16
|
+
.plugin-block-context { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0; color: var(--doc-fg-3, #5b6271); font-size: 11px; }
|
|
17
|
+
.plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }
|
|
18
|
+
.plugin-block-fields > div { min-width: 0; }
|
|
19
|
+
.plugin-block-fields dt { color: var(--doc-fg-3, #5b6271); font-size: 10px; margin-bottom: 1px; }
|
|
20
|
+
.plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }
|
|
21
|
+
.plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }
|
|
22
|
+
.plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }
|
|
23
|
+
.plugin-block-columns aside { border-left: 1px solid var(--doc-border, #dde3eb); padding-left: 12px; }
|
|
24
|
+
.plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }
|
|
25
|
+
.plugin-block-section { border-top: 1px solid var(--doc-border, #dde3eb); padding-top: 6px; margin: 10px 0 0; min-width: 0; }
|
|
26
|
+
.plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2, #2a3140); padding: 4px 0; }
|
|
27
|
+
.plugin-block-note { color: var(--doc-warn, #b97600); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }
|
|
28
|
+
.plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }
|
|
29
|
+
.plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
30
|
+
.plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }
|
|
31
|
+
.plugin-blocks .plugin-block-code { font: 12px/1.65 var(--doc-mono, ui-monospace, monospace); padding: 12px; margin: 10px 0; border: 1px solid var(--doc-border, #dde3eb); border-radius: 6px; max-height: 400px; overflow: auto; white-space: pre-wrap; }
|
|
32
|
+
.plugin-block-diff code > span { display: inline-block; min-width: 100%; }
|
|
33
|
+
.plugin-block-diff [data-tone="success"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 8%, transparent); }
|
|
34
|
+
.plugin-block-diff [data-tone="danger"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 8%, transparent); }
|
|
35
|
+
.plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border, #dde3eb); }
|
|
36
|
+
.plugin-block-message:last-child { border-bottom: 0; }
|
|
37
|
+
.plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
38
|
+
.plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3, #5b6271); font-size: 10px; }
|
|
39
|
+
.plugin-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 12%, var(--doc-bg, #ffffff)); font-size: 10px; }
|
|
40
|
+
.plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }
|
|
41
|
+
.plugin-message-actions svg { display: block; width: 14px; height: 14px; }
|
|
42
|
+
.plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3, #5b6271); }
|
|
43
|
+
.plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }
|
|
44
|
+
.plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }
|
|
45
|
+
.plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }
|
|
46
|
+
.plugin-reactions button { font: inherit; padding: 2px 8px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 12px; background: transparent; color: var(--doc-fg-2, #2a3140); cursor: pointer; }
|
|
47
|
+
.plugin-reactions [aria-pressed="true"] { border-color: var(--doc-accent, #1b4994); color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 8%, transparent); }
|
|
48
|
+
.plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2, #2a3140); background: var(--doc-bg-2, #f6f8fb); }
|
|
49
|
+
.plugin-badge[data-tone="accent"] { color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 10%, var(--doc-bg, #ffffff)); }
|
|
50
|
+
.plugin-badge[data-tone="success"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 10%, var(--doc-bg, #ffffff)); }
|
|
51
|
+
.plugin-badge[data-tone="warning"] { color: var(--doc-warn, #b97600); background: color-mix(in srgb, var(--doc-warn, #b97600) 10%, var(--doc-bg, #ffffff)); }
|
|
52
|
+
.plugin-badge[data-tone="danger"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 10%, var(--doc-bg, #ffffff)); }
|
|
53
|
+
.plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }
|
|
54
|
+
.plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3, #5b6271); cursor: pointer; flex: none; }
|
|
55
|
+
.plugin-copy svg { width: 14px; height: 14px; }
|
|
56
|
+
.plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3, #5b6271); margin: 12px 0; }
|
|
57
|
+
.plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent, #1b4994); }
|
|
58
|
+
.plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
|
|
59
|
+
.plugin-block-actions:has([data-block-composer]) { display: block; }
|
|
60
|
+
.plugin-block-button { font: inherit; font-size: 12px; padding: 5px 10px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 5px; color: var(--doc-fg, #000000); background: transparent; cursor: pointer; }
|
|
61
|
+
.plugin-block-button:hover { background: var(--doc-bg-2, #f6f8fb); }
|
|
62
|
+
.plugin-block-button:disabled { opacity: .5; cursor: wait; }
|
|
63
|
+
.plugin-action[aria-pressed="true"] { color: var(--doc-accent, #1b4994); background: var(--doc-bg-2, #f6f8fb); }
|
|
64
|
+
.plugin-danger { color: var(--doc-danger, #b53030); }
|
|
65
|
+
.plugin [data-plugin-edit-trigger]:focus-visible, .plugin :is(button, summary, input, select, textarea):focus-visible, .plugin-block-table:focus-visible { outline: 2px solid var(--doc-accent, #1b4994); outline-offset: 2px; }
|
|
66
|
+
.plugin-editor { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font: inherit; font-size: 12px; line-height: 1.5; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); min-width: 0; }
|
|
67
|
+
.plugin-editor label { display: grid; gap: 0; font-size: 0; }
|
|
68
|
+
.plugin-editor :is(input, textarea, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; padding: 3px 6px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 4px; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); font: inherit; font-size: 12px; line-height: 1.5; }
|
|
69
|
+
.plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }
|
|
70
|
+
.plugin-editor .plugin-submit { background: var(--doc-accent, #1b4994); color: var(--doc-accent-fg, #ffffff); border-color: transparent; }
|
|
71
|
+
.plugin-editor-notice { color: var(--doc-danger, #b53030); font-size: 11px; }
|
|
72
|
+
.plugin-editor-notice:empty { display: none; }
|
|
73
|
+
.plugin [hidden] { display: none !important; }
|
|
74
|
+
@container (max-width: 600px) {
|
|
75
|
+
.plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }
|
|
76
|
+
.plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border, #dde3eb); padding: 14px 0 0; }
|
|
77
|
+
.plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
78
|
+
.plugin-heading-context { display: none; }
|
|
79
|
+
.plugin-blocks .plugin-block-heading { font-size: 16px; }
|
|
80
|
+
.plugin-message-body, .plugin-reactions { margin-left: 0; }
|
|
81
|
+
}
|
|
82
|
+
`;
|
package/dist/viewer/plugins.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { escapeHtml } from "../core/html.js";
|
|
2
3
|
import { isPluginError, PluginError } from "../plugins/oauth.js";
|
|
3
4
|
import { createPluginRuntime } from "../plugins/runtime.js";
|
|
4
5
|
import { isLocalToolRequest } from "./editor-tools.js";
|
|
@@ -95,7 +96,11 @@ export const createPluginHandler = (plugins, presentation = { mocks: {} }, crede
|
|
|
95
96
|
tickets.set(ticket, { plugin, origin, expires: Date.now() + 10 * 60 * 1000 });
|
|
96
97
|
return `${origin}/api/plugins/login/${plugin}?ticket=${ticket}`;
|
|
97
98
|
};
|
|
98
|
-
const authorizationUrl = (session, plugin, host) => {
|
|
99
|
+
const authorizationUrl = async (session, plugin, host) => {
|
|
100
|
+
if (config.plugins.find((item) => item.id === plugin)?.oauth.deviceAuthorizationUrl) {
|
|
101
|
+
const state = await runtime.connectDevice(session, plugin);
|
|
102
|
+
return `http://${host}/api/plugins/device/${plugin}?state=${state}`;
|
|
103
|
+
}
|
|
99
104
|
const authorization = new URL(runtime.connect(session, plugin, `http://${host}/api/plugins/callback/${plugin}`));
|
|
100
105
|
const mock = origins.get(authorization.origin);
|
|
101
106
|
return mock
|
|
@@ -184,10 +189,48 @@ export const createPluginHandler = (plugins, presentation = { mocks: {} }, crede
|
|
|
184
189
|
tickets.delete(key);
|
|
185
190
|
if (!runtime.hasSession(session))
|
|
186
191
|
createSession();
|
|
187
|
-
res.writeHead(303, {
|
|
192
|
+
res.writeHead(303, {
|
|
193
|
+
location: await authorizationUrl(session, ticket.plugin, host),
|
|
194
|
+
});
|
|
188
195
|
res.end();
|
|
189
196
|
return true;
|
|
190
197
|
}
|
|
198
|
+
const device = /^\/api\/plugins\/device\/([a-z][a-z0-9-]{0,63})$/.exec(url.pathname);
|
|
199
|
+
if (req.method === "GET" && device?.[1]) {
|
|
200
|
+
if (url.searchParams.getAll("state").length !== 1)
|
|
201
|
+
throw new PluginError(400, "Invalid device authorization");
|
|
202
|
+
const pending = await runtime.pollDevice(session, device[1], url.searchParams.get("state") ?? "");
|
|
203
|
+
if (req.headers.accept === "application/json") {
|
|
204
|
+
send(200, pending ?? { connected: true });
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
const nonce = randomBytes(16).toString("hex");
|
|
208
|
+
res.setHeader("content-security-policy", `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`);
|
|
209
|
+
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
210
|
+
const name = escapeHtml(config.plugins.find((item) => item.id === device[1])?.name ?? device[1]);
|
|
211
|
+
res.end(`<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Connect ${name}</title>
|
|
212
|
+
<style>html{color-scheme:light dark}body{max-width:32rem;margin:4rem auto;padding:0 1.5rem;font:16px/1.6 system-ui}input{font:1.5rem monospace;max-width:100%;box-sizing:border-box;padding:.5rem}a{color:LinkText}:focus-visible{outline:2px solid LinkText;outline-offset:3px}</style>
|
|
213
|
+
<main><h1>Connect ${name}</h1>${pending ? `<section id="instructions"><p>Enter this code on ${name} to authorize dooc.</p><p><label>Verification code<br><input readonly value="${escapeHtml(pending.userCode)}"></label></p><p><a href="${escapeHtml(pending.verificationUri)}" target="_blank" rel="noopener noreferrer">Continue to ${name}</a></p><noscript><p>After approving, <a href="">check the connection</a>.</p></noscript></section>` : ""}
|
|
214
|
+
<p id="status" role="status">${pending ? "Waiting for authorization…" : "Connected. You can close this tab and return to dooc."}</p></main>
|
|
215
|
+
${pending
|
|
216
|
+
? `<script nonce="${nonce}">
|
|
217
|
+
const status = document.getElementById("status");
|
|
218
|
+
async function poll() {
|
|
219
|
+
try {
|
|
220
|
+
const response = await fetch(location.href, {headers:{accept:"application/json"}});
|
|
221
|
+
const data = await response.json();
|
|
222
|
+
if (!response.ok) throw new Error(data.error || "Sign-in failed. Return to dooc and try again.");
|
|
223
|
+
if (data.connected) {
|
|
224
|
+
document.getElementById("instructions").hidden = true;
|
|
225
|
+
status.textContent = "Connected. You can close this tab and return to dooc.";
|
|
226
|
+
} else setTimeout(poll, data.retryAfter * 1000);
|
|
227
|
+
} catch (error) { status.textContent = error.message; }
|
|
228
|
+
}
|
|
229
|
+
setTimeout(poll, ${pending.retryAfter * 1000});
|
|
230
|
+
</script>`
|
|
231
|
+
: ""}</html>`);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
191
234
|
const callback = /^\/api\/plugins\/callback\/([a-z][a-z0-9-]{0,63})$/.exec(url.pathname);
|
|
192
235
|
if (req.method === "GET" && callback?.[1]) {
|
|
193
236
|
let cancelled = false;
|
|
@@ -231,7 +274,7 @@ export const createPluginHandler = (plugins, presentation = { mocks: {} }, crede
|
|
|
231
274
|
(credentials || input.action === "connect" || input.action === "status"))
|
|
232
275
|
createSession();
|
|
233
276
|
if (input.action === "connect") {
|
|
234
|
-
send(200, { url: authorizationUrl(session, input.plugin, host) });
|
|
277
|
+
send(200, { url: await authorizationUrl(session, input.plugin, host) });
|
|
235
278
|
}
|
|
236
279
|
else if (input.action === "status") {
|
|
237
280
|
send(200, { user: runtime.status(session, input.plugin) ?? null });
|
package/dist/viewer/resize.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/** Shared by editor, preview, and published pages; keep this function self-contained. */
|
|
2
2
|
export declare const mountPanelResize: () => void;
|
|
3
|
-
/** The navigation is replaced on refresh; keep listeners and height on its stable sidebar. */
|
|
4
|
-
export declare const mountToolsResize: () => (() => void);
|