Skip to content

Commit

Permalink
feat: 新增扩展菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 1, 2023
1 parent 123a2d2 commit 6fb007d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 198 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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?
Expand All @@ -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`.

<u>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. </u>
<u>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. </u>

<u>Note 2: After opening the widget version, all functions of the plugin version will be disabled to avoid confusion.</u>

**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?

Expand All @@ -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
Expand Down
18 changes: 8 additions & 10 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

> 🌹 温馨提示:这个插件是原 `思源笔记发布工具` 挂件的插件升级版,功能包含原有挂件提供的所有功能,同时提供了方便的菜单操作入口,并进行了一系列问题修复和体验优化。
>
> [发布预览] 需要 [在线分享] 插件支持,图床功能 需要 [PicGo插件] 支持外,**其他功能无需其他任何依赖**无需下载之前的挂件,插件已经内置
> [扩展功能] 外,**其他功能无需任何依赖**也无需下载之前的挂件,挂件在插件中已经内置
## 核心特色

Expand Down Expand Up @@ -44,6 +44,10 @@

平台适配情况请查看请参考 [最新适配情况](https://terwergreen.feishu.cn/share/base/view/shrcnWT2IGIz1r94z9qvqUghDzd)

## 更新历史

请直接查看 [CHANGELOG](./CHANGELOG.md)

## FAQ

* Q1:发布工具插件怎么安装?安装之后在哪里找到他的入口?
Expand All @@ -60,17 +64,11 @@

插件版包含挂件版的所有功能。

* Q3:我不习惯新版操作,想继续通过插件使用以前的挂件,可以吗?

A3:**可以。** 注意:内测版不提供此功能。

插件默认内置了一个桥接器,可以通过插件唤起挂件。该功能需要在 `设置 -> 使用挂件版` 开启。

<u>注意 1:插件版用插件系统内置的菜单,所有插件版唤起的时候菜单插槽会禁用。</u>
* Q3:我不习惯新版操作,想继续使用以前的挂件,可以吗?

<u>注意 2:开启挂件版之后会关闭插件版的所有功能,避免引起混淆。</u>
A3:**可以但是不推荐。**

**我们强烈推荐您使用插件版,因为插件版将是以后长久维护的主要版本,挂架版本已废弃,仅作为修复问题以及兼容历史用户。**
**我们强烈推荐您直接使用插件版,因为插件版将是以后长久维护的主要版本,挂架版本已废弃,仅作为修复问题以及兼容历史用户。**

* Q4:我以前是通过 `自定义JS片段 ` 或者 直接添加 `挂件` 来使用的,现在还需要下载该插件吗?

Expand Down
9 changes: 1 addition & 8 deletions siyuan/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
11 changes: 2 additions & 9 deletions siyuan/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,5 @@
"save": "保存",
"publishTo": "一键发布",
"publishNormal": "常规发布",
"platformCnblogs": "博客园",
"platformTypecho": "Typecho",
"platformWordpress": "WordPress",
"platformYuque": "语雀",
"platformGithub": "Github",
"platformHexo": "Hexo",
"platformHugo": "Hugo",
"platformVitepress": "Vitepress"
}
"extendFunction": "扩展功能"
}
56 changes: 10 additions & 46 deletions siyuan/invoke/pluginInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/**
* 插件相关
Expand All @@ -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)
Expand All @@ -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")
}
}
22 changes: 1 addition & 21 deletions siyuan/invoke/widgetInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
}
Loading

0 comments on commit 6fb007d

Please sign in to comment.