Skip to content

MbBookNote

插件开发中最核心的数据对象,代表一条笔记(脑图节点)。可通过 Database.getNoteByIdNotebookController.focusNoteMindMapNode.note 等获取。修改后建议使用 UndoManager.undoGrouping 包裹并刷新界面。

属性类型说明
noteTitlestring笔记标题。
excerptTextstring摘录文本。
excerptTextMarkdownnumber摘录文本是否为 Markdown(运行时字段,通常为 0/1)。
colorIndexnumber颜色索引 (0–15)。
fillIndexnumber填充类型。
属性类型说明
noteIdstring笔记唯一 ID。
docMd5string来源文档 MD5。
notebookIdstring所属笔记本 ID。
startPage / endPageNSNumber摘录起止页码。
startPos / endPosstring摘录起止位置。
excerptPicNSDictionary摘录图片信息。
createDate / modifiedDateNSDate创建/修改时间。
mediaListstring媒体列表。
originNoteIdstring原始笔记 ID(如 Evernote)。
mindmapBranchCloseNSNumber脑图分支是否折叠。
notesTextstring笔记文本聚合。
groupNoteIdstring分组笔记 ID。
commentsNSArray评论数组,元素为 NoteComment 结构。
parentNoteMbBookNote | undefined父笔记。
childMindMapMbBookNote | undefined子脑图(getter 为 parentDraft)。
linkedNotesNSArray链接的笔记。
childNotesNSArray子笔记数组。
summaryLinksNSArray摘要链接。
zLevel / hidden / toc / annotation / textFirst / groupMode / flashcard / flaggedNSNumber各类标志。
summaryboolean是否有摘要链接(getter hasSummaryLinks)。
textHighlight / optionsNSDictionary文本高亮与选项。

添加一条文本评论。

appendTextComment(text: string): void

Parameters:

NameTypeDescription
textstring评论内容。

添加一条 Markdown 格式评论。

appendMarkdownComment(text: string): void

Parameters:

NameTypeDescription
textstringMarkdown 格式的评论内容。

添加指向另一条笔记的链接。

appendNoteLink(note: MbBookNote): void

Parameters:

NameTypeDescription
noteMbBookNote目标笔记对象。

说明:会在 comments 数组中添加一条 TextNote 类型的评论,text 字段存储格式为 marginnote4app://note/{noteId}

添加笔记链接(历史命名;等价于“把另一条笔记作为链接加入 comments”)。

merge(note: MbBookNote): void

添加 HTML 评论(已废弃,建议使用 appendMarkdownComment)。

appendHtmlComment(html: string, text: string, size: CGSize, tag: string): void

Parameters:

NameTypeDescription
htmlstringHTML 内容。
textstring纯文本内容(用于搜索等)。
sizeCGSize渲染尺寸。
tagstring标签标识。

说明:此方法已废弃,HTML 评论不再单独存储,建议使用 appendMarkdownComment 替代。

按索引删除一条评论。

removeCommentByIndex(index: number): void

Parameters:

NameTypeDescription
indexnumber评论在 comments 数组中的索引。

清除笔记文本格式。

clearFormat(): void

粘贴(将剪贴板内容作为评论或摘录)。

paste(): void

获取笔记全部文本(标题+摘录+评论)。

allNoteText(): string

Return Value:

  • string: 聚合文本。

创建新笔记(类方法)。在 JS 侧通常通过全局注入的 Note 对象调用同名方法。

static createWithTitleNotebookDocument(title: string, notebook: MbTopic, document: MbBook): MbBookNote

创建新笔记的方法不在 MbBookNote 类上,而是在全局注入的 Note 对象上:

  • NoteNote.createWithTitleNotebookDocument(title, notebook, doc)
方法说明
removeFromParent()从父节点移除。
insertChildBefore(note, beforeNote)在指定子节点前插入。
addChild(note)添加子节点。
processMarkdownBase64Images()处理 Markdown 中的 base64 图片(按运行时实现)。
sortCommentsByNewIndices(newIndices)按新索引数组重排 comments。
getDrawingSize() / getStrokesCount()绘制相关信息(按运行时实现)。
realGroupNoteIdForTopicId(topicid)获取分组笔记在指定笔记本下的真实 ID。
头文件 API 清单

正在加载…

协议:,来源: