diff --git a/README.md b/README.md index a5bc5031..7c5cf2f9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This plugin promises that the basic functions will be free forever, and the foll > 🌹 Tips: This plugin is an upgraded version of the original 'Siyuan Note Publishing Tool' widget, which includes all the functions provided by the original widget, provides a convenient menu operation entry, and has carried out a series of problem fixes and experience optimizations. > -> In addition to [Release Preview] requires [Online Sharing] plugin support, the graph bed function requires [PicGo plugin] support, **Other functions do not need any other dependencies**, no need to download the previous widget, the plug-in is already built-in. +> In addition to [Extended Functions], **Other functions do not require any dependencies** , and there is no need to download the previous widget, which is already built-in in the plugin. ## Core Features @@ -51,6 +51,10 @@ the [Siyuan Note Publishing Tool Plugin Platform Adaptation Tracking Form](https For platform adaptation, please refer to [Latest Adaptation](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGIz1r94z9qvqUghDzd) +## Update history + +Please check [CHANGELOG](./CHANGELOG.MD) + ## FAQ * Q1:How to install the publishing tool plugin? Where can I find his entrance after installation? @@ -61,39 +65,35 @@ to [Latest Adaptation](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGI After the installation is complete, find the ✈️ icon on the top right toolbar, click the menu, and follow the corresponding instructions to use it. -‍ * Q2:After installing the publishing tool plugin, do I still need to install the widget? - A2:**unnecessary. ​** + A2:**unnecessary. ** The plugin version contains all the functions of the widget version. -‍ * Q3:I am not used to the operation of the new version, and I want to continue to use the previous widget through the plugin, is that possible? A3:**Yes.** - The plugin has a builtin bridge by default, which can invoke the widget through the plugin. This feature needs to be turned on in `Settings -> Use WidgetInvoke`​. + The plugin has a builtin bridge by default, which can invoke the widget through the plugin. This feature needs to be turned on in `Settings -> Use WidgetInvoke`. - Note 1: The plugin version uses the builtin menu of the plugin system, and the menu slot will be disabled when the widget version is activated via plugin. ​ + Note 1: The plugin version uses the builtin menu of the plugin system, and the menu slot will be disabled when the widget version is activated via plugin. Note 2: After opening the widget version, all functions of the plugin version will be disabled to avoid confusion. **We strongly recommend you to use the plugin version, because the plugin version will be the main version for long-term maintenance in the future, and the widget version is obsolete, and it is only used to fix problems and compatible with historical users.** -‍ -* Q4:I used to use `Custom JS Fragment`​ or add `WidgetInvoke`​ directly, do I still need to download the plugin now? +* Q4:I used to use `Custom JS Fragment` or add `WidgetInvoke` directly, do I still need to download the plugin now? A4:**Optional.** But we highly recommended to remove JS snippets and widgets to download the plugin version. - If you don't want to use the plugin version, you don't need to download it, just use the original `custom JS fragment`​ or add `widget`​ to continue using. + If you don't want to use the plugin version, you don't need to download it, just use the original `custom JS fragment` or add `widget` to continue using. - If you want to use the plugin version, then we strongly recommend that you delete the previously added `custom JS snippets`​ and `widgets`​, download the plugin version directly, and enable it. No other additional action is required. + If you want to use the plugin version, then we strongly recommend that you delete the previously added `custom JS snippets` and `widgets`, download the plugin version directly, and enable it. No other additional action is required. -‍ * Q5:Is it possible to migrate my historical configuration data items to the plugin? @@ -103,12 +103,10 @@ to [Latest Adaptation](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGI Note: The widget version configuration data import only supports `sy-p-cfg-v0.8.0.json` and `picgo.json`. -‍ * Q6:What should I do if the platform I need to publish is not provided by the publishing tool? * A6:Reference: [Platform Adaptation Plan](https://github.com/terwer/siyuan-plugin-publisher/blob/main/README_zh_CN.md#platform-adaptation-plan "Platform Adaptation Plan") - ## Donate If you approve of this project, invite me to have a cup of coffee, which will encourage me to keep updating and create diff --git a/README_zh_CN.md b/README_zh_CN.md index 7dff0310..a28272f8 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -10,7 +10,7 @@ > 🌹 温馨提示:这个插件是原 `思源笔记发布工具` 挂件的插件升级版,功能包含原有挂件提供的所有功能,同时提供了方便的菜单操作入口,并进行了一系列问题修复和体验优化。 > -> 除 [发布预览] 需要 [在线分享] 插件支持,图床功能 需要 [PicGo插件] 支持外,**其他功能无需其他任何依赖** ,无需下载之前的挂件,插件已经内置。 +> 除 [扩展功能] 外,**其他功能无需任何依赖** ,也无需下载之前的挂件,挂件在插件中已经内置。 ## 核心特色 @@ -44,6 +44,10 @@ 平台适配情况请查看请参考 [最新适配情况](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGIz1r94z9qvqUghDzd) +## 更新历史 + +请直接查看 [CHANGELOG](./CHANGELOG.md) + ## FAQ * Q1:发布工具插件怎么安装?安装之后在哪里找到他的入口? @@ -60,17 +64,11 @@ 插件版包含挂件版的所有功能。 -* Q3:我不习惯新版操作,想继续通过插件使用以前的挂件,可以吗? - - A3:**可以。** 注意:内测版不提供此功能。 - - 插件默认内置了一个桥接器,可以通过插件唤起挂件。该功能需要在 `设置 -> 使用挂件版` 开启。 - - 注意 1:插件版用插件系统内置的菜单,所有插件版唤起的时候菜单插槽会禁用。 +* Q3:我不习惯新版操作,想继续使用以前的挂件,可以吗? - 注意 2:开启挂件版之后会关闭插件版的所有功能,避免引起混淆。 + A3:**可以但是不推荐。** - **我们强烈推荐您使用插件版,因为插件版将是以后长久维护的主要版本,挂架版本已废弃,仅作为修复问题以及兼容历史用户。** + **我们强烈推荐您直接使用插件版,因为插件版将是以后长久维护的主要版本,挂架版本已废弃,仅作为修复问题以及兼容历史用户。** * Q4:我以前是通过 `自定义JS片段 ` 或者 直接添加 `挂件` 来使用的,现在还需要下载该插件吗? diff --git a/siyuan/i18n/en_US.json b/siyuan/i18n/en_US.json index 8171829d..299efcda 100644 --- a/siyuan/i18n/en_US.json +++ b/siyuan/i18n/en_US.json @@ -15,12 +15,5 @@ "save": "Save", "publishTo": "Publish to...", "publishNormal": "Publish normal", - "platformCnblogs": "Cnblogs", - "platformTypecho": "Typecho", - "platformWordpress": "WordPress", - "platformYuque": "Yuque", - "platformGithub": "Github", - "platformHexo": "Hexo", - "platformHugo": "Hugo", - "platformVitepress": "Vitepress" + "extendFunction": "Extended functionality" } \ No newline at end of file diff --git a/siyuan/i18n/zh_CN.json b/siyuan/i18n/zh_CN.json index ec27b43a..bb053dfc 100644 --- a/siyuan/i18n/zh_CN.json +++ b/siyuan/i18n/zh_CN.json @@ -15,12 +15,5 @@ "save": "保存", "publishTo": "一键发布", "publishNormal": "常规发布", - "platformCnblogs": "博客园", - "platformTypecho": "Typecho", - "platformWordpress": "WordPress", - "platformYuque": "语雀", - "platformGithub": "Github", - "platformHexo": "Hexo", - "platformHugo": "Hugo", - "platformVitepress": "Vitepress" -} \ No newline at end of file + "extendFunction": "扩展功能" +} diff --git a/siyuan/invoke/pluginInvoke.ts b/siyuan/invoke/pluginInvoke.ts index 0501f1f2..06bd82f3 100644 --- a/siyuan/invoke/pluginInvoke.ts +++ b/siyuan/invoke/pluginInvoke.ts @@ -23,12 +23,12 @@ * questions. */ -import PublisherPlugin from "../index"; -import { createAppLogger } from "../appLogger"; -import { showIframeDialog } from "../iframeDialog"; -import PageUtil from "../utils/pageUtil"; -import { IObject, showMessage } from "siyuan"; -import { isFileExists } from "../utils/utils"; +import PublisherPlugin from "../index" +import { createAppLogger } from "../appLogger" +import { showIframeDialog } from "../iframeDialog" +import PageUtil from "../utils/pageUtil" +import { IObject } from "siyuan" +import { isFileExists } from "../utils/utils" /** * 插件相关 @@ -47,12 +47,6 @@ export class PluginInvoke { public async showBlogDialog() { const pageId: string | undefined = PageUtil.getPageId() - // 检测是否安装博客插件 - const flag = await this.preCheckBlogPlugin() - if (!flag) { - return - } - // 临时开启预览权限 let isShared = false const attrs = await this.pluginInstance.kernelApi.getBlockAttrs(pageId) @@ -78,53 +72,23 @@ export class PluginInvoke { } public async showPicbedDialog() { - const flag = await this.preCheckPicgoPlugin() - if (!flag) { - return - } - const pageId: string | undefined = PageUtil.getPageId() const pageUrl = `${this.picgoPluginBase}/?pageId=${pageId}` showIframeDialog(this.pluginInstance, pageUrl) } public async showPicbedSettingDialog() { - const flag = await this.preCheckPicgoPlugin() - if (!flag) { - return - } - const pageId: string | undefined = PageUtil.getPageId() const pageUrl = `${this.picgoPluginBase}/setting?pageId=${pageId}` showIframeDialog(this.pluginInstance, pageUrl) } - private async preCheckPicgoPlugin() { + public async preCheckPicgoPlugin() { // 检测是否安装 picgo 插件 - const isInstalled = await isFileExists( - this.pluginInstance.kernelApi, - "/data/plugins/siyuan-plugin-picgo/plugin.json", - "text" - ) - if (!isInstalled) { - // 安装 - showMessage(`该功能需要Picgo插件支持,请在集市安装 [Picgo插件] 最新版`, 2000, "error") - return false - } - return true + return await isFileExists(this.pluginInstance.kernelApi, "/data/plugins/siyuan-plugin-picgo/plugin.json", "text") } - private async preCheckBlogPlugin() { - // 检测是否安装 blog 插件 - const isInstalled = await isFileExists( - this.pluginInstance.kernelApi, - "/data/plugins/siyuan-blog/plugin.json", - "text" - ) - if (!isInstalled) { - showMessage(`该功能需要在线分享插件支持,请在集市安装 [在线分享] 插件最新版`, 7000, "error") - return false - } - return true + public async preCheckBlogPlugin() { + return await isFileExists(this.pluginInstance.kernelApi, "/data/plugins/siyuan-blog/plugin.json", "text") } } diff --git a/siyuan/invoke/widgetInvoke.ts b/siyuan/invoke/widgetInvoke.ts index b2eca7e6..f80dde72 100644 --- a/siyuan/invoke/widgetInvoke.ts +++ b/siyuan/invoke/widgetInvoke.ts @@ -82,12 +82,7 @@ export class WidgetInvoke { const deviceType: DeviceTypeEnum = DeviceDetection.getDevice() this.logger.info(`you are from ${deviceType}`) - const flag = await this.preCheckSypWidget() - if (!flag) { - return - } - - const url = `/widgets/sy-post-publisher/#${pageUrl}` + const url = `/plugins/siyuan-plugin-publisher/#${pageUrl}` this.logger.info("will show iframe page =>", url) if (isReload) { @@ -99,19 +94,4 @@ export class WidgetInvoke { showIframeDialog(this.pluginInstance, url, w, h, noscroll) } } - - private async preCheckSypWidget() { - // 检测是否安装 发布挂件 - const isInstalled = await isFileExists( - this.pluginInstance.kernelApi, - "/data/widgets/sy-post-publisher/widget.json", - "text" - ) - if (!isInstalled) { - // 安装 - showMessage(`该功能需要发布工具挂件版支持,请在集市安装 [发布工具挂件版] 挂件 v0.9.0+ 以上版本`, 7000, "error") - return - } - return true - } } diff --git a/siyuan/topbar.ts b/siyuan/topbar.ts index d4ad3cc5..461f9ff1 100644 --- a/siyuan/topbar.ts +++ b/siyuan/topbar.ts @@ -25,7 +25,7 @@ import PublisherPlugin from "./index" import { icons } from "./utils/svg" -import { IMenuItemOption, Menu } from "siyuan" +import { IMenuItemOption, Menu, showMessage } from "siyuan" import PageUtil from "./utils/pageUtil" import HtmlUtils from "./utils/htmlUtils" import { createAppLogger } from "./appLogger" @@ -52,12 +52,13 @@ export class Topbar { public async initTopbar() { const quickMenus = await this.getQuickMenus() + const extendMenus = await this.getExtendMenus() const topBarElement = this.pluginInstance.addTopBar({ icon: icons.iconPlane, title: this.pluginInstance.i18n.publishTool, position: "left", callback: () => { - this.addMenu(topBarElement.getBoundingClientRect(), quickMenus) + this.addMenu(topBarElement.getBoundingClientRect(), quickMenus, extendMenus) }, }) } @@ -87,10 +88,58 @@ export class Topbar { submenus.push(submenu) } }) + + if (submenus.length == 0) { + return undefined + } return submenus } - private addMenu(rect: DOMRect, quickMenus: IMenuItemOption[]) { + private async getExtendMenus() { + const isBlogInstalled = await this.pluginInvoke.preCheckBlogPlugin() + const isPicgoInstalled = await this.pluginInvoke.preCheckPicgoPlugin() + this.logger.info(`isBlogInstalled=>${isBlogInstalled}`) + this.logger.info(`isPicgoInstalled=>${isPicgoInstalled}`) + + const extmenus = [] + if (isBlogInstalled) { + // 发布预览 + const extPreviewMenu = { + iconHTML: icons.iconEye, + label: this.pluginInstance.i18n.preview, + click: () => { + this.pluginInvoke.showBlogDialog() + }, + } + extmenus.push(extPreviewMenu) + } + if (isPicgoInstalled) { + // 图床 + const extPicBedMenu = { + iconHTML: icons.iconPicture, + label: this.pluginInstance.i18n.picbed, + click: async () => { + await this.pluginInvoke.showPicbedDialog() + }, + } + extmenus.push(extPicBedMenu) + + const extPicBedSettingMenu = { + iconHTML: icons.iconPicbed, + label: this.pluginInstance.i18n.settingPicbed, + click: async () => { + await this.pluginInvoke.showPicbedSettingDialog() + }, + } + extmenus.push(extPicBedSettingMenu) + } + if (extmenus.length == 0) { + return undefined + } + return extmenus + } + + private addMenu(rect: DOMRect, quickMenus: IMenuItemOption[], extendMenus: IMenuItemOption[]) { const menu = new Menu("publisherMenu") // 一键发布 @@ -98,6 +147,11 @@ export class Topbar { icon: `iconRiffCard`, label: this.pluginInstance.i18n.publishTo, submenu: quickMenus, + click: () => { + if (!quickMenus) { + showMessage("请先在 设置->发布设置配置平台并启用", 7000, "error") + } + }, }) // 常规发布 @@ -110,26 +164,23 @@ export class Topbar { }, }) - // 发布预览 + // 扩展功能 menu.addSeparator() menu.addItem({ - iconHTML: icons.iconEye, - label: this.pluginInstance.i18n.preview, + icon: `iconBazaar`, + label: this.pluginInstance.i18n.extendFunction, + submenu: extendMenus, click: () => { - this.pluginInvoke.showBlogDialog() + if (!extendMenus) { + showMessage( + "扩展功能需配合其他插件使用,目前支持在线分享、PicGo插件。请先下载在并启用扩展插件。", + 7000, + "error" + ) + } }, }) - // 图床 - // menu.addSeparator() - // menu.addItem({ - // iconHTML: icons.iconPicture, - // label: this.pluginInstance.i18n.picbed, - // click: async () => { - // await this.pluginInvoke.showPicbedDialog() - // }, - // }) - // 设置 menu.addSeparator() menu.addItem({ @@ -144,13 +195,6 @@ export class Topbar { this.widgetInvoke.showPublisherPublishSettingDialog() }, }, - // { - // iconHTML: icons.iconPicbed, - // label: this.pluginInstance.i18n.settingPicbed, - // click: async () => { - // await this.pluginInvoke.showPicbedSettingDialog() - // }, - // }, { iconHTML: icons.iconPreference, label: this.pluginInstance.i18n.settingGeneral, diff --git a/src/assets/README.md b/src/assets/README.md index d6cddd3e..ef4bb803 100644 --- a/src/assets/README.md +++ b/src/assets/README.md @@ -10,7 +10,7 @@ Publish [siyuan-note](https://github.com/siyuan-note/siyuan) articles to support 0.8.1- For the following versions, please see [this description](./README_0_8_1_zh_CN.md) -## 0.9.0 beta +## New widget beta Note: This version will be used with the plugin on one line. Please think about it before upgrading. This version is in closed beta, currently only available in Blog Park and Yuque, welcome to submit issues and PRs. @@ -45,35 +45,4 @@ If you approve of this project, please have a cup of coffee, which will encourag alipay -## Copyright Notice - -This work is open source in [GPLv3] (https://github.com/terwer/sy-post-publisher/blob/main/LICENSE). - -``` -/* - * Copyright (c) 2022, Terwer . All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Terwer designates this - * particular file as subject to the "Classpath" exception as provided - * by Terwer in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com - * or visit www.terwer.space if you need additional information or have any - * questions. - */ -``` - diff --git a/src/assets/README_zh_CN.md b/src/assets/README_zh_CN.md index db8f5da7..c8490ab5 100644 --- a/src/assets/README_zh_CN.md +++ b/src/assets/README_zh_CN.md @@ -6,13 +6,13 @@ 将 [思源笔记](https://github.com/siyuan-note/siyuan) 的文章发布到支持的平台的 **思源笔记挂件** -0.9.0+ 强烈建议配合 [发布工具](https://github.com/terwer/siyuan-plugin-publisher) 插件使用,体验更好哟~ +0.9.0+ 强烈建议配合 [发布工具](https://github.com/terwer/siyuan-plugin-publisher) 插件使用,体验更好~ 0.8.1- 以下版本请查看 [此说明](./README_0_8_1_zh_CN.md) -## 0.9.0 内测版 +## 新版内测版 -注意:此版本一行将配合插件使用。请想好之后再升级。此版本为内测版,目前仅博客园和语雀可用,欢迎提交 issue 和 PR 。 +注意:此版本以后将配合插件使用。请想好之后再升级。此版本为内测版,目前仅博客园和语雀可用,欢迎提交 issue 和 PR 。 目前已有功能 @@ -43,35 +43,4 @@
alipay -
- -## 版权声明 - -本作品以 [GPL V3](https://github.com/terwer/sy-post-publisher/blob/main/LICENSE) 形式开源 - -``` -/* - * Copyright (c) 2022, Terwer . All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Terwer designates this - * particular file as subject to the "Classpath" exception as provided - * by Terwer in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com - * or visit www.terwer.space if you need additional information or have any - * questions. - */ -``` + \ No newline at end of file