mn-docs-mcp 0.6.2 → 1.1.0

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.
Files changed (222) hide show
  1. package/.trae/documents/libmn_cleanup_plan.md +51 -0
  2. package/.trae/documents/libmn_doc_restructure_plan.md +140 -0
  3. package/.trae/documents/libmn_indentation_plan.md +116 -0
  4. package/.trae/documents/libmn_title_hierarchy_plan.md +91 -0
  5. package/README.md +9 -7
  6. package/next-env.d.ts +6 -0
  7. package/next.config.mjs +14 -0
  8. package/package.json +25 -10
  9. package/postcss.config.mjs +7 -0
  10. package/scripts/sync-definitions.mjs +33 -0
  11. package/source.config.ts +5 -0
  12. package/src/app/[[...slug]]/page.tsx +259 -0
  13. package/src/app/api/search/route.ts +6 -0
  14. package/src/app/global.css +81 -0
  15. package/src/app/layout.tsx +33 -0
  16. package/src/components/JsbApiFooter.tsx +251 -0
  17. package/src/content/docs/{guides/contributing.md → contributing.md} +31 -6
  18. package/src/content/docs/{guides/cookbook → cookbook}/addon-settings.md +2 -2
  19. package/src/content/docs/{guides/cookbook → cookbook}/embed-webview-panel.md +2 -2
  20. package/src/content/docs/cookbook/meta.json +13 -0
  21. package/src/content/docs/{guides/cookbook → cookbook}/network-api-call.md +2 -2
  22. package/src/content/docs/{guides/cookbook → cookbook}/webview-bidirectional-js.md +1 -1
  23. package/src/content/docs/guides/getting-started.md +2 -2
  24. package/src/content/docs/guides/lifecycle-and-window.md +4 -4
  25. package/src/content/docs/guides/meta.json +14 -0
  26. package/src/content/docs/guides/mindmap-and-selection.md +2 -2
  27. package/src/content/docs/guides/native-ui.md +4 -4
  28. package/src/content/docs/guides/network-requests.md +8 -9
  29. package/src/content/docs/guides/notes-and-database.md +2 -2
  30. package/src/content/docs/guides/shortcut-keys.md +9 -9
  31. package/src/content/docs/guides/storage-and-files.md +4 -4
  32. package/src/content/docs/guides/toolbar-and-commands.md +1 -1
  33. package/src/content/docs/index.mdx +13 -38
  34. package/src/content/docs/libmn/data-converter.md +1572 -0
  35. package/src/content/docs/libmn/frame.md +279 -0
  36. package/src/content/docs/libmn/headers.md +234 -0
  37. package/src/content/docs/libmn/index.md +60 -0
  38. package/src/content/docs/libmn/internal-exposed.md +46 -0
  39. package/src/content/docs/libmn/locale.md +307 -0
  40. package/src/content/docs/libmn/menu.md +77 -0
  41. package/src/content/docs/libmn/meta.json +27 -0
  42. package/src/content/docs/libmn/mnbutton.md +966 -0
  43. package/src/content/docs/libmn/mncomment.md +533 -0
  44. package/src/content/docs/libmn/mnconnection.md +717 -0
  45. package/src/content/docs/libmn/mndocument.md +309 -0
  46. package/src/content/docs/libmn/mnextension-panel.md +340 -0
  47. package/src/content/docs/libmn/mnnote.md +533 -0
  48. package/src/content/docs/libmn/mnnotebook.md +725 -0
  49. package/src/content/docs/libmn/mnutil.md +2936 -0
  50. package/src/content/docs/libmn/mnwebview.md +693 -0
  51. package/src/content/docs/libmn/mustache.md +65 -0
  52. package/src/content/docs/libmn/response.md +352 -0
  53. package/src/content/docs/libmn/runtime-assets.md +64 -0
  54. package/src/content/docs/libmn/runtime-web-view-host.md +77 -0
  55. package/src/content/docs/libmn/runtime.md +178 -0
  56. package/src/content/docs/libmn/vendor-globals.md +34 -0
  57. package/src/content/docs/meta.json +11 -0
  58. package/src/content/docs/reference/black-box.md +2 -2
  59. package/src/content/docs/reference/foundation/meta.json +4 -0
  60. package/src/content/docs/reference/foundation/ns-attributed-string.md +1 -1
  61. package/src/content/docs/reference/foundation/ns-counted-set.md +1 -1
  62. package/src/content/docs/reference/foundation/ns-date-components.md +2 -2
  63. package/src/content/docs/reference/foundation/ns-date-formatter.md +1 -3
  64. package/src/content/docs/reference/foundation/ns-decimal-number.md +1 -1
  65. package/src/content/docs/reference/foundation/ns-enumerator.md +1 -1
  66. package/src/content/docs/reference/foundation/ns-error.md +2 -2
  67. package/src/content/docs/reference/foundation/ns-file-manager.md +1 -1
  68. package/src/content/docs/reference/foundation/ns-formatter.md +2 -2
  69. package/src/content/docs/reference/foundation/ns-json-serialization.md +10 -2
  70. package/src/content/docs/reference/foundation/ns-mutable-attributed-string.md +1 -1
  71. package/src/content/docs/reference/foundation/ns-mutable-character-set.md +1 -1
  72. package/src/content/docs/reference/foundation/ns-mutable-dictionary.md +1 -1
  73. package/src/content/docs/reference/foundation/ns-mutable-index-set.md +1 -1
  74. package/src/content/docs/reference/foundation/ns-mutable-set.md +1 -1
  75. package/src/content/docs/reference/foundation/ns-mutable-string.md +1 -1
  76. package/src/content/docs/reference/foundation/ns-mutable-url-request.md +2 -3
  77. package/src/content/docs/reference/foundation/ns-null.md +1 -1
  78. package/src/content/docs/reference/foundation/ns-number-formatter.md +1 -1
  79. package/src/content/docs/reference/foundation/ns-operation.md +2 -2
  80. package/src/content/docs/reference/foundation/ns-pointer-array.md +1 -1
  81. package/src/content/docs/reference/foundation/ns-proxy.md +5 -3
  82. package/src/content/docs/reference/foundation/ns-scanner.md +7 -1
  83. package/src/content/docs/reference/foundation/ns-set.md +1 -1
  84. package/src/content/docs/reference/foundation/ns-simple-c-string.md +3 -4
  85. package/src/content/docs/reference/foundation/ns-time-zone.md +1 -1
  86. package/src/content/docs/reference/foundation/ns-ubiquitous-key-value-store.md +61 -0
  87. package/src/content/docs/reference/foundation/ns-url-connection.md +2 -2
  88. package/src/content/docs/reference/foundation/ns-url-request.md +2 -2
  89. package/src/content/docs/reference/foundation/ns-url-response.md +5 -5
  90. package/src/content/docs/reference/foundation/ns-url.md +1 -1
  91. package/src/content/docs/reference/foundation/ns-user-defaults.md +5 -5
  92. package/src/content/docs/reference/foundation/ns-value.md +15 -15
  93. package/src/content/docs/reference/global/agent-tools.md +91 -0
  94. package/src/content/docs/reference/global/application.md +4 -4
  95. package/src/content/docs/reference/global/builtin-commands.md +2 -2
  96. package/src/content/docs/reference/global/database.md +4 -4
  97. package/src/content/docs/reference/global/document.md +21 -0
  98. package/src/content/docs/reference/global/global-variables.md +22 -5
  99. package/src/content/docs/reference/global/jsb.md +6 -4
  100. package/src/content/docs/reference/global/meta.json +18 -0
  101. package/src/content/docs/reference/global/note.md +2 -2
  102. package/src/content/docs/reference/global/notebook.md +21 -0
  103. package/src/content/docs/reference/global/popup-menu-item.md +2 -2
  104. package/src/content/docs/reference/global/popup-menu.md +5 -6
  105. package/src/content/docs/reference/global/search-manager.md +12 -6
  106. package/src/content/docs/reference/global/self.md +1 -13
  107. package/src/content/docs/reference/js-runtime.md +5 -4
  108. package/src/content/docs/reference/marginnote/document-controller.md +37 -5
  109. package/src/content/docs/reference/marginnote/jsextension.md +7 -7
  110. package/src/content/docs/reference/marginnote/mb-book-note.md +162 -72
  111. package/src/content/docs/reference/marginnote/mb-book.md +3 -3
  112. package/src/content/docs/reference/marginnote/mb-model-tool.md +2 -2
  113. package/src/content/docs/reference/marginnote/mb-topic.md +13 -2
  114. package/src/content/docs/reference/marginnote/meta.json +18 -0
  115. package/src/content/docs/reference/marginnote/mindmap-node.md +2 -2
  116. package/src/content/docs/reference/marginnote/mindmap-view.md +2 -2
  117. package/src/content/docs/reference/marginnote/notebook-controller.md +1 -1
  118. package/src/content/docs/reference/marginnote/outline-view.md +2 -2
  119. package/src/content/docs/reference/marginnote/reader-controller.md +1 -1
  120. package/src/content/docs/reference/marginnote/study-controller.md +19 -19
  121. package/src/content/docs/reference/meta.json +14 -0
  122. package/src/content/docs/reference/quartzcore/caanimation-group.md +3 -3
  123. package/src/content/docs/reference/quartzcore/cabasic-animation.md +3 -3
  124. package/src/content/docs/reference/quartzcore/caemitter-layer.md +44 -0
  125. package/src/content/docs/reference/quartzcore/cagradient-layer.md +1 -1
  126. package/src/content/docs/reference/quartzcore/cakeyframe-animation.md +3 -3
  127. package/src/content/docs/reference/quartzcore/calayer.md +1 -1
  128. package/src/content/docs/reference/quartzcore/camedia-timing-function.md +1 -1
  129. package/src/content/docs/reference/quartzcore/caproperty-animation.md +1 -1
  130. package/src/content/docs/reference/quartzcore/careplicator-layer.md +2 -2
  131. package/src/content/docs/reference/quartzcore/cascroll-layer.md +1 -1
  132. package/src/content/docs/reference/quartzcore/cashape-layer.md +2 -2
  133. package/src/content/docs/reference/quartzcore/catext-layer.md +4 -4
  134. package/src/content/docs/reference/quartzcore/catransaction.md +5 -3
  135. package/src/content/docs/reference/quartzcore/catransform-layer.md +3 -3
  136. package/src/content/docs/reference/quartzcore/catransition.md +10 -6
  137. package/src/content/docs/reference/quartzcore/cavalue-function.md +1 -1
  138. package/src/content/docs/reference/quartzcore/meta.json +4 -0
  139. package/src/content/docs/reference/uikit/meta.json +4 -0
  140. package/src/content/docs/reference/uikit/ns-mutable-paragraph-style.md +3 -3
  141. package/src/content/docs/reference/uikit/ns-paragraph-style.md +3 -4
  142. package/src/content/docs/reference/uikit/ns-text-storage.md +4 -5
  143. package/src/content/docs/reference/uikit/uiactivity-indicator-view.md +2 -2
  144. package/src/content/docs/reference/uikit/uiapplication.md +1 -1
  145. package/src/content/docs/reference/uikit/uibar-button-item.md +3 -4
  146. package/src/content/docs/reference/uikit/uibar-item.md +2 -3
  147. package/src/content/docs/reference/uikit/uibezier-path.md +2 -2
  148. package/src/content/docs/reference/uikit/uibutton.md +1 -1
  149. package/src/content/docs/reference/uikit/uicollection-view-cell.md +5 -5
  150. package/src/content/docs/reference/uikit/uicollection-view-controller.md +22 -2
  151. package/src/content/docs/reference/uikit/uicollection-view-flow-layout.md +54 -0
  152. package/src/content/docs/reference/uikit/uicollection-view-layout.md +9 -2
  153. package/src/content/docs/reference/uikit/uicollection-view.md +13 -4
  154. package/src/content/docs/reference/uikit/uicolor.md +1 -1
  155. package/src/content/docs/reference/uikit/uicontrol.md +3 -5
  156. package/src/content/docs/reference/uikit/uidate-picker.md +1 -1
  157. package/src/content/docs/reference/uikit/uievent.md +2 -2
  158. package/src/content/docs/reference/uikit/uifont.md +1 -1
  159. package/src/content/docs/reference/uikit/uigesture-recognizer.md +1 -1
  160. package/src/content/docs/reference/uikit/uiimage-picker-controller.md +1 -1
  161. package/src/content/docs/reference/uikit/uiimage-view.md +2 -2
  162. package/src/content/docs/reference/uikit/uiimage.md +2 -2
  163. package/src/content/docs/reference/uikit/uikey-command.md +2 -2
  164. package/src/content/docs/reference/uikit/uilabel.md +3 -3
  165. package/src/content/docs/reference/uikit/uilocal-notification.md +2 -2
  166. package/src/content/docs/reference/uikit/uilong-press-gesture-recognizer.md +2 -2
  167. package/src/content/docs/reference/uikit/uinavigation-bar.md +2 -2
  168. package/src/content/docs/reference/uikit/uinavigation-controller.md +1 -1
  169. package/src/content/docs/reference/uikit/uinavigation-item.md +1 -1
  170. package/src/content/docs/reference/uikit/uipage-control.md +1 -1
  171. package/src/content/docs/reference/uikit/uipage-view-controller.md +1 -1
  172. package/src/content/docs/reference/uikit/uipan-gesture-recognizer.md +1 -1
  173. package/src/content/docs/reference/uikit/uipasteboard.md +1 -1
  174. package/src/content/docs/reference/uikit/uipicker-view.md +3 -3
  175. package/src/content/docs/reference/uikit/uipinch-gesture-recognizer.md +1 -1
  176. package/src/content/docs/reference/uikit/uipopover-controller.md +1 -1
  177. package/src/content/docs/reference/uikit/uiresponder.md +3 -4
  178. package/src/content/docs/reference/uikit/uirotation-gesture-recognizer.md +1 -1
  179. package/src/content/docs/reference/uikit/uiscreen-mode.md +2 -2
  180. package/src/content/docs/reference/uikit/uiscrollview.md +1 -1
  181. package/src/content/docs/reference/uikit/uisearch-bar.md +25 -2
  182. package/src/content/docs/reference/uikit/uisegmented-control.md +1 -1
  183. package/src/content/docs/reference/uikit/uislider.md +1 -1
  184. package/src/content/docs/reference/uikit/uiswipe-gesture-recognizer.md +1 -1
  185. package/src/content/docs/reference/uikit/uiswitch.md +2 -2
  186. package/src/content/docs/reference/uikit/uitab-bar-controller.md +2 -2
  187. package/src/content/docs/reference/uikit/uitab-bar-item.md +1 -1
  188. package/src/content/docs/reference/uikit/uitab-bar.md +1 -1
  189. package/src/content/docs/reference/uikit/uitable-view-cell.md +6 -6
  190. package/src/content/docs/reference/uikit/uitable-view-controller.md +1 -1
  191. package/src/content/docs/reference/uikit/uitable-view.md +3 -3
  192. package/src/content/docs/reference/uikit/uitap-gesture-recognizer.md +2 -2
  193. package/src/content/docs/reference/uikit/uitext-input-mode.md +7 -3
  194. package/src/content/docs/reference/uikit/uitext-position.md +5 -5
  195. package/src/content/docs/reference/uikit/uitext-range.md +4 -4
  196. package/src/content/docs/reference/uikit/uitext-view.md +2 -2
  197. package/src/content/docs/reference/uikit/uitextfield.md +3 -3
  198. package/src/content/docs/reference/uikit/uitoolbar.md +1 -1
  199. package/src/content/docs/reference/uikit/uitouch.md +3 -3
  200. package/src/content/docs/reference/uikit/uiview-controller.md +2 -2
  201. package/src/content/docs/reference/uikit/uiview.md +5 -5
  202. package/src/content/docs/reference/uikit/uiwebview.md +5 -5
  203. package/src/content/docs/reference/uikit/uiwindow.md +2 -2
  204. package/src/content/docs/reference/utility/menu-controller.md +1 -1
  205. package/src/content/docs/reference/utility/meta.json +4 -0
  206. package/src/content/docs/reference/utility/sqlite-result-set.md +1 -1
  207. package/src/content/docs/reference/utility/sqlite-statement.md +2 -2
  208. package/src/content/docs/reference/utility/zip-archive.md +13 -14
  209. package/src/content/docs/reference/value-sturct.md +105 -0
  210. package/src/lib/layout.tsx +31 -0
  211. package/src/lib/source.ts +7 -0
  212. package/tsconfig.json +42 -3
  213. package/astro.config.mjs +0 -126
  214. package/src/client/jsb-api-footer.ts +0 -242
  215. package/src/components/Footer.astro +0 -57
  216. package/src/components/Search.astro +0 -330
  217. package/src/content.config.ts +0 -7
  218. package/src/styles/starlight-overrides.css +0 -23
  219. /package/src/content/docs/{guides/cookbook → cookbook}/append-selection-as-comment.md +0 -0
  220. /package/src/content/docs/{guides/cookbook → cookbook}/batch-rename-notes.md +0 -0
  221. /package/src/content/docs/{guides/cookbook → cookbook}/export-notebook.md +0 -0
  222. /package/src/content/docs/{guides/cookbook → cookbook}/focus-note-in-mindmap.md +0 -0
