diff --git a/README.md b/README.md index 2407f00..0e16cc5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ ## 更新说明 > [!IMPORTANT] -> NoteToMP 1.3.0版本对主题进行了优化,升级后请先清理旧版本主题文件,再重新下载新版主题。 +> Note2Any 1.3.0版本对主题进行了优化,升级后请先清理旧版本主题文件,再重新下载新版主题。 > -> 操作步骤:在NoteToMP插件设置中,先点击『清空主题-清空』,然后点击『获取更多主题-下载』 +> 操作步骤:在Note2Any插件设置中,先点击『清空主题-清空』,然后点击『获取更多主题-下载』 > > 注意:如果修改过主题文件请做备份后再操作。 @@ -49,30 +49,30 @@ ``` 路径日志做了节流:同一文件 3 秒内不重复打印。后续可加"调试开关"以完全关闭。 -### 摘要、封面裁剪、原文链接等ges/screenshot.png) +### 摘要、封面裁剪、原文链接等 ## 2、安装 首先,**请确认已关闭了Obsidian的安全模式**。如未关闭,请通过**设置——第三方插件——关闭安全模式**关闭。 ### 2.1 插件安装 #### 从官方**社区插件市场**安装 -通过Obsidian**设置——第三方插件——社区插件市场**,输入**NoteToMP**搜索安装。 +通过Obsidian**设置——第三方插件——社区插件市场**,输入**Note2Any**搜索安装。 ### 2.2 主题资源安装 如果采用的是用从插件市场或者Github下载安装的方式,在插件安装完成后还需要再下载主题资源。网盘里的安装包已经集成了主题样式,无需下载。 **1)通过设置下载** -为了尽可能保证插件符合官方规范,主题和代码高亮需要打开Obsidian的**设置**界面,在底部的**第三方插件**——**Note to MP**——**获取更多主题**手动下载。 +为了尽可能保证插件符合官方规范,主题和代码高亮需要打开Obsidian的**设置**界面,在底部的**第三方插件**——**Note 2 Any**——**获取更多主题**手动下载。 **2)手动下载** -也可以直接在[Release](https://github.com/sunbooshi/note-to-mp/releases)页面下载`assets.zip`文件,解压后放到`.obsidian/plugins/note-to-mp/assets`目录下。 +也可以直接在[Release](https://github.com/sunbooshi/note2any/releases)页面下载`assets.zip`文件,解压后放到`.obsidian/plugins/note2any/assets`目录下。 ### 2.3 常见安装问题 **只有默认主题** 确认根据**2.2 主题资源安装**里的步骤操作了,然后检查一下插件目录内容,应如下所示: ``` -.obsidian/plugins/note-to-mp/ +.obsidian/plugins/note2any/ ├── assets │ ├── themes.json │ ├── highlights.json @@ -177,36 +177,36 @@ c=+-sqrt(a^2+b^2) ``` ```` -然后打开NoteToMP插件设置,将**自定义样式**(即包含自定义CSS内容的笔记名称),粘贴到**自定义CSS笔记**中即可。如果不使用自定义CSS,留空即可。 +然后打开Note2Any插件设置,将**自定义样式**(即包含自定义CSS内容的笔记名称),粘贴到**自定义CSS笔记**中即可。如果不使用自定义CSS,留空即可。 关于自定义CSS的写法可以参考下面的代码 ```css /* 全局属性 * 这里可以设置字体,字体大小,边距,背景颜色等 */ -.note-to-mp { +.note2any { /* 注:请在大括号内改写!!! */ } /* 段落 */ -.note-to-mp p { +.note2any p { /* 注:请在大括号内改写!!! */ } /* 一级标题 */ -.note-to-mp h1 { +.note2any h1 { /* 注:请在大括号内改写!!! */ } /* 二级标题 */ -.note-to-mp h2 { +.note2any h2 { /* 注:请在大括号内改写!!! */ } /* 三级标题 */ -.note-to-mp h3 { +.note2any h3 { /* 注:请在大括号内改写!!! */ } @@ -214,38 +214,38 @@ c=+-sqrt(a^2+b^2) /* 无序列表整体样式 * list-style-type: square|circle|disc; */ -.note-to-mp ul { +.note2any ul { /* 注:请在大括号内改写!!! */ } /* 加粗 */ -.note-to-mp strong { +.note2any strong { /* 注:请在大括号内改写!!! */ } /* 斜体 */ -.note-to-mp em { +.note2any em { /* 注:请在大括号内改写!!! */ } /* 加粗斜体 */ -.note-to-mp em strong { +.note2any em strong { /* 注:请在大括号内改写!!! */ } /* 删除线 */ -.note-to-mp del { +.note2any del { /* 注:请在大括号内改写!!! */ } /* 分隔线 */ -.note-to-mp hr { +.note2any hr { /* 注:请在大括号内改写!!! */ } /* 图片 */ -.note-to-mp img { +.note2any img { /* 注:请在大括号内改写!!! */ } /* @@ -288,7 +288,7 @@ c=+-sqrt(a^2+b^2) 例如这篇文章[几个让公众号排版更精致的小技巧,手机上也可以!](https://mp.weixin.qq.com/s/Q4_pV9TW8un3qZ0vrUvD1A)👈️使用的自定义样式如下: ```css -.note-to-mp { +.note2any { font-family: Optima-regular, Optima, "Microsoft YaHei", PingFangSC-regular, serif; } @@ -313,7 +313,7 @@ section .note-callout-example { background-color: rgba(90, 185, 131, 0.1); } ``` -上面的例子,通过`.note-to-mp`指定了文章的字体,通过`h2 strong`单独定义了h2标题下strong的样式,这样可以在标题中通过使用粗体增加了一个边框样式。通过`h2`定义了h2标题的底部线条的宽度和文本颜色。这样配合**Olive Dunk**主题就形成了自己的风格。 +上面的例子,通过`.note2any`指定了文章的字体,通过`h2 strong`单独定义了h2标题下strong的样式,这样可以在标题中通过使用粗体增加了一个边框样式。通过`h2`定义了h2标题的底部线条的宽度和文本颜色。这样配合**Olive Dunk**主题就形成了自己的风格。 ### 公众号名片 请参考 https://mp.weixin.qq.com/s/1wYd15Irmv9BPabgp5XMCA @@ -341,7 +341,7 @@ NoteToMP插件支持该语法。 ![[文件名称#^段落标记]] ``` -在NoteToMP插件中有两种展示文件嵌入内容的样式,一种是引用,也就是Obsidian默认的方式,一种是正文,相当于模板的方式。与模板不同的是,采用嵌入方式内容会跟随被嵌入文件的内容更改。 +在Note2Any插件中有两种展示文件嵌入内容的样式,一种是引用,也就是Obsidian默认的方式,一种是正文,相当于模板的方式。与模板不同的是,采用嵌入方式内容会跟随被嵌入文件的内容更改。 ## 批量发布(Batch Publish) diff --git a/assets/themes/mweb-indigo.css b/assets/themes/mweb-indigo.css index 47c1164..7ede55c 100644 --- a/assets/themes/mweb-indigo.css +++ b/assets/themes/mweb-indigo.css @@ -1,4 +1,4 @@ -.note-to-mp { +.note2any { padding: 0 1em; color: #595959; font-size: 16px; diff --git a/manifest.json b/manifest.json index f8d150c..4716f9a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { - "id": "note-to-mp", - "name": "NoteToAny", + "id": "note2any", + "name": "Note2Any", "version": "1.3.4", "minAppVersion": "1.4.5", "description": "xiaohongshu/mp publisher ", diff --git a/package.json b/package.json index f81cbcf..cb72096 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "note-to-mp", + "name": "note2any", "version": "1.3.0", "description": "This is a plugin for Obsidian (https://obsidian.md)", "main": "main.js", diff --git a/src/article-render.ts b/src/article-render.ts index c9f7c2d..1cd8b20 100644 --- a/src/article-render.ts +++ b/src/article-render.ts @@ -200,7 +200,7 @@ export class ArticleRender implements MDRendererCallback { errorContent(error: any) { return '

