MNUtil
MNUtil是提供核心工具函数的对象,包含插件开发常用的上下文读取、学习集查询、文件操作、URL处理、HUD提示与异步交互等能力。
类成员(Class members)
Section titled “类成员(Class members)”| 成员 | 类型 | 说明 |
|---|---|---|
onAlert | boolean | 弹窗流程状态位,用于判断是否处于弹窗中。 |
themeColor | {Gray:UIColor,Default:UIColor,Dark:UIColor,Green:UIColor,Sepia:UIColor} | 内置主题色映射表,按主题名取UIColor。 |
imageTypeCache | Record<string,string> | 图片类型缓存,减少重复识别。 |
popUpNoteInfo | {noteId:string}|undefined | 弹出卡片上下文,常用字段是noteId。 |
popUpSelectionInfo | {docController:DocumentController}|undefined | 弹出选区上下文,包含docController。 |
initialized | boolean | 初始化状态位。 |
dataFolder | string | 插件数据目录路径。 |
MNImagePattern | RegExp | 图片标记匹配规则。 |
defaultNoteColors | string[] | 默认卡片颜色列表。 |
focusHistory | Array<{ type: string; time: number; noteId?: string; text?: string; imageData?: NSData; notebookId?: string; docMd5?: string; pageIndex?: number }> | 最近聚焦记录列表。 |
errorLog | `Array<{ source?: string; time: string; error: string | { message: string; detail?: string }; info?: object |
version | { version: 'marginnote4'|'marginnote3'; versionNumber: number; type: 'iPadOS'|'iPhoneOS'|'macOS' }|undefined | 当前MarginNote版本信息。 |
app | Application | Application单例。 |
db | Database | 数据库访问入口。 |
currentWindow | UIWindow | 当前活动窗口。 |
windowWidth | number | 当前窗口宽度。 |
windowHeight | number | 当前窗口高度。 |
studyController | StudyController | 当前学习控制器。 |
studyView | UIView | 当前学习视图。 |
studyWidth | number | 学习区域宽度。 |
studyRight | number | 学习区域右边界。 |
studyHeight | number | 学习区域高度。 |
isLeftSidebarOpen | boolean | 左侧栏是否打开。 |
leftSidebarWidth | number | 左侧栏宽度。 |
isFixedRightSidebarOpen | boolean | 固定右侧栏是否打开。 |
fixedRightSidebarWidth | number | 固定右侧栏宽度。 |
fixedRightSidebar | UIView|undefined | 固定右侧栏视图。 |
isFloatRightSidebarOpen | boolean | 浮动右侧栏是否打开。 |
floatRightSidebar | UIView|undefined | 浮动右侧栏视图。 |
floatRightSidebarPosition | 'left'|'right'|undefined | 浮动右侧栏位置。 |
floatRightSidebarWidth | number | 浮动右侧栏宽度。 |
isVertical | boolean | 当前是否竖向分栏。 |
isHorizontal | boolean | 当前是否横向分栏。 |
orientation | 'vertical'|'horizontal' | 当前布局方向。 |
extensionPanelController | { view: UIView }|undefined | 扩展面板控制器。 |
extensionPanelView | UIView|undefined | 扩展面板视图。 |
extensionPanelOn | boolean | 扩展面板是否开启。 |
mainPath | string | 插件主目录路径。 |
studyMode | number | 当前学习模式。 |
readerController | ReaderController | 当前阅读控制器。 |
notebookController | NotebookController | 当前学习集控制器。 |
docControllers | DocumentController[] | 当前文档控制器列表。 |
currentDocController | DocumentController | 当前文档控制器。 |
mindmapView | MindMapView | 当前脑图视图。 |
selectionText | string|undefined | 当前选中文本。 |
isSelectionText | boolean | 当前是否选中文本。 |
activeTextView | UITextView|undefined | 当前活跃文本视图。 |
selectionRefreshTime | number | 选区缓存刷新时间。 |
_currentSelection | {onSelection:boolean,image?:NSData,text?:string,isText?:boolean,docMd5?:string,pageIndex?:number,source?:string,docController?:DocumentController} | 内部选区缓存。 |
currentSelection | {onSelection:boolean,image?:NSData,text?:string,isText?:boolean,docMd5?:string,pageIndex?:number,source?:string} | 统一选区对象,含文本或图片信息。 |
currentNotebookId | string | 当前学习集id。 |
currentNotebook | MbTopic|undefined | 当前学习集对象。 |
currentNotebookFlags | number | 当前学习集标记。 |
currentNotebookType | 'Hiden'|'Doc'|'MindMap'|'FlashCard'|'Unknown' | 当前学习集类型。 |
currentNotebookController | NotebookController | 当前学习集控制器对象。 |
currentNotebookExcerptColor | string[] | 当前学习集摘录颜色。 |
currentDoc | MbBook | 当前文档对象。 |
currentDocmd5 | string|undefined | 当前文档md5旧命名。 |
currentDocMd5 | string|undefined | 当前文档md5。 |
isZH | boolean | 当前语言是否中文。 |
currentTheme | 'Default'|'Dark'|'Light'|'Gray'|'Green'|'Sepia' | 当前主题名。 |
currentThemeColor | UIColor | 当前主题颜色。 |
clipboardText | string | 剪贴板文本。 |
clipboardImage | UIImage|undefined | 剪贴板图片对象。 |
clipboardImageData | NSData|undefined | 剪贴板图片数据。 |
dbFolder | string | 数据库目录路径。 |
cacheFolder | string | 缓存目录路径。 |
documentFolder | string | 文档目录路径。 |
tempFolder | string | 临时目录路径。 |
splitLine | number|undefined | 分隔线文本。 |
_appVersion | { version: 'marginnote4'|'marginnote3'; versionNumber: number; type: 'iPadOS'|'iPhoneOS'|'macOS' }|undefined | 内部缓存的版本号。 |
cancelString | string | 取消按钮文案。 |
confirmString | string | 确认按钮文案。 |
static init(mainPath: string): void初始化MNUtil运行环境并记录主路径。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
mainPath | string | 是 | 插件主目录路径。 |
- 类型:
void - 语义:无返回值。
checkDataDir
Section titled “checkDataDir”static checkDataDir(): void检查并准备数据目录。
无。
- 类型:
void - 语义:无返回值。
addHistory
Section titled “addHistory”static addHistory(type: string, detail: { noteId?: string; text?: string; imageData?: NSData; notebookId?: string; docMd5?: string; pageIndex?: number }): void写入一次聚焦历史记录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | string | 是 | 历史记录类型。 |
detail | { noteId?: string; text?: string; imageData?: NSData; notebookId?: string; docMd5?: string; pageIndex?: number } | 是 | 历史记录详情。 |
- 类型:
void - 语义:无返回值。
addErrorLog
Section titled “addErrorLog”static addErrorLog(error: string|{ message: string; detail?: string }, source: string, info?: object|string): void写入一条错误日志。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | string|{ message: string; detail?: string } | 是 | 错误信息或错误对象。 |
source | string | 是 | 错误来源。 |
info | object|string | 否 | 附加信息。 |
- 类型:
void - 语义:无返回值。
customBtoa
Section titled “customBtoa”static customBtoa(str: string): string把字符串做Base64编码。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要编码的字符串。 |
- 类型:
string - 语义:返回Base64编码后的字符串。
utf8_to_b64
Section titled “utf8_to_b64”static utf8_to_b64(str: string): stringUTF-8字符串转Base64。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要编码的UTF-8字符串。 |
- 类型:
string - 语义:返回Base64编码后的字符串。
customAtob
Section titled “customAtob”static customAtob(input: string): string把Base64解码成字符串。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
input | string | 是 | 要解码的Base64字符串。 |
- 类型:
string - 语义:返回解码后的字符串。
b64_to_utf8
Section titled “b64_to_utf8”static b64_to_utf8(str: string): stringBase64转UTF-8字符串。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要解码的Base64字符串。 |
- 类型:
string - 语义:返回解码后的UTF-8字符串。
static btoa(str: string): string字符串转Base64。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要编码的字符串。 |
- 类型:
string - 语义:返回Base64编码后的字符串。
compressAndEncode
Section titled “compressAndEncode”static compressAndEncode(jsonObj: object, type?: 'pako'|'lz-string'): string|undefined压缩JSON并输出可传输字符串。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonObj | object | 是 | 要压缩的JSON对象。 |
type | `‘pako' | 'lz-string’` | 否 |
- 类型:
string|undefined - 语义:返回压缩后的字符串,失败时返回undefined。
decodeAndDecompress
Section titled “decodeAndDecompress”static decodeAndDecompress(base64: string, type?: 'pako'|'lz-string'): string|undefined还原压缩字符串。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
base64 | string | 是 | 要解压的Base64字符串。 |
type | `‘pako' | 'lz-string’` | 否 |
- 类型:
string|undefined - 语义:返回解压后的字符串,失败时返回undefined。
static atob(str: string): stringBase64转字符串。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要解码的Base64字符串。 |
- 类型:
string - 语义:返回解码后的字符串。
generateURLScheme
Section titled “generateURLScheme”static generateURLScheme(scheme: string, host?: string, path?: string|string[], query?: Record<string,string|number|boolean|object>, fragment?: string): string按组件拼装URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
scheme | string | 是 | URL协议。 |
host | string | 否 | URL主机。 |
path | `string | string[]` | 否 |
query | `Record<string,string | number | boolean |
fragment | string | 否 | URL片段。 |
- 类型:
string - 语义:返回拼装后的目标URL字符串。
parseMNUIStatusURL
Section titled “parseMNUIStatusURL”static parseMNUIStatusURL(encodedURL: string): object|string|null|undefined解析MNUI状态URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
encodedURL | string | 是 | 要解析的MNUI状态URL。 |
- 类型:
object|string|null|undefined - 语义:返回解析后的状态对象,失败时返回null或undefined。
generateMNUIStatusURL
Section titled “generateMNUIStatusURL”static generateMNUIStatusURL(jsonObj: object): string|null把状态对象转成MNUI状态URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonObj | object | 是 | 要转换的状态对象。 |
- 类型:
string|null - 语义:返回生成的MNUI状态URL,失败时返回null。
setUIStatusByConfig
Section titled “setUIStatusByConfig”static setUIStatusByConfig(jsonObj: object): void|null按配置切换界面状态。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonObj | object | 是 | 界面状态配置对象。 |
- 类型:
void|null - 语义:无返回值,失败时返回null。
setMindmapZoonScale
Section titled “setMindmapZoonScale”static setMindmapZoonScale(scale: number): void设置脑图缩放比例。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
scale | number | 是 | 缩放比例。 |
- 类型:
void - 语义:无返回值。
setSideBar
Section titled “setSideBar”static setSideBar(open: boolean): void打开或关闭侧栏。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
open | boolean | 是 | 是否打开侧栏。 |
- 类型:
void - 语义:无返回值。
searchInSideBar
Section titled “searchInSideBar”static searchInSideBar(searchText: string, type?: 'name'|'text'): void在侧栏按标题或文本搜索。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
searchText | string | 是 | 搜索文本。 |
type | `‘name' | 'text’` | 否 |
- 类型:
void - 语义:无返回值。
_getFloatSearchWebview
Section titled “_getFloatSearchWebview”static _getFloatSearchWebview(): UIWebView|undefined获取浮动搜索WebView。
无。
- 类型:
UIWebView|undefined - 语义:返回浮动搜索WebView实例,不存在时返回undefined。
_getFixedSearchWebview
Section titled “_getFixedSearchWebview”static _getFixedSearchWebview(): UIWebView|undefined获取固定搜索WebView。
无。
- 类型:
UIWebView|undefined - 语义:返回固定搜索WebView实例,不存在时返回undefined。
isSearchWebviewShown
Section titled “isSearchWebviewShown”static isSearchWebviewShown(): boolean判断搜索WebView是否可见。
无。
- 类型:
boolean - 语义:返回搜索WebView是否可见。
getSearchWebviewURL
Section titled “getSearchWebviewURL”static getSearchWebviewURL(): string|undefined读取搜索WebView当前URL。
无。
- 类型:
string|undefined - 语义:返回搜索WebView当前URL,不存在时返回undefined。
showResearchView
Section titled “showResearchView”static showResearchView(): void显示研究视图。
无。
- 类型:
void - 语义:无返回值。
openURLInResearch
Section titled “openURLInResearch”static openURLInResearch(url: string, needEncode?: boolean): void在研究视图打开URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 要打开的URL。 |
needEncode | boolean | 否 | 是否需要编码,默认为false。 |
- 类型:
void - 语义:无返回值。
openNoteEditor
Section titled “openNoteEditor”static openNoteEditor(noteId: string): void打开指定卡片编辑器。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteId | string | 是 | 卡片ID。 |
- 类型:
void - 语义:无返回值。
selectNotesInMindmap
Section titled “selectNotesInMindmap”static selectNotesInMindmap(noteIds: string[]|string): void在脑图中选中目标卡片。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteIds | `string[] | string` | 是 |
- 类型:
void - 语义:无返回值。
setTheme
Section titled “setTheme”static setTheme(themeName: string): void切换主题。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
themeName | string | 是 | 主题名称。 |
- 类型:
void - 语义:无返回值。
getToday
Section titled “getToday”static getToday(): number获取当天日期数字。
无。
- 类型:
number - 语义:返回当天日期数字。
_isTagComment_
Section titled “_isTagComment_”static _isTagComment_(comment: NoteComment): boolean判断评论是否是标签评论。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
comment | NoteComment | 是 | 评论对象。 |
- 类型:
boolean - 语义:返回评论是否是标签评论。
getCurrentSelection
Section titled “getCurrentSelection”static getCurrentSelection(): {onSelection:boolean,image?:NSData,text?:string,isText?:boolean,docMd5?:string,pageIndex?:number,source?:string,docController?:DocumentController}读取当前选区。
无。
- 类型:
{onSelection:boolean,image?:NSData,text?:string,isText?:boolean,docMd5?:string,pageIndex?:number,source?:string,docController?:DocumentController} - 语义:返回当前选区对象。
rgbaToHex
Section titled “rgbaToHex”static rgbaToHex(rgba: { r: number; g: number; b: number; a: number }, includeAlpha?: boolean, toUpperCase?: boolean): stringRGBA转十六进制颜色。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
rgba | { r: number; g: number; b: number; a: number } | 是 | RGBA颜色对象。 |
includeAlpha | boolean | 否 | 是否包含透明度,默认false。 |
toUpperCase | boolean | 否 | 是否大写,默认false。 |
- 类型:
string - 语义:返回十六进制颜色值。
rgbaArrayToHexArray
Section titled “rgbaArrayToHexArray”static rgbaArrayToHexArray(rgbaArray: Array<{ r: number; g: number; b: number; a: number }>, includeAlpha?: boolean, toUpperCase?: boolean): string[]RGBA数组批量转十六进制颜色。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
rgbaArray | Array<{ r: number; g: number; b: number; a: number }> | 是 | RGBA数组。 |
includeAlpha | boolean | 否 | 是否包含透明度,默认false。 |
toUpperCase | boolean | 否 | 是否大写,默认false。 |
- 类型:
string[] - 语义:返回十六进制颜色值数组。
getNotebookExcerptColorById
Section titled “getNotebookExcerptColorById”static getNotebookExcerptColorById(notebookId: string): string[]按学习集id获取摘录颜色。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
notebookId | string | 是 | 学习集ID。 |
- 类型:
string[] - 语义:返回学习集的摘录颜色。
noteColorByNotebookIdAndColorIndex
Section titled “noteColorByNotebookIdAndColorIndex”static noteColorByNotebookIdAndColorIndex(notebookId: string, colorIndex: number): string按学习集和颜色索引取颜色值。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
notebookId | string | 是 | 学习集ID。 |
colorIndex | number | 是 | 颜色索引。 |
- 类型:
string - 语义:返回颜色值。
appVersion
Section titled “appVersion”static appVersion(): { version: 'marginnote4'|'marginnote3'; versionNumber: number; type: 'iPadOS'|'iPhoneOS'|'macOS' }|undefined获取应用版本号。
无。
- 类型:
{ version: 'marginnote4'|'marginnote3'; versionNumber: number; type: 'iPadOS'|'iPhoneOS'|'macOS' }\|undefined - 语义:返回应用版本和系统类型信息,异常时返回
undefined。
static isIOS(): boolean判断当前系统是否iOS。
无。
- 类型:
boolean - 语义:返回当前系统是否iOS。
isMacOS
Section titled “isMacOS”static isMacOS(): boolean判断当前系统是否macOS。
无。
- 类型:
boolean - 语义:返回当前系统是否macOS。
isIPadOS
Section titled “isIPadOS”static isIPadOS(): boolean判断当前系统是否iPadOS。
无。
- 类型:
boolean - 语义:返回当前系统是否iPadOS。
static isMN4(): boolean判断当前是否MarginNote4。
无。
- 类型:
boolean - 语义:返回当前是否MarginNote4。
static isMN3(): boolean判断当前是否MarginNote3。
无。
- 类型:
boolean - 语义:返回当前是否MarginNote3。
getMNUtilVersion
Section titled “getMNUtilVersion”static getMNUtilVersion(): string获取MNUtil版本号。
无。
- 类型:
string - 语义:返回MNUtil版本号。
countWords
Section titled “countWords”static countWords(str: string): number统计文本词数。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要统计的文本。 |
- 类型:
number - 语义:返回文本词数。
removePunctuationOnlyElements
Section titled “removePunctuationOnlyElements”static removePunctuationOnlyElements(arr: string[]): string[]移除仅含标点的分词结果。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
arr | string[] | 是 | 分词结果数组。 |
- 类型:
string[] - 语义:返回移除标点后的分词结果数组。
doSegment
Section titled “doSegment”static doSegment(str: string): string[]对文本做分词。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要分词的文本。 |
- 类型:
string[] - 语义:返回分词结果数组。
wordCountBySegmentit
Section titled “wordCountBySegmentit”static wordCountBySegmentit(str: string): number按分词结果统计词数。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要统计的文本。 |
- 类型:
number - 语义:返回按分词结果统计的词数。
importNotebook
Section titled “importNotebook”static importNotebook(path: string, merge: boolean): MNNotebook|undefined导入学习集文件。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 学习集文件路径。 |
merge | boolean | 是 | 是否合并。 |
- 类型:
MNNotebook\|undefined - 语义:返回导入的学习集对象,失败时返回undefined。
subpathsOfDirectory
Section titled “subpathsOfDirectory”static subpathsOfDirectory(path: string): string[]读取目录全部子路径。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 目录路径。 |
- 类型:
string[] - 语义:返回目录全部子路径数组。
contentsOfDirectory
Section titled “contentsOfDirectory”static contentsOfDirectory(path: string): string[]读取目录直属内容。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 目录路径。 |
- 类型:
string[] - 语义:返回目录直属内容数组。
allNotebooks
Section titled “allNotebooks”static allNotebooks(): MNNotebook[]获取全部学习集。
无。
- 类型:
MNNotebook[] - 语义:返回全部学习集数组。
allNotebookIds
Section titled “allNotebookIds”static allNotebookIds(): string[]获取全部学习集id。
无。
- 类型:
string[] - 语义:返回全部学习集id数组。
allDocumentNotebooks
Section titled “allDocumentNotebooks”static allDocumentNotebooks(option?: { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] }): MNNotebook[]获取文档学习集列表。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
option | { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] } | 否 | 排除选项。 |
- 类型:
MNNotebook[] - 语义:返回文档学习集列表。
allReviewGroups
Section titled “allReviewGroups”static allReviewGroups(option?: { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] }): MNNotebook[]获取复习组列表。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
option | { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] } | 否 | 排除选项。 |
- 类型:
MNNotebook[] - 语义:返回复习组列表。
allStudySets
Section titled “allStudySets”static allStudySets(option?: { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] }): MNNotebook[]获取学习集列表。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
option | { exceptNotebookIds?: string[]; exceptNotebookNames?: string[] } | 否 | 排除选项。 |
- 类型:
MNNotebook[] - 语义:返回学习集列表。
notesInStudySet
Section titled “notesInStudySet”static notesInStudySet(studySetId?: string|MNNotebook): MbBookNote[]获取学习集内卡片。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
studySetId | string|MNNotebook | 否 | 学习集ID或学习集对象。 |
- 类型:
MbBookNote[] - 语义:返回学习集内卡片数组。
chatNotesInStudySet
Section titled “chatNotesInStudySet”static chatNotesInStudySet(studySetId?: string|MNNotebook): MbBookNote[]获取学习集内可聊天卡片。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
studySetId | string|MNNotebook | 否 | 学习集ID或学习集对象。 |
- 类型:
MbBookNote[] - 语义:返回学习集内可聊天卡片数组。
convertDate
Section titled “convertDate”static convertDate(date: string|number|Date|null|undefined): Date|null把输入值转成Date对象。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
date | string|number|Date|null|undefined | 是 | 要转换的日期值。 |
- 类型:
Date\|null - 语义:返回转换后的Date对象,失败时返回null。
convertNsAttrsToFsStats
Section titled “convertNsAttrsToFsStats”static convertNsAttrsToFsStats(nsAttrs: Record<string, object|string|number|Date>): { dev: number ino: number mode: number nlink: number uid: number gid: number rdev: number size: number blksize: number blocks: number atimeMs: number mtimeMs: number ctimeMs: number birthtimeMs: number atime: Date mtime: Date ctime: Date birthtime: Date _nsFileType?: string _nsFileOwnerAccountName?: string _nsFileGroupOwnerAccountName?: string _nsFileProtectionKey?: string _nsFileExtendedAttributes?: object isFile: boolean isDirectory: boolean isSymbolicLink: boolean isFIFO: boolean isSocket: boolean isBlockDevice: boolean isCharacterDevice: boolean}把NS文件属性转成常见文件属性结构。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
nsAttrs | Record<string,object|string|number|Date> | 是 | NS文件属性对象。 |
- 类型:
{ dev: number; ino: number; mode: number; nlink: number; uid: number; gid: number; rdev: number; size: number; blksize: number; blocks: number; atimeMs: number; mtimeMs: number; ctimeMs: number; birthtimeMs: number; atime: Date; mtime: Date; ctime: Date; birthtime: Date; _nsFileType?: string; _nsFileOwnerAccountName?: string; _nsFileGroupOwnerAccountName?: string; _nsFileProtectionKey?: string; _nsFileExtendedAttributes?: object; isFile: boolean; isDirectory: boolean; isSymbolicLink: boolean; isFIFO: boolean; isSocket: boolean; isBlockDevice: boolean; isCharacterDevice: boolean } - 语义:返回转换后的文件属性对象。
getFileAttributes
Section titled “getFileAttributes”static getFileAttributes(path: string): { dev: number ino: number mode: number nlink: number uid: number gid: number rdev: number size: number blksize: number blocks: number atimeMs: number mtimeMs: number ctimeMs: number birthtimeMs: number atime: Date mtime: Date ctime: Date birthtime: Date isFile: boolean isDirectory: boolean isSymbolicLink: boolean isFIFO: boolean isSocket: boolean isBlockDevice: boolean isCharacterDevice: boolean path: string}读取文件属性。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件路径。 |
- 类型:
{ dev: number; ino: number; mode: number; nlink: number; uid: number; gid: number; rdev: number; size: number; blksize: number; blocks: number; atimeMs: number; mtimeMs: number; ctimeMs: number; birthtimeMs: number; atime: Date; mtime: Date; ctime: Date; birthtime: Date; isFile: boolean; isDirectory: boolean; isSymbolicLink: boolean; isFIFO: boolean; isSocket: boolean; isBlockDevice: boolean; isCharacterDevice: boolean; path: string } - 语义:返回文件属性对象。
strCode
Section titled “strCode”static strCode(str: string): number计算字符串编码值。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
str | string | 是 | 要计算的字符串。 |
- 类型:
number - 语义:返回字符串编码值。
textMatchPhrase
Section titled “textMatchPhrase”static textMatchPhrase(text: string, query: string): boolean判断文本是否命中查询短语。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
text | string | 是 | 要匹配的文本。 |
query | string | 是 | 查询短语。 |
- 类型:
boolean - 语义:返回文本是否命中查询短语。
allDocuments
Section titled “allDocuments”static allDocuments(): MbBook[]获取全部文档。
无。
- 类型:
MbBook[] - 语义:返回全部文档数组。
allDocumentIds
Section titled “allDocumentIds”static allDocumentIds(): string[]获取全部文档id。
无。
- 类型:
string[] - 语义:返回全部文档id数组。
getNoteFileById
Section titled “getNoteFileById”static getNoteFileById(noteId: string): { fileExists: false } | { name: string; path: string; md5: string; fileExists: true; pageCount: number }按卡片id获取关联文件信息。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteId | string | 是 | 卡片ID。 |
- 类型:
{ fileExists: false } | { name: string; path: string; md5: string; fileExists: true; pageCount: number } - 语义:返回卡片关联文件信息。
isNSNull
Section titled “isNSNull”static isNSNull(obj: object): boolean判断对象是否为NSNull。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
obj | object | 是 | 要判断的对象。 |
- 类型:
boolean - 语义:返回对象是否为NSNull。
createFolder
Section titled “createFolder”static createFolder(path: string): void创建目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 目录路径。 |
- 类型:
void - 语义:无返回值。
createFolderDev
Section titled “createFolderDev”static createFolderDev(path: string): void在开发场景创建目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 目录路径。 |
- 类型:
void - 语义:无返回值。
writeDataToFile
Section titled “writeDataToFile”static writeDataToFile(data: NSData, path: string): boolean把数据写入文件。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
data | NSData | 是 | 要写入的数据。 |
path | string | 是 | 文件路径。 |
- 类型:
boolean - 语义:写入成功返回
true,失败返回false。
getFileFold
Section titled “getFileFold”static getFileFold(path: string): string获取文件所在目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件路径。 |
- 类型:
string - 语义:返回文件所在目录。
getFileFolder
Section titled “getFileFolder”static getFileFolder(path: string): string获取文件所在目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件路径。 |
- 类型:
string - 语义:返回文件所在目录。
copyFile
Section titled “copyFile”static copyFile(sourcePath: string, targetPath: string): void复制文件。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
sourcePath | string | 是 | 源文件路径。 |
targetPath | string | 是 | 目标文件路径。 |
- 类型:
void - 语义:无返回值。
moveFile
Section titled “moveFile”static moveFile(sourcePath: string, targetPath: string): void移动文件。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
sourcePath | string | 是 | 源文件路径。 |
targetPath | string | 是 | 目标文件路径。 |
- 类型:
void - 语义:无返回值。
moveFileToCacheFolder
Section titled “moveFileToCacheFolder”static moveFileToCacheFolder(path: string): void把文件移动到缓存目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件路径。 |
- 类型:
void - 语义:无返回值。
moveFolderToCacheFolder
Section titled “moveFolderToCacheFolder”static moveFolderToCacheFolder(path: string): void把目录移动到缓存目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 目录路径。 |
- 类型:
void - 语义:无返回值。
moveToCacheFolder
Section titled “moveToCacheFolder”static moveToCacheFolder(path: string): void把文件或目录移动到缓存目录。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件或目录路径。 |
- 类型:
void - 语义:无返回值。
getRandomElement
Section titled “getRandomElement”static getRandomElement(arr: any[]): any从集合随机取一个元素。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
arr | any[] | 是 | 集合对象。 |
- 类型:
any - 语义:返回随机选取的元素,空数组时返回空字符串。
showHUD
Section titled “showHUD”static showHUD(message: string, duration?: number, view?: UIView): void显示HUD提示。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
message | string | 是 | 提示消息。 |
duration | number | 否 | 显示时长,默认为2秒。 |
view | UIView | 否 | 显示视图,默认为当前窗口。 |
- 类型:
void - 语义:无返回值。
waitHUD
Section titled “waitHUD”static waitHUD(message: string, view?: UIView): void显示等待HUD。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
message | string | 是 | 提示消息。 |
view | UIView | 否 | 显示视图,默认为当前窗口。 |
- 类型:
void - 语义:无返回值。
findToc
Section titled “findToc”static findToc(md5: string, excludeNotebookId?: string): MNNote[]|undefined查找文档目录卡片。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
md5 | string | 是 | 文档MD5。 |
excludeNotebookId | string | 否 | 排除的笔记本ID。 |
- 类型:
MNNote[]\|undefined - 语义:找到目录卡片时返回数组,否则返回
undefined。
getDocTocNotes
Section titled “getDocTocNotes”static getDocTocNotes(md5?: string, notebookId?: string): MNNote[]|undefined获取文档目录卡片列表。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
md5 | string | 否 | 文档MD5,默认当前文档。 |
notebookId | string | 否 | 笔记本ID,默认当前学习集。 |
- 类型:
MNNote[]\|undefined - 语义:返回目录卡片列表,未找到时返回
undefined。
fileTypeFromBase64URL
Section titled “fileTypeFromBase64URL”static fileTypeFromBase64URL(content: string): string|undefined从DataURL判断文件类型。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
content | string | 是 | DataURL内容。 |
- 类型:
string\|undefined - 语义:返回文件类型。
getFileTypeFromhexHeader
Section titled “getFileTypeFromhexHeader”static getFileTypeFromhexHeader(hexHeader: string): string从十六进制头判断文件类型。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
hexHeader | string | 是 | 十六进制头信息。 |
- 类型:
string - 语义:返回文件类型。
hexHeaderFromData
Section titled “hexHeaderFromData”static hexHeaderFromData(data: NSData): string|undefined提取数据头部十六进制。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
data | NSData | 是 | 数据对象。 |
- 类型:
string\|undefined - 语义:返回十六进制头部信息。
getFileTypeFromBase64
Section titled “getFileTypeFromBase64”static getFileTypeFromBase64(base64: string): string从Base64字符串判断文件类型。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
base64 | string | 是 | Base64字符串。 |
- 类型:
string - 语义:返回文件类型。
getFileType
Section titled “getFileType”static getFileType(data: NSData|string): string从二进制数据判断文件类型。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
data | NSData|string | 是 | 二进制数据或Base64字符串。 |
- 类型:
string - 语义:返回文件类型。
copyObject
Section titled “copyObject”static copyObject(object: object|NSData|UIImage): void复制对象。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
object | object|NSData|UIImage | 是 | 要复制的对象。 |
- 类型:
void - 语义:无返回值。
static copy(object: string|object|NSData|UIImage|number|boolean|undefined): void复制文本或对象到剪贴板。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
object | string|object|NSData|UIImage|number|boolean|undefined | 是 | 要复制的文本或对象。 |
- 类型:
void - 语义:无返回值。
copyJSON
Section titled “copyJSON”static copyJSON(object: object): void复制JSON字符串到剪贴板。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
object | object | 是 | 要复制的对象。 |
- 类型:
void - 语义:无返回值。
copyImage
Section titled “copyImage”static copyImage(imageData: NSData): void复制图片到剪贴板。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
imageData | NSData | 是 | 图片数据。 |
- 类型:
void - 语义:无返回值。
openMarginNoteURL
Section titled “openMarginNoteURL”static openMarginNoteURL(url: string): void打开MarginNote内部URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | MarginNote内部URL。 |
- 类型:
void - 语义:无返回值。
openURL
Section titled “openURL”static openURL(url: string|NSURL, mode?: 'auto'|'external'|'mnbrowser'): void按模式打开URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string|NSURL | 是 | 要打开的URL。 |
mode | 'auto'|'external'|'mnbrowser' | 否 | 打开模式,默认为auto。 |
- 类型:
void - 语义:无返回值。
canOpenURL
Section titled “canOpenURL”static canOpenURL(url: string): boolean判断URL是否可打开。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 要检查的URL。 |
- 类型:
boolean - 语义:返回URL是否可打开。
parseTagsToTree
Section titled “parseTagsToTree”static parseTagsToTree(tags: string[]): Array<{ name: string; path: string; children: Array<{ name: string; path: string; children: object[]; isLeaf?: boolean }>; isLeaf?: boolean }>把标签数组转成树结构。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
tags | string[] | 是 | 标签数组。 |
- 类型:
Array<{ name: string; path: string; children: Array<{ name: string; path: string; children: object[]; isLeaf?: boolean }>; isLeaf?: boolean }> - 语义:返回标签树结构。
openWith
Section titled “openWith”static openWith(config: { url?: string; mode?: 'openURL'|'search'; textToSearch?: string; noteId?: string; engine?: string }, addon?: 'external'|'mnbrowser'): void调用指定插件执行openWith。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
config | { url?: string; mode?: 'openURL'|'search'; textToSearch?: string; noteId?: string; engine?: string } | 是 | 配置对象。 |
addon | 'external'|'mnbrowser' | 否 | 插件名称,默认external。 |
- 类型:
void - 语义:无返回值。
compressImage
Section titled “compressImage”static compressImage(imageData: string|NSData|UIImage, quality?: number): NSData|undefined压缩图片数据。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
imageData | string|NSData|UIImage | 是 | 图片数据。 |
quality | number | 否 | 压缩质量,0-1之间,默认0.1。 |
- 类型:
NSData\|undefined - 语义:压缩成功返回图片数据,失败返回
undefined。
parseURL
Section titled “parseURL”static parseURL(urlString: string|NSURL|NSURLRequest): {url:string,scheme:string,host?:string,query?:string,params:Record<string,string|boolean|object>,pathComponents?:string[],isBlank:boolean,fragment?:string,port?:number}解析URL并返回结构化信息。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
urlString | string|NSURL|NSURLRequest | 是 | 要解析的URL。 |
- 类型:
{url:string,scheme:string,host?:string,query?:string,params:Record<string,string\|boolean\|object>,pathComponents?:string[],isBlank:boolean,fragment?:string,port?:number} - 语义:返回解析后的URL结构信息。
isNoteInReview
Section titled “isNoteInReview”static isNoteInReview(noteId: string): boolean判断卡片是否在复习状态。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteId | string | 是 | 卡片ID。 |
- 类型:
boolean - 语义:返回卡片是否在复习状态。
notebookExists
Section titled “notebookExists”static notebookExists(notebookId: string, checkNotes?: boolean): boolean判断学习集是否存在。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
notebookId | string | 是 | 学习集ID。 |
checkNotes | boolean | 否 | 是否检查卡片,默认false。 |
- 类型:
boolean - 语义:返回学习集是否存在。
noteExists
Section titled “noteExists”static noteExists(noteId: string|MNNote): boolean判断卡片是否存在。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteId | string|MNNote | 是 | 卡片ID或MNNote实例。 |
- 类型:
boolean - 语义:返回卡片是否存在。
getNoteById
Section titled “getNoteById”static getNoteById(noteid: string, alert?: boolean): MbBookNote|undefined按id获取卡片对象。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteid | string | 是 | 卡片ID。 |
alert | boolean | 否 | 是否显示警告,默认为false。 |
- 类型:
MbBookNote\|undefined - 语义:返回卡片对象,不存在时返回undefined。
getNoteBookById
Section titled “getNoteBookById”static getNoteBookById(notebookId: string): MbTopic|undefined按id获取学习集对象。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
notebookId | string | 是 | 学习集ID。 |
- 类型:
MbTopic\|undefined - 语义:返回学习集对象,不存在时返回
undefined。
getDocById
Section titled “getDocById”static getDocById(md5: string): MbBook|undefined按md5获取文档对象。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
md5 | string | 是 | 文档MD5。 |
- 类型:
MbBook\|undefined - 语义:返回文档对象,不存在时返回undefined。
getNoteIdByURL
Section titled “getNoteIdByURL”static getNoteIdByURL(url: string): string从卡片URL提取卡片id。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 卡片URL。 |
- 类型:
string - 语义:返回卡片ID。
getNoteURLById
Section titled “getNoteURLById”static getNoteURLById(noteId: string): string按卡片id生成卡片URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
noteId | string | 是 | 卡片ID。 |
- 类型:
string - 语义:返回卡片URL。
getNotebookIdByURL
Section titled “getNotebookIdByURL”static getNotebookIdByURL(url: string): string从学习集URL提取学习集id。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 学习集URL。 |
- 类型:
string - 语义:返回学习集ID。
实例成员(Instance members)
Section titled “实例成员(Instance members)”MNUtil以类静态能力为主,实例成员暂无稳定对外约定。
getCurrentUIStatusURL
Section titled “getCurrentUIStatusURL”static async getCurrentUIStatusURL(): Promise<string|undefined>异步获取当前UI状态URL。
无。
- 类型:
Promise<string|undefined> - 语义:返回当前UI状态URL,失败时返回undefined。
setUIStatusByConfigAsync
Section titled “setUIStatusByConfigAsync”static async setUIStatusByConfigAsync(jsonObj: object): Promise<void>异步按配置设置UI状态。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonObj | object | 是 | 界面状态配置对象。 |
- 类型:
Promise<void> - 语义:无返回值。
getSearchWebview
Section titled “getSearchWebview”static async getSearchWebview(force?: boolean): Promise<UIWebView|undefined>异步获取搜索WebView。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
force | boolean | 否 | 是否强制创建,默认为false。 |
- 类型:
Promise<UIWebView|undefined> - 语义:返回搜索WebView实例,失败时返回undefined。
openURLInResearchAsync
Section titled “openURLInResearchAsync”static async openURLInResearchAsync(url: string, needEncode?: boolean): Promise<void>异步在研究视图打开URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 要打开的URL。 |
needEncode | boolean | 否 | 是否需要编码,默认为false。 |
- 类型:
Promise<void> - 语义:无返回值。
convertImageBase64ToPdfBase64
Section titled “convertImageBase64ToPdfBase64”static async convertImageBase64ToPdfBase64(pngBase64: string): Promise<string|undefined>异步把图片Base64转成PDFBase64。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
pngBase64 | string | 是 | 图片Base64字符串。 |
- 类型:
Promise<string|undefined> - 语义:返回PDF Base64字符串,失败时返回undefined。
convertImageDataToPdfData
Section titled “convertImageDataToPdfData”static async convertImageDataToPdfData(imageData: NSData): Promise<NSData|undefined>异步把图片数据转成PDF数据。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
imageData | NSData | 是 | 图片数据。 |
- 类型:
Promise<NSData|undefined> - 语义:返回PDF数据,失败时返回undefined。
runJavaScript
Section titled “runJavaScript”static async runJavaScript(webview: UIWebView, script: string): Promise<object|string|number|boolean|undefined>在WebView里执行JavaScript并返回结果。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
webview | UIWebView | 是 | WebView实例。 |
script | string | 是 | 要执行的JavaScript代码。 |
- 类型:
Promise<object|string|number|boolean|undefined> - 语义:返回JavaScript执行结果。
webviewBlur
Section titled “webviewBlur”static async webviewBlur(webView: UIWebView): Promise<void>触发WebView失焦。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
webView | UIWebView | 是 | WebView实例。 |
- 类型:
Promise<void> - 语义:无返回值。
stopHUD
Section titled “stopHUD”static async stopHUD(delay?: number, view?: UIView): Promise<void>关闭HUD。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
delay | number | 否 | 延迟时间,默认为0。 |
view | UIView | 否 | 显示视图,默认为当前窗口。 |
- 类型:
Promise<void> - 语义:无返回值。
static async alert(mainTitle: string, subTitle?: string): Promise<number>弹出提示框并返回按钮索引。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
mainTitle | string | 是 | 主标题。 |
subTitle | string | 否 | 副标题。 |
- 类型:
Promise<number> - 语义:返回按钮索引。
confirm
Section titled “confirm”static async confirm(mainTitle: string, subTitle?: string, items?: string[]): Promise<boolean>弹出确认框并返回布尔结果。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
mainTitle | string | 是 | 主标题。 |
subTitle | string | 否 | 副标题。 |
items | string[] | 否 | 选项列表。 |
- 类型:
Promise<boolean> - 语义:返回用户是否确认。
userSelect
Section titled “userSelect”static async userSelect(mainTitle: string, subTitle?: string, items: string[]): Promise<number>弹出选项框并返回选中索引。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
mainTitle | string | 是 | 主标题。 |
subTitle | string | 否 | 副标题。 |
items | string[] | 是 | 选项列表。 |
- 类型:
Promise<number> - 语义:返回选中的选项索引。
openMarginNoteURLAsync
Section titled “openMarginNoteURLAsync”static async openMarginNoteURLAsync(url: string): Promise<void>异步打开MarginNote内部URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | MarginNote内部URL。 |
- 类型:
Promise<void> - 语义:无返回值。
openURLAsync
Section titled “openURLAsync”static async openURLAsync(url: string, mode?: string): Promise<void>异步打开URL。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 要打开的URL。 |
mode | string | 否 | 打开模式。 |
- 类型:
Promise<void> - 语义:无返回值。
openURLOptionsCompletionHandler
Section titled “openURLOptionsCompletionHandler”static async openURLOptionsCompletionHandler(url: string): Promise<boolean>异步打开URL并返回是否成功。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 是 | 要打开的URL。 |
- 类型:
Promise<boolean> - 语义:返回URL是否打开成功。
openNotebook
Section titled “openNotebook”static async openNotebook(notebook: string|MNNotebook|MbTopic, needConfirm?: boolean): Promise<boolean>异步打开学习集。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
notebook | `string | MNNotebook | MbTopic` |
needConfirm | boolean | 否 | 是否需要确认,默认为false。 |
- 类型:
Promise<boolean> - 语义:返回学习集是否打开成功。