@@ -8,12 +8,12 @@ description: 文档贡献流程与格式规范(API 参考、教程、Markdown
8
8
  ## 贡献流程
9
9
 
10
10
  1. **Fork** 本仓库到你的 GitHub 账号。
11
- 2. **创建分支**:从默认分支(如 `main`)拉取新分支,建议命名 `docs/xxx` 或 `fix/typo-xxx`。
11
+ 2. **创建分支**:从默认分支(如 `main`)拉取新分支,命名 `docs/xxx` 或 `fix/typo-xxx`。
12
12
  3. **修改**:在本地或 GitHub 网页编辑器中修改文档。
13
13
  4. **提交并推送**:提交到你的 Fork,推送到 GitHub。
14
14
  5. **发起 Pull Request**:在本仓库创建 PR,目标分支为默认分支(如 `main`)。
15
15
 
16
- **PR 描述建议包含**:修改类型(纠错 / 新增教程 / 新增或修订 API 页)、涉及文件或路径、简要说明。
16
+ **PR 描述应包含**:修改类型(纠错 / 新增教程 / 新增或修订 API 页)、涉及文件或路径、简要说明。
17
17
 
18
18
  ## 文档结构约定
19
19
 
@@ -21,7 +21,7 @@ description: 文档贡献流程与格式规范(API 参考、教程、Markdown
21
21
  - `guides/`:教程与 Cookbook 配方;
22
22
  - `reference/`:API 参考,按 `global`、`marginnote`、`foundation`、`uikit`、`quartzcore`、`utility` 等子目录组织。
23
23
  - **新增页面**:参考同类型现有页面。若为 API 参考,需符合下述「API 参考格式」;若为教程或 Cookbook,需符合「教程与指南格式」。
24
- - **侧栏**:若新增的是 `reference/` 下且位于已配置 `autogenerate` 的目录(如 Foundation、UIKit),侧栏会自动出现;若为 `guides/` 新页或新目录,需在 `astro.config.mjs` 的 `sidebar` 中手动添加对应 `slug`。
24
+ - **侧栏**:新增页面后按需要更新对应目录下的 `meta.json`,以固定Fumadocs侧栏标题与页面顺序。
25
25
 
26
26
  ## API 参考文档格式规范
27
27
 
@@ -36,7 +36,14 @@ description: 文档贡献流程与格式规范(API 参考、教程、Markdown
36
36
 
37
37
  ### 方法(方法单列)
38
38
 
39
- - 每个方法一个三级标题:`### \`methodName\``。
39
+ - 每个方法一个三级标题,格式如下:
40
+ ```markdown
41
+ ### `methodName`
42
+ ```
43
+ 例如:
44
+ ```markdown
45
+ ### `getUser`
46
+ ```
40
47
  - 可选:标题下方一行简短说明。
41
48
  - **签名代码块**:使用 ` ```javascript `,内容为方法签名,例如 `static sharedInstance(): Application` 或 `count(): number`,然后 ` ``` `。
42
49
  - **Parameters**(若有参数):
@@ -56,6 +63,24 @@ description: 文档贡献流程与格式规范(API 参考、教程、Markdown
56
63
  - 二级标题:`## 类成员 (Class members)`、`## 实例成员 (Instance members)`。
57
64
  - 可按需用三级标题分组(如「创建」「查询」),再在其下按上述方法/属性格式书写。
58
65
 
66
+ ### 构造函数
67
+
68
+ 如有构造函数,需单独列出:
69
+
70
+ ````markdown
71
+ ## 构造函数
72
+
73
+ ```javascript
74
+ new ClassName(parameter: Type)
75
+ ```
76
+
77
+ 构造函数说明。
78
+
79
+ | 参数名 | 类型 | 说明 |
80
+ | :----- | :--- | :--- |
81
+ | `parameter` | `Type` | 参数说明 |
82
+ ````
83
+
59
84
  ### 相关链接
60
85
 
61
86
  页面末尾可使用 `## 相关` 列出与本页相关的其他 API 或教程链接(Markdown 链接,如 `[Application](/reference/global/application/)`)。
@@ -76,7 +101,7 @@ description: 文档贡献流程与格式规范(API 参考、教程、Markdown
76
101
  - **语言**:文档正文与说明统一使用**简体中文**;API 名称、代码、技术术语保留英文。
77
102
  - **标点**:中文句子使用中文标点;英文或代码片段内使用英文标点。
78
103
  - **专有名词**:MarginNote、API、JavaScript 等大小写保持一致;首次出现可加简短解释。
79
- - **链接**:避免裸 URL,使用 `[描述](url)` 或 `[描述](/path/)`;API 交叉引用建议用「相关」小节或正文内链接到对应 reference 页。
104
+ - **链接**:避免裸 URL,使用 `[描述](url)` 或 `[描述](/path/)`;API 交叉引用用「相关」小节或正文内链接到对应 reference 页。
80
105
  - **代码块**:标注语言、保持缩进一致;长示例可省略无关部分并用注释说明。
81
106
 
82
- 若对某条规范有疑问或建议,欢迎在 Issue 中提出。
107
+ 若对某条规范有疑问或改进意见,欢迎在 Issue 中提出。
@@ -40,7 +40,7 @@ NSUserDefaults.standardUserDefaults().setObjectForKey(newKey, "my_addon_api_key"
40
40
  Application.sharedInstance().showHUD("已保存", self.window, 2);
41
41
  ```
42
42
 
43
- 若需用该 Key 发起网络请求,可参考 [调用远程 API](/guides/cookbook/network-api-call/) 和 [网络请求](/guides/network-requests/)。保存后可选择调用简单 API 验证 Key 是否有效。
43
+ 若需用该 Key 发起网络请求,可参考 [调用远程 API](/cookbook/network-api-call/) 和 [网络请求](/guides/network-requests/)。保存后可选择调用简单 API 验证 Key 是否有效。
44
44
 
45
45
  **完整流程简述**:
46
46
 
@@ -50,4 +50,4 @@ Application.sharedInstance().showHUD("已保存", self.window, 2);
50
50
  4. 插件主逻辑(如是否显示面板)在需要时从 NSUserDefaults 读取。
51
51
  5. (可选)保存 API Key 后调用简单接口验证是否有效。
52
52
 
53
- **相关**:[存储与文件](/guides/storage-and-files/)、[NSUserDefaults](/reference/foundation/ns-user-defaults/)、[原生 UI](/guides/native-ui/)、[调用远程 API](/guides/cookbook/network-api-call/)
53
+ **相关**:[存储与文件](/guides/storage-and-files/)、[NSUserDefaults](/reference/foundation/ns-user-defaults/)、[原生 UI](/guides/native-ui/)、[调用远程 API](/cookbook/network-api-call/)
@@ -5,7 +5,7 @@ description: 从工具栏打开浮窗,浮窗内为 UIWebView,加载本地或
5
5
 
6
6
  **场景**:用户点击插件工具栏按钮后,在主界面上显示一个浮窗面板,面板内为 [UIWebView](/reference/uikit/uiwebview/),加载本地或内联 HTML;面板内可通过自定义 URL 触发插件逻辑(如 showHUD),插件也可通过 `evaluateJavaScript` 更新页面内容。
7
7
 
8
- **要点**:浮窗为自定义 ViewController 的 view,在入口中 `JSB.require` 该 ViewController **一次**,在 `sceneWillConnect` 中创建实例;在 ViewController 的 **viewWillAppear** 中设置 `webView.delegate = self`,在 **viewWillDisappear** 中 `webView.stopLoading()` 并 `webView.delegate = null`。加载 HTML 用 `loadHTMLStringBaseURL(html, null)`,加载失败时在 `webViewDidFailLoadWithError` 中用 `error.localizedDescription` 拼 HTML 后用 `loadHTMLStringBaseURL` 显示错误页。双向通信写法见 [WebView 内 JS 与插件 JS 双向通信](/guides/cookbook/webview-bidirectional-js/)。
8
+ **要点**:浮窗为自定义 ViewController 的 view,在入口中 `JSB.require` 该 ViewController **一次**,在 `sceneWillConnect` 中创建实例;在 ViewController 的 **viewWillAppear** 中设置 `webView.delegate = self`,在 **viewWillDisappear** 中 `webView.stopLoading()` 并 `webView.delegate = null`。加载 HTML 用 `loadHTMLStringBaseURL(html, null)`,加载失败时在 `webViewDidFailLoadWithError` 中用 `error.localizedDescription` 拼 HTML 后用 `loadHTMLStringBaseURL` 显示错误页。双向通信写法见 [WebView 内 JS 与插件 JS 双向通信](/cookbook/webview-bidirectional-js/)。
9
9
 
10
10
  下文给出与 Samples/UIKit/WebView 同构的完整代码:main.js 中挂面板与切换显示,MyWebViewController.js 中创建 WebView、生命周期与 delegate。
11
11
 
@@ -154,5 +154,5 @@ var MyWebViewController = JSB.defineClass('MyWebViewController : UIViewControlle
154
154
  ## 相关
155
155
 
156
156
  - [工具栏与命令](/guides/toolbar-and-commands/)、[原生 UI:使用 WebView](/guides/native-ui/#使用-webview)
157
- - [WebView 内 JS 与插件 JS 双向通信](/guides/cookbook/webview-bidirectional-js/)、[UIWebView](/reference/uikit/uiwebview/)
157
+ - [WebView 内 JS 与插件 JS 双向通信](/cookbook/webview-bidirectional-js/)、[UIWebView](/reference/uikit/uiwebview/)
158
158
  - [网络请求](/guides/network-requests/) —— 获取远程数据后注入 HTML 或通过 evaluateJavaScript 注入
@@ -0,0 +1,13 @@
1
+ {
2
+ "title": "Cookbook配方",
3
+ "pages": [
4
+ "batch-rename-notes",
5
+ "network-api-call",
6
+ "export-notebook",
7
+ "focus-note-in-mindmap",
8
+ "append-selection-as-comment",
9
+ "addon-settings",
10
+ "embed-webview-panel",
11
+ "webview-bidirectional-js"
12
+ ]
13
+ }
@@ -106,7 +106,7 @@ async function fetchWithAPIKey() {
106
106
  }
107
107
  ```
108
108
 
109
- API Key 的保存与读取见 [插件设置页](/guides/cookbook/addon-settings/)。保存后可选择调用简单 API 验证 Key 是否有效。
109
+ API Key 的保存与读取见 [插件设置页](/cookbook/addon-settings/)。保存后可选择调用简单 API 验证 Key 是否有效。
110
110
 
111
111
  ---
112
112
 
@@ -131,5 +131,5 @@ async function fetchPlainText() {
131
131
  ## 相关
132
132
 
133
133
  - [网络请求](/guides/network-requests/) —— Base64 与 MNNetwork 完整代码、data 转 JSON/文本说明
134
- - [插件设置页](/guides/cookbook/addon-settings/) —— 存储 API Key
134
+ - [插件设置页](/cookbook/addon-settings/) —— 存储 API Key
135
135
  - [笔记与数据库](/guides/notes-and-database/) —— 修改笔记与 Undo
@@ -109,4 +109,4 @@ self.webView.evaluateJavaScript("document.getElementById('text').innerText = '
109
109
  ## 相关
110
110
 
111
111
  - [UIWebView](/reference/uikit/uiwebview/)、[原生 UI:使用 WebView](/guides/native-ui/#使用-webview)
112
- - [Cookbook:在插件中嵌入 WebView 面板](/guides/cookbook/embed-webview-panel/)
112
+ - [Cookbook:在插件中嵌入 WebView 面板](/cookbook/embed-webview-panel/)
@@ -7,7 +7,7 @@ description: 从零运行你的第一个 MarginNote 插件(Hello World)。
7
7
 
8
8
  ## 前提
9
9
 
10
- - 已安装 MarginNote 3 或 MarginNote 4(MN3 建议 3.6.11 及以上)。
10
+ - 已安装 MarginNote 3 或 MarginNote 4(MN3使用 3.6.11 及以上)。
11
11
  - 了解如何将 .mnaddon 包安装到 MarginNote 并在应用中启用插件。
12
12
 
13
13
  ## 第一步:插件包结构
@@ -32,7 +32,7 @@ description: 从零运行你的第一个 MarginNote 插件(Hello World)。
32
32
  }
33
33
  ```
34
34
 
35
- - `addonid`:唯一 ID,建议用反向域名。
35
+ - `addonid`:唯一 ID,用反向域名。
36
36
  - `title`:在 MarginNote 中显示的插件名称。
37
37
  - `marginnote_version_min`:最低支持的 MarginNote 版本。
38
38
 
@@ -11,7 +11,7 @@ description: 理解 scene/notebook/document 生命周期及何时可安全使用
11
11
 
12
12
  | 方法 | 调用时机 |
13
13
  |------|----------|
14
- | `sceneWillConnect()` | 插件窗口即将创建,可在此做轻量初始化;此时可能还没有打开笔记本。 |
14
+ | `sceneWillConnect()` | 插件窗口即将创建,可在此做轻量初始化;此时会还没有打开笔记本。 |
15
15
  | `sceneDidDisconnect()` | 插件窗口已断开。 |
16
16
  | `sceneWillResignActive()` | 窗口即将失去活跃。 |
17
17
  | `sceneDidBecomeActive()` | 窗口变为活跃。 |
@@ -33,8 +33,8 @@ description: 理解 scene/notebook/document 生命周期及何时可安全使用
33
33
  ## 何时可使用 studyController
34
34
 
35
35
  - `studyController(window)` 返回的是**当前窗口**的学习控制器;只有在该窗口已经打开过笔记本、学习界面已就绪时,返回值才可用。
36
- - 在 `sceneWillConnect` 中通常**还没有**打开笔记本,因此一般不要在这里依赖 `studyController(self.window)` 去访问脑图或文档。
37
- - 在 `notebookWillOpen(topicid)` 被调用后,该窗口即将或已经拥有学习界面;但若需在「打开笔记本」后立刻挂载 UI,建议用 `NSTimer.scheduledTimerWithTimeInterval(0.2, false, function () { ... })` 延迟约 0.2 秒再执行,以确保 studyController 与 view 已就绪。
36
+ - 在 `sceneWillConnect` 中默认**还没有**打开笔记本,因此直接不要在这里依赖 `studyController(self.window)` 去访问脑图或文档。
37
+ - 在 `notebookWillOpen(topicid)` 被调用后,该窗口即将或已经拥有学习界面;但若需在「打开笔记本」后立刻挂载 UI,用 `NSTimer.scheduledTimerWithTimeInterval(0.2, false, function () { ... })` 延迟约 0.2 秒再执行,以确保 studyController 与 view 已就绪。
38
38
 
39
39
  ## 示例:在笔记本打开时打日志并延迟挂载 UI
40
40
 
@@ -59,7 +59,7 @@ notebookWillOpen: function (topicid) {
59
59
 
60
60
  ## 布局回调:controllerWillLayoutSubviews
61
61
 
62
- 若你在学习界面上添加了自定义视图,窗口尺寸或布局变化时可能需要重新计算位置。实现 `controllerWillLayoutSubviews(controller)`,当传入的 controller 是当前窗口的 studyController 时,在其中更新你的面板 frame(例如根据 `controller.view.bounds` 计算)。
62
+ 若你在学习界面上添加了自定义视图,窗口尺寸或布局变化时会需要重新计算位置。实现 `controllerWillLayoutSubviews(controller)`,当传入的 controller 是当前窗口的 studyController 时,在其中更新你的面板 frame(例如根据 `controller.view.bounds` 计算)。
63
63
 
64
64
  ```javascript
65
65
  controllerWillLayoutSubviews: function (controller) {
@@ -0,0 +1,14 @@
1
+ {
2
+ "title": "教程",
3
+ "pages": [
4
+ "getting-started",
5
+ "lifecycle-and-window",
6
+ "notes-and-database",
7
+ "mindmap-and-selection",
8
+ "toolbar-and-commands",
9
+ "shortcut-keys",
10
+ "native-ui",
11
+ "storage-and-files",
12
+ "network-requests"
13
+ ]
14
+ }
@@ -29,7 +29,7 @@ var document = docController.document; // MbBook
29
29
  var selectionText = docController.selectionText; // 用户选中的文本
30
30
  ```
31
31
 
32
- 若用户未选中任何内容,`selectionText` 可能为 undefined 或空字符串。
32
+ 若用户未选中任何内容,`selectionText` undefined 或空字符串。
33
33
 
34
34
  ## 在脑图中高亮指定笔记
35
35
 
@@ -73,4 +73,4 @@ if (focusNote && text && text.length > 0) {
73
73
  ## 相关
74
74
 
75
75
  - [StudyController](/reference/marginnote/study-controller/)、[NotebookController](/reference/marginnote/notebook-controller/)、[DocumentController](/reference/marginnote/document-controller/)
76
- - [Cookbook:将选区追加为评论](/guides/cookbook/append-selection-as-comment/)、[在脑图中高亮指定笔记](/guides/cookbook/focus-note-in-mindmap/)
76
+ - [Cookbook:将选区追加为评论](/cookbook/append-selection-as-comment/)、[在脑图中高亮指定笔记](/cookbook/focus-note-in-mindmap/)
@@ -88,12 +88,12 @@ self.webView.loadRequest(NSURLRequest.requestWithURL(NSURL.URLWithString("http:/
88
88
 
89
89
  ```javascript
90
90
  var html = "<html><body><h1>Hello</h1></body></html>";
91
- self.webView.loadHTMLStringBaseURL(html, null); // 以示例为准,JS 中方法名为 loadHTMLStringBaseURL(string, baseURL);若环境不同则可能为 loadHTMLString
91
+ self.webView.loadHTMLStringBaseURL(html, null); // JS 中方法名为 loadHTMLStringBaseURL(string, baseURL)
92
92
  ```
93
93
 
94
94
  ### Delegate 回调(实例成员)
95
95
 
96
- 建议在 **viewWillAppear** 中设置 `self.webView.delegate = self`(确保每次显示时 delegate 有效),在 **viewWillDisappear** 中调用 `self.webView.stopLoading()` 并设置 `self.webView.delegate = null`,避免视图消失后仍收到回调。
96
+ **viewWillAppear** 中设置 `self.webView.delegate = self`(确保每次显示时 delegate 有效),在 **viewWillDisappear** 中调用 `self.webView.stopLoading()` 并设置 `self.webView.delegate = null`,避免视图消失后仍收到回调。
97
97
 
98
98
  在 `JSB.defineClass` 的第二个参数中定义:
99
99
 
@@ -122,7 +122,7 @@ self.webView.evaluateJavaScript("document.title", function (result) {
122
122
  });
123
123
  ```
124
124
 
125
- WebView 内 JS 与插件 JS 的双向通信(自定义 URL Scheme 拦截 + evaluateJavaScript)见 [Cookbook:WebView 内 JS 与插件 JS 双向通信](/guides/cookbook/webview-bidirectional-js/)。
125
+ WebView 内 JS 与插件 JS 的双向通信(自定义 URL Scheme 拦截 + evaluateJavaScript)见 [Cookbook:WebView 内 JS 与插件 JS 双向通信](/cookbook/webview-bidirectional-js/)。
126
126
 
127
127
  ## 布局与圆角
128
128
 
@@ -133,4 +133,4 @@ WebView 内 JS 与插件 JS 的双向通信(自定义 URL Scheme 拦截 + eval
133
133
 
134
134
  - [UIView](/reference/uikit/uiview/)、[UIButton](/reference/uikit/uibutton/)、[UIAlertView](/reference/uikit/uialertview/)、[UIWebView](/reference/uikit/uiwebview/)、[UIColor](/reference/uikit/uicolor/)
135
135
  - [工具栏与命令](/guides/toolbar-and-commands/) — 将面板与工具栏按钮联动
136
- - [Cookbook:WebView 内 JS 与插件 JS 双向通信](/guides/cookbook/webview-bidirectional-js/)
136
+ - [Cookbook:WebView 内 JS 与插件 JS 双向通信](/cookbook/webview-bidirectional-js/)
@@ -9,7 +9,7 @@ description: 使用 NSURLConnection 发起 HTTP 请求;含 Base64 解码与 Re
9
9
 
10
10
  - **读 data**:异步回调形参为 `(response, data, error)`。响应体在 **data**(NSData)里,处理结果以 data 为主;`response` 用于取 `statusCode()`,`error` 用于判断失败,不必用到所有参数。
11
11
  - **data → JSON**:直接对 **NSData** 调用 `NSJSONSerialization.JSONObjectWithDataOptions(data, 0 或 1)`,得到 JS 对象;**不要**先转成字符串再 `JSON.parse`。
12
- - **data → 纯文本**:环境中无现成「NSData → 字符串」API 时,用 `data.base64Encoding()` 得到 base64 字符串,再用 **Base64 解码**得到 JS 字符串。运行时不提供 Base64 解码,需在插件内实现(见下一节完整代码)。
12
+ - **data → 纯文本**:环境中无「NSData → 字符串」API ,用 `data.base64Encoding()` 得到 base64 字符串,再用 **Base64 解码**得到 JS 字符串。插件环境不提供 Base64 解码,需在插件内实现(见下一节完整代码)。
13
13
 
14
14
  ---
15
15
 
@@ -140,7 +140,7 @@ class MNNetwork {
140
140
  NSOperationQueue.mainQueue(),
141
141
  function (res, data, err) {
142
142
  if (!MNNetwork.isNil(err)) {
143
- reject(err.localizedDescription ? err.localizedDescription() : "Network Error");
143
+ reject(err.localizedDescription);
144
144
  } else {
145
145
  var response = new Response(data, res);
146
146
  resolve(response);
@@ -156,7 +156,7 @@ class MNNetwork {
156
156
 
157
157
  - `Response#text()`:用 `data.base64Encoding()` 得到 base64 串,再 `Base64.decode(encoding)` 得到 JS 字符串;环境无 Base64 解码,故依赖上面的 `base64.js`。
158
158
  - `Response#json()`:直接对 **NSData** 调用 `NSJSONSerialization.JSONObjectWithDataOptions(this.data, 1)`,不经过 base64 或字符串。
159
- - 错误信息:`error.localizedDescription` 在部分运行时为方法,需 `error.localizedDescription()`,封装里已按「有则调用」处理。
159
+ - 错误信息:`error.localizedDescription` 为方法,需 `error.localizedDescription`,封装里已按「有则调用」处理。
160
160
 
161
161
  ---
162
162
 
@@ -231,9 +231,8 @@ async function fetchWithAuth() {
231
231
 
232
232
  - **回调**:`NSURLConnection.sendAsynchronousRequestQueueCompletionHandler(request, NSOperationQueue.mainQueue(), function (response, data, error) { ... })`。有用的是 **data**(响应体)、可选的 `response.statusCode()`、以及 **error**(失败时)。
233
233
  - **JSON**:直接对 **data**(NSData)解析,不要先转字符串再 `JSON.parse`:
234
- - `var obj = NSJSONSerialization.JSONObjectWithDataOptions(data, 0);` 或选项 `1`(若运行时支持)。
234
+ - `var obj = NSJSONSerialization.JSONObjectWithDataOptions(data, 0);` 或选项 `1`(环境支持)。
235
235
  - **纯文本**:无 Base64 解码时无法从 NSData 得到字符串;必须先按上文提供 `base64.js`,再 `var str = Base64.decode(data.base64Encoding());`。
236
- - **错误**:`error.localizedDescription` 可能是属性或方法,建议统一写成:`var msg = (typeof error.localizedDescription === "function" ? error.localizedDescription() : error.localizedDescription) || "未知错误";`。
237
236
 
238
237
  **原始 GET + JSON 示例**:
239
238
 
@@ -246,7 +245,7 @@ NSURLConnection.sendAsynchronousRequestQueueCompletionHandler(
246
245
  NSOperationQueue.mainQueue(),
247
246
  function (response, data, error) {
248
247
  if (error) {
249
- var msg = (typeof error.localizedDescription === "function" ? error.localizedDescription() : error.localizedDescription) || "未知错误";
248
+ var msg = error.localizedDescription;
250
249
  Application.sharedInstance().alert("请求失败: " + msg);
251
250
  return;
252
251
  }
@@ -278,7 +277,7 @@ NSURLConnection.sendAsynchronousRequestQueueCompletionHandler(
278
277
  NSOperationQueue.mainQueue(),
279
278
  function (response, data, error) {
280
279
  if (error) {
281
- var msg = (typeof error.localizedDescription === "function" ? error.localizedDescription() : error.localizedDescription) || "未知错误";
280
+ var msg = error.localizedDescription;
282
281
  Application.sharedInstance().alert("请求失败: " + msg);
283
282
  return;
284
283
  }
@@ -298,12 +297,12 @@ NSURLConnection.sendAsynchronousRequestQueueCompletionHandler(
298
297
  | 响应体 | 使用回调中的 **data**(NSData),不必依赖 response 的其他字段 |
299
298
  | data → JSON | `NSJSONSerialization.JSONObjectWithDataOptions(data, 0)` 或 `1`,直接对 data |
300
299
  | data → 纯文本 | `data.base64Encoding()` 得到 base64 串,再 **Base64.decode**(需自备 base64.js) |
301
- | 错误信息 | `error.localizedDescription` 或 `error.localizedDescription()`,依运行时而定 |
300
+ | 错误信息 | `error.localizedDescription` |
302
301
 
303
302
  推荐在插件内包含完整的 `base64.js` 与 `network.js`(如上),先 `JSB.require('base64')` 再 `JSB.require('network')`,然后用 `MNNetwork.fetch` 发起请求,在 try/catch 中用 `res.json()` 或 `res.text()` 处理 JSON 与纯文本。
304
303
 
305
304
  ## 相关
306
305
 
307
- - [Cookbook:调用远程 API](/guides/cookbook/network-api-call/) —— 将 API 结果展示或写入笔记
306
+ - [Cookbook:调用远程 API](/cookbook/network-api-call/) —— 将 API 结果展示或写入笔记
308
307
  - [JavaScript 原生环境](/reference/js-runtime/) —— 为何没有 fetch
309
308
  - [NSURLConnection](/reference/foundation/ns-url-connection/)、[NSMutableURLRequest](/reference/foundation/ns-mutable-url-request/)
@@ -47,7 +47,7 @@ if (note) {
47
47
 
48
48
  ## 创建新笔记
49
49
 
50
- 使用全局 `Note` 对象创建新笔记:`Note.createWithTitleNotebookDocument(title, notebook, doc)`(`notebook` 为 `MbTopic`,`doc` 为 `MbBook`)。创建后同样建议放在 undoGrouping 中并刷新。
50
+ 使用全局 `Note` 对象创建新笔记:`Note.createWithTitleNotebookDocument(title, notebook, doc)`(`notebook` 为 `MbTopic`,`doc` 为 `MbBook`)。创建后同样放在 undoGrouping 中并刷新。
51
51
 
52
52
  ```javascript
53
53
  var db = Database.sharedInstance();
@@ -96,4 +96,4 @@ if (note) {
96
96
  ## 相关
97
97
 
98
98
  - [Database](/reference/global/database/)、[MbBookNote](/reference/marginnote/mb-book-note/)、[UndoManager](/reference/utility/undo-manager/)
99
- - [Cookbook:批量修改笔记标题](/guides/cookbook/batch-rename-notes/)
99
+ - [Cookbook:批量修改笔记标题](/cookbook/batch-rename-notes/)
@@ -5,7 +5,7 @@ description: 在JSExtension中注册快捷键,并用query/process稳定处理
5
5
 
6
6
  MarginNote插件提供了一套“扩展快捷键”机制:你可以在插件主类(继承`JSExtension`)中实现`additionalShortcutKeys()`返回快捷键声明,然后用`queryShortcutKeyWithKeyFlags(command,keyFlags)`与`processShortcutKeyWithKeyFlags(command,keyFlags)`完成“可用性判断”和“按下处理”。
7
7
 
8
- 本页按标准教程结构介绍该机制:接口作用、注册方式、推荐实现范式、参数语义、组合键选择建议与常见坑。
8
+ 本页按标准教程结构介绍该机制:接口作用、注册方式、推荐实现范式、参数语义、组合键选择规范与常见问题。
9
9
 
10
10
  ## 概述
11
11
 
@@ -16,8 +16,8 @@ MarginNote插件提供了一套“扩展快捷键”机制:你可以在插件
16
16
 
17
17
  边界与限制:
18
18
 
19
- - 当用户正在编辑文本时(firstResponder在输入框/编辑器上),按键可能被输入控件优先消费,插件快捷键不一定触发。这是预期行为。
20
- - 组合键可能与系统或应用内建快捷键冲突,导致命中率不稳定;应优先选择冲突更少的组合键,并允许用户自定义(如你的插件有设置页)。
19
+ - 当用户正在编辑文本时(firstResponder在输入框/编辑器上),按键会被输入控件优先消费,插件快捷键不会稳定触发。这是预期行为。
20
+ - 组合键会与系统或应用内建快捷键冲突,导致命中率不稳定;应优先选择冲突更少的组合键,并允许用户自定义(如你的插件有设置页)。
21
21
 
22
22
  ## 接口一览
23
23
 
@@ -57,8 +57,8 @@ additionalShortcutKeys: function () {
57
57
 
58
58
  这两者的职责必须严格区分:
59
59
 
60
- - `queryShortcutKeyWithKeyFlags(...)`用于“查询状态”。系统可能会在可用性判断、快捷键列表重建、焦点变化等场景批量调用它,因此调用次数与传入参数都可能远超你的预期。为了保证性能与行为可控,建议在query中只做轻量判断并返回状态:避免任何IO操作、耗时计算、网络请求、文件读写,以及无差别日志输出;更不要在这里修改笔记/数据库或触发UI。
61
- - `processShortcutKeyWithKeyFlags(...)`用于“处理按下”。真正的业务动作应放在这里;如果会修改笔记/笔记本数据,建议使用`UndoManager.undoGrouping(...)`包裹,保证撤销/重做稳定。
60
+ - `queryShortcutKeyWithKeyFlags(...)`用于“查询状态”。系统会在可用性判断、快捷键列表重建、焦点变化等场景批量调用它,因此调用次数与传入参数都会远超你的预期。为了保证性能与行为可控,在query中只做轻量判断并返回状态:避免任何IO操作、耗时计算、网络请求、文件读写,以及无差别日志输出;更不要在这里修改笔记/数据库或触发UI。
61
+ - `processShortcutKeyWithKeyFlags(...)`用于“处理按下”。真正的业务动作应放在这里;如果会修改笔记/笔记本数据,使用`UndoManager.undoGrouping(...)`包裹,保证撤销/重做稳定。
62
62
 
63
63
  推荐写法:只匹配你关心的组合键,其余保持静默(例如直接`return null`)。
64
64
 
@@ -66,7 +66,7 @@ additionalShortcutKeys: function () {
66
66
 
67
67
  ### command
68
68
 
69
- `command`是系统传入的标识。已确认它可能是:
69
+ `command`是系统传入的标识。已确认它是:
70
70
 
71
71
  - 内建命令名:例如`NewChildNote`、`ToggleExpand`、`EditAddTitle`等。
72
72
  - 输入常量/字符:例如`UIKeyInputLeftArrow`、`UIKeyInputUpArrow`,以及`z`这类字符输入。
@@ -86,16 +86,16 @@ additionalShortcutKeys: function () {
86
86
  | Command+Shift | `1179648` |
87
87
 
88
88
 
89
- ## 组合键选择建议
89
+ ## 组合键选择规范
90
90
 
91
91
  - 优先选择不常被系统/应用占用的组合键。
92
92
  - 避免与“通用编辑快捷键”冲突(例如撤销/重做/复制粘贴等),除非你非常确定不会影响用户习惯。
93
- - 若某个组合键命中率不稳定,通常是冲突或编辑态吞键导致;建议提供替代键位或设置项。
93
+ - 若某个组合键命中率不稳定,默认是冲突或编辑态吞键导致;提供替代键位或设置项。
94
94
 
95
95
  ## 注意事项
96
96
 
97
97
  - 在query里做副作用:导致“未按下也触发动作”、撤销链异常、或出现难以定位的状态错乱。
98
- - 无差别打印日志:query可能被批量调用,导致刷屏,反而遮蔽真正有用的命中日志。
98
+ - 无差别打印日志:query会被批量调用,导致刷屏,反而遮蔽真正有用的命中日志。
99
99
  - 忽略编辑态:用户在输入时快捷键不触发属于预期,需要在产品交互上规避或提示。
100
100
 
101
101
  ## 相关
@@ -23,7 +23,7 @@ var counter = defaults.integerForKey("my_addon_counter");
23
23
  var on = defaults.boolForKey("my_addon_switch");
24
24
  ```
25
25
 
26
- 键名建议加插件前缀,避免与其他插件冲突。
26
+ 键名加插件前缀,避免与其他插件冲突。
27
27
 
28
28
  ## NSFileManager:目录与文件
29
29
 
@@ -50,7 +50,7 @@ textData.writeToFileAtomically(filePath, true);
50
50
  读取文件为 NSData 后,若需转为 JS 可用的形式:
51
51
 
52
52
  - **若文件为 JSON**:用 `NSJSONSerialization.JSONObjectWithDataOptions(data, 0)` 解析为对象/数组;解析前可用 `data.length() === 0` 判断是否为空。
53
- - **若需纯文本字符串**:若运行时导出了 `NSString`,可用 `NSString.alloc().initWithDataEncoding(data, 4)`(4 UTF-8)再取字符串;若无 NSString,可先尝试上述 JSON 解析。
53
+ - **若需纯文本字符串**:使用 `NSString.stringWithContentsOfData(data)` `NSData` 转为字符串。
54
54
 
55
55
  示例:从文件读取 JSON 并解析
56
56
 
@@ -67,7 +67,7 @@ if (data && data.length() > 0) {
67
67
  ## 路径说明
68
68
 
69
69
  - `Application.sharedInstance().documentPath`:文稿目录,适合存放用户数据。
70
- - `Application.sharedInstance().tempPath`:临时目录,系统可能清理。
70
+ - `Application.sharedInstance().tempPath`:临时目录,系统会清理。
71
71
  - 插件包根路径由 `JSB.newAddon(mainPath)` 的 `mainPath` 传入,可用于读取包内资源(如图标)。
72
72
 
73
73
  ## 完整示例:保存与读取一个开关
@@ -87,5 +87,5 @@ NSUserDefaults.standardUserDefaults().setBoolForKey(newValue, "my_addon_show_pan
87
87
  ## 相关
88
88
 
89
89
  - [NSUserDefaults](/reference/foundation/ns-user-defaults/)、[NSFileManager](/reference/foundation/ns-file-manager/)、[NSData](/reference/foundation/ns-data/)
90
- - [Cookbook:插件设置页](/guides/cookbook/addon-settings/)
90
+ - [Cookbook:插件设置页](/cookbook/addon-settings/)
91
91
  - [网络请求](/guides/network-requests/) —— 网络响应 NSData 的 JSON 解析同理
@@ -12,7 +12,7 @@ MarginNote 会调用插件的 `queryAddonCommandStatus()`。若希望显示工
12
12
  | 字段 | 类型 | 说明 |
13
13
  |------|------|------|
14
14
  | `image` | string | 图标文件名(相对于插件包根目录,如 `'sample.png'`)。 |
15
- | `object` | object | 接收点击的对象,通常为 `self`(插件实例)。 |
15
+ | `object` | object | 接收点击的对象,为 `self`(插件实例)。 |
16
16
  | `selector` | string | 点击时调用的方法名,**必须以冒号结尾**(如 `'toggleSample:'`)。 |
17
17
  | `checked` | boolean | 是否显示为「选中」状态(如面板是否已显示)。 |
18
18
 
@@ -1,44 +1,19 @@
1
1
  ---
2
2
  title: MarginNote 插件开发文档
3
- description: MarginNote 插件开发的完整 API 参考与渐进式教程(含 Cookbook 配方)。
4
- template: splash
5
- hero:
6
- tagline: 为 MarginNote 编写插件的官方/社区参考文档
7
- image:
8
- file: ../../assets/houston.webp
9
- actions:
10
- - text: 快速开始
11
- link: /guides/getting-started/
12
- icon: right-arrow
13
- - text: API 参考
14
- link: /reference/global/jsb/
15
- icon: document
16
- variant: minimal
3
+ description: MarginNote 插件开发的完整 API 参考与渐进式教程。
17
4
  ---
18
5
 
19
- import { Card, CardGrid } from '@astrojs/starlight/components';
6
+ import { Card, Cards } from 'fumadocs-ui/components/card';
20
7
 
21
- ## 从这里开始
8
+ # MarginNote 插件开发文档
22
9
 
23
- <CardGrid stagger>
24
- <Card title="快速开始" icon="rocket">
25
- 从零运行你的第一个插件(Hello World),了解 mnaddon.json 与入口函数。
26
- [进入快速开始](/guides/getting-started/)
27
- </Card>
28
- <Card title="教程" icon="pencil">
29
- 按学习路径掌握生命周期、笔记与数据库、脑图与选区、工具栏与原生 UI。
30
- [浏览教程](/guides/lifecycle-and-window/)
31
- </Card>
32
- <Card title="Cookbook 配方" icon="add-document">
33
- 按任务查找完整可运行代码:批量改标题、导出笔记本、高亮笔记、设置页等。
34
- [查看配方](/guides/cookbook/batch-rename-notes/)
35
- </Card>
36
- <Card title="API 参考" icon="open-book">
37
- 全局对象、MarginNote 核心、Foundation、UIKit、Utility 的完整 API 说明。
38
- [进入 API](/reference/global/jsb/)
39
- </Card>
40
- <Card title="贡献指南" icon="heart">
41
- 参与文档改进:贡献流程、API 参考与教程的格式规范、Markdown 约定等。
42
- [查看贡献指南](/guides/contributing/)
43
- </Card>
44
- </CardGrid>
10
+ MarginNote 编写插件的 API 参考、渐进式教程与 Cookbook 配方。
11
+
12
+ <Cards>
13
+ <Card title="快速开始" href="/guides/getting-started/" description="从零运行你的第一个插件,了解开发流程。" />
14
+ <Card title="教程" href="/guides/lifecycle-and-window/" description="按学习路径掌握生命周期、笔记与数据库等核心概念。" />
15
+ <Card title="Cookbook" href="/cookbook/batch-rename-notes/" description="按任务查找完整可运行代码。" />
16
+ <Card title="API 参考" href="/reference/global/jsb/" description="全局对象与核心 API 的完整说明。" />
17
+ <Card title="LibMN" href="/libmn/" description="LibMN 运行时与插件开发核心模块。" />
18
+ <Card title="贡献指南" href="/contributing/" description="参与文档改进,了解格式规范。" />
19
+ </Cards>