渲染失败!


' - + '如需帮助请前往  https://github.com/sunbooshi/note-to-mp/issues  反馈

' + + '如需帮助请前往  https://github.com/sunbooshi/note2any/issues  反馈

' + '如果方便,请提供引发错误的完整Markdown内容。

' + '
Obsidian版本:' + apiVersion + '
错误信息:
' @@ -341,11 +341,11 @@ export class ArticleRender implements MDRendererCallback { try { const globalAny = window as any; const now = Date.now(); - if (!globalAny.__note2mp_lastPathLog || - globalAny.__note2mp_lastPathLog.path !== file.path || - now - globalAny.__note2mp_lastPathLog.time > 3000) { - console.log('[note2mp] active file path:', file.path); - globalAny.__note2mp_lastPathLog = { path: file.path, time: now }; + if (!globalAny.__note2any_lastPathLog || + globalAny.__note2any_lastPathLog.path !== file.path || + now - globalAny.__note2any_lastPathLog.time > 3000) { + console.log('[note2any] active file path:', file.path); + globalAny.__note2any_lastPathLog = { path: file.path, time: now }; } } catch {} const metadata = this.app.metadataCache.getFileCache(file); @@ -475,7 +475,7 @@ export class ArticleRender implements MDRendererCallback { if (base) res.cover = `![[${base}]]`; } if (res.cover) { - try { console.log('[note2mp] use default cover:', def, '->', res.cover); } catch {} + try { console.log('[note2any] use default cover:', def, '->', res.cover); } catch {} } } } diff --git a/src/assets.ts b/src/assets.ts index f52b1fc..8064b56 100644 --- a/src/assets.ts +++ b/src/assets.ts @@ -297,7 +297,7 @@ export default class AssetsManager { getThemeURL() { const version = this.manifest.version; - return `https://github.com/sunbooshi/note-to-mp/releases/download/${version}/assets.zip`; + return `https://github.com/sunbooshi/note2any/releases/download/${version}/assets.zip`; } async getStyle() { diff --git a/src/batch-publish-modal.ts b/src/batch-publish-modal.ts index 421cebd..881460b 100644 --- a/src/batch-publish-modal.ts +++ b/src/batch-publish-modal.ts @@ -8,7 +8,7 @@ import { App, Modal, Setting, TFile, Notice, ButtonComponent } from 'obsidian'; import { BatchArticleFilter, BatchFilterConfig } from './batch-filter'; -import NoteToMpPlugin from './main'; +import Note2AnyPlugin from './main'; // 小红书功能模块 import { XiaohongshuContentAdapter } from './xiaohongshu/adapter'; import { XiaohongshuAPIManager } from './xiaohongshu/api'; @@ -34,7 +34,7 @@ import { XiaohongshuAPIManager } from './xiaohongshu/api'; */ export class BatchPublishModal extends Modal { - plugin: NoteToMpPlugin; + plugin: Note2AnyPlugin; filter: BatchArticleFilter; filteredFiles: TFile[] = []; selectedFiles: Set = new Set(); @@ -69,7 +69,7 @@ export class BatchPublishModal extends Modal { orderDirection: 'asc' }; - constructor(app: App, plugin: NoteToMpPlugin) { + constructor(app: App, plugin: Note2AnyPlugin) { super(app); this.plugin = plugin; this.filter = new BatchArticleFilter(app); diff --git a/src/main.ts b/src/main.ts index a576aa9..5d2985f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,7 @@ import { Plugin, WorkspaceLeaf, App, PluginManifest, Menu, Notice, TAbstractFile, TFile, TFolder } from 'obsidian'; import { PreviewView, VIEW_TYPE_NOTE_PREVIEW } from './preview-view'; import { NMPSettings } from './settings'; -import { NoteToMpSettingTab } from './setting-tab'; +import { Note2AnySettingTab } from './setting-tab'; import AssetsManager from './assets'; import { setVersion, uevent } from './utils'; import { WidgetsModal } from './widgets-modal'; @@ -20,7 +20,7 @@ import { XiaohongshuContentAdapter } from './xiaohongshu/adapter'; import { XiaohongshuAPIManager } from './xiaohongshu/api'; /** - * NoteToMpPlugin + * Note2AnyPlugin * * 中文说明: * 这是插件的入口类,负责: @@ -30,12 +30,12 @@ import { XiaohongshuAPIManager } from './xiaohongshu/api'; * - 提供文件右键菜单扩展,支持对单文件或文件夹进行发布操作 * * 设计决策(简要): - * - 将批量发布的 UI 放在 `BatchPublishModal` 中,命令 `note-to-mp-batch-publish` 会打开该模态框 + * - 将批量发布的 UI 放在 `BatchPublishModal` 中,命令 `note2any-batch-publish` 会打开该模态框 * - 单篇发布/文件夹批量发布仍复用 `NotePreview` 的发布逻辑,避免重复实现上传流程 */ -export default class NoteToMpPlugin extends Plugin { +export default class Note2AnyPlugin extends Plugin { settings: NMPSettings; assetsManager: AssetsManager; ribbonIconEl: HTMLElement | null = null; @@ -51,35 +51,35 @@ export default class NoteToMpPlugin extends Plugin { } async onload() { - console.log('Loading NoteToMP (plugin onload start)'); + console.log('Loading Note2Any (plugin onload start)'); setVersion(this.manifest.version); uevent('load'); - console.log('[NoteToMpPlugin] workspace.layoutReady at onload =', this.app.workspace.layoutReady); + console.log('[Note2AnyPlugin] workspace.layoutReady at onload =', this.app.workspace.layoutReady); // 先注册 view 之前,防止旧 snapshot 立即恢复创建大量视图:先临时卸载残留叶子(如果类型匹配) try { const legacyLeaves = this.app.workspace.getLeavesOfType(VIEW_TYPE_NOTE_PREVIEW); if (legacyLeaves.length > 0) { - console.log('[NoteToMpPlugin] detach legacy leaves early count=', legacyLeaves.length); + console.log('[Note2AnyPlugin] detach legacy leaves early count=', legacyLeaves.length); this.app.workspace.detachLeavesOfType(VIEW_TYPE_NOTE_PREVIEW); } } catch (e) { - console.warn('[NoteToMpPlugin] early detach failed', e); + console.warn('[Note2AnyPlugin] early detach failed', e); } this.app.workspace.onLayoutReady(async () => { - console.log('[NoteToMpPlugin] onLayoutReady callback entered'); - console.time('[NoteToMpPlugin] startup:onLayoutReady→loadResource'); + console.log('[Note2AnyPlugin] onLayoutReady callback entered'); + console.time('[Note2AnyPlugin] startup:onLayoutReady→loadResource'); try { await this.loadResource(); // 确保资源完全加载完再继续,避免后续视图初始化反复等待 } catch (e) { - console.error('[NoteToMpPlugin] loadResource 失败', e); + console.error('[Note2AnyPlugin] loadResource 失败', e); } finally { - console.timeEnd('[NoteToMpPlugin] startup:onLayoutReady→loadResource'); + console.timeEnd('[Note2AnyPlugin] startup:onLayoutReady→loadResource'); } // 清理旧视图 this.cleanupLegacyViews(); // 取消自动打开预览视图(用于排查启动卡顿)。用户可通过图标或命令手动打开。 - // console.log('[NoteToMpPlugin] 已跳过自动打开预览视图调试模式'); + // console.log('[Note2AnyPlugin] 已跳过自动打开预览视图调试模式'); }); this.registerView( @@ -90,28 +90,28 @@ export default class NoteToMpPlugin extends Plugin { this.ribbonIconEl = this.addRibbonIcon('clipboard-paste', '复制到公众号', (evt: MouseEvent) => { this.activateView(); }); - this.ribbonIconEl.addClass('note-to-mp-plugin-ribbon-class'); + this.ribbonIconEl.addClass('note2any-plugin-ribbon-class'); this.addCommand({ - id: 'note-to-mp-preview', + id: 'note2any-preview', name: '复制到公众号', callback: () => { this.activateView(); } }); - this.addSettingTab(new NoteToMpSettingTab(this.app, this)); + this.addSettingTab(new Note2AnySettingTab(this.app, this)); this.addCommand({ - id: 'note-to-mp-widget', - name: '插入样式小部件', + id: 'note2any-widget', + name: '插入样式组件', callback: () => { new WidgetsModal(this.app).open(); } }); this.addCommand({ - id: 'note-to-mp-batch-publish', + id: 'note2any-batch-publish', name: '批量发布文章', callback: () => { new BatchPublishModal(this.app, this).open(); @@ -120,7 +120,7 @@ export default class NoteToMpPlugin extends Plugin { // TODO: 重构后需要重新实现批量发布功能 // this.addCommand({ - // id: 'note-to-mp-pub', + // id: 'note2any-pub', // name: '发布公众号文章', // callback: async () => { // await this.activateView(); @@ -130,7 +130,7 @@ export default class NoteToMpPlugin extends Plugin { // 命令:当前文件发布到微信草稿 this.addCommand({ - id: 'note-to-mp-post-current', + id: 'note2any-post-current', name: '发布当前文件到公众号草稿', callback: async () => { const file = this.app.workspace.getActiveFile(); @@ -181,7 +181,7 @@ export default class NoteToMpPlugin extends Plugin { } onunload() { - console.log('Unloading NoteToMP'); + console.log('Unloading Note2Any'); // 移除 ribbon icon,避免重载插件时重复创建 if (this.ribbonIconEl) { this.ribbonIconEl.remove(); @@ -208,7 +208,7 @@ export default class NoteToMpPlugin extends Plugin { } }); } catch (e) { - console.warn('[NoteToMp] cleanupLegacyViews 失败', e); + console.warn('[Note2Any] cleanupLegacyViews 失败', e); } } diff --git a/src/setting-tab.ts b/src/setting-tab.ts index f84dc65..507b6b0 100644 --- a/src/setting-tab.ts +++ b/src/setting-tab.ts @@ -4,19 +4,19 @@ */ import { App, TextAreaComponent, PluginSettingTab, Setting, Notice, sanitizeHTMLToDom } from 'obsidian'; -import NoteToMpPlugin from './main'; +import Note2AnyPlugin from './main'; import { wxGetToken, wxEncrypt } from './wechat/weixin-api'; import { cleanMathCache } from './markdown/math'; import { NMPSettings } from './settings'; import { DocModal } from './doc-modal'; -export class NoteToMpSettingTab extends PluginSettingTab { - plugin: NoteToMpPlugin; +export class Note2AnySettingTab extends PluginSettingTab { + plugin: Note2AnyPlugin; wxInfo: string; wxTextArea: TextAreaComponent|null; settings: NMPSettings; - constructor(app: App, plugin: NoteToMpPlugin) { + constructor(app: App, plugin: Note2AnyPlugin) { super(app, plugin); this.plugin = plugin; this.settings = NMPSettings.getInstance(); @@ -425,7 +425,7 @@ export class NoteToMpSettingTab extends PluginSettingTab { private renderImageTab(panel: HTMLElement): void { new Setting(panel) .setName('切图保存路径') - .setDesc('切图文件的保存目录,默认:/Users/gavin/note2mp/images/xhs') + .setDesc('切图文件的保存目录,默认:/Users/gavin/note2any/images/xhs') .addText(text => { text.setPlaceholder('例如 /Users/xxx/images/xhs') .setValue(this.settings.sliceImageSavePath || '') diff --git a/src/settings.ts b/src/settings.ts index 8db54bc..916e2f6 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -100,7 +100,7 @@ export class NMPSettings { } ]; // 切图配置默认值 - this.sliceImageSavePath = '/Users/gavin/note2mp/images/xhs'; + this.sliceImageSavePath = '/Users/gavin/note2any/images/xhs'; this.sliceImageWidth = 1080; this.sliceImageAspectRatio = '3:4'; this.xhsPreviewWidth = 540; diff --git a/src/utils.ts b/src/utils.ts index 0d9671f..c83d623 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -31,7 +31,7 @@ export function setVersion(version: string) { function getStyleSheet() { for (var i = 0; i < document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; - if (sheet.title == 'note-to-mp-style') { + if (sheet.title == 'note2any-style') { return sheet; } } diff --git a/src/xiaohongshu/xhs-preview.ts b/src/xiaohongshu/xhs-preview.ts index 618d3e1..9d1463d 100644 --- a/src/xiaohongshu/xhs-preview.ts +++ b/src/xiaohongshu/xhs-preview.ts @@ -460,7 +460,7 @@ export class XiaohongshuPreview { private async persistSettings(): Promise { try { - const plugin = (this.app as any)?.plugins?.getPlugin?.('note-to-mp'); + const plugin = (this.app as any)?.plugins?.getPlugin?.('note2any'); if (plugin?.saveSettings) { await plugin.saveSettings(); } diff --git a/todolist.md b/todolist.md index a83363d..a6aaed7 100644 --- a/todolist.md +++ b/todolist.md @@ -8,7 +8,7 @@ ✅ - 标题取frontmatter的title属性。 ✅ - - 图片保存路径可配置,默认为/Users/gavin/note2mp/images/xhs。 + - 图片保存路径可配置,默认为/Users/gavin/note2any/images/xhs。 ✅ - 图片名取frontmatter的slug属性,如: slug: mmm,文章长图命名为mmm.png,如切为3张图片,则切图图片名按顺序依次为mmm_1.png,mmm_2.png,mmm_3.png ✅ @@ -76,6 +76,8 @@ xhslogin改造成MCP server部署在远端服务器上。插件中只要实现mcp client就可以了。 这样xhslogin项目没有必要整合到note2any中。 +4. 选中内容,右键发布到不同平台。发布时调用渲染,发布到特定的栏目中,比如网站中某个区块的“闪念集”。 + ## 问题 1. "发布平台"首次选“小红书”时,预览页面没有加载当前文章。 ✅ @@ -155,4 +157,8 @@ SOLVE:obsidian控制台打印信息,定位在哪里阻塞,AI修复。 自己写布局demo原型,让codex参考布局修改(原来元素美化的css可保留)。 demo原型可以手绘后,拍照让chatgpt生成,在此基础上自己修改。 +## 思路 +1. 网上图片模版,让AI快速生成css themes主题。快速套用。‼️ + **样式和功能必须结构,样式必须可以0基础,快速选择,让用户可以选择足够多样式(AI生成)。** + diff --git a/x b/x index 359667f..035d794 100644 --- a/x +++ b/x @@ -105,8 +105,8 @@ box-sizing: border-box; } -/* 若内部 section.note-to-mp 主题没有撑开,确保文本可见基色 */ -.wechat-article-wrapper .note-to-mp { +/* 若内部 section.note2any 主题没有撑开,确保文本可见基色 */ +.wechat-article-wrapper .note2any { background: transparent; }