Code Monkey home page Code Monkey logo

Comments (21)

obgnail avatar obgnail commented on August 14, 2024 1

@DoubleW2w

需求已完成,已经支持在空白页调用此插件。代码在 dev

预计今晚发版。

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

@DoubleW2w

您好,感谢反馈。

这个插件很早了,当初设计的时候出于避险策略,做了【空白页不可使用此插件】的限制。

设计初衷是:我不清楚 Typora 是否可以凭空打开(没有任何挂载的目录)(举例:vscode),如果可以的话,我都不知道新文件该保存在哪个位置。

您觉得这种情况该如何处理呢?

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

@DoubleW2w

您好,感谢反馈。

这个插件很早了,当初设计的时候出于避险策略,做了【空白页不可使用此插件】的限制。

设计初衷是:我不清楚 Typora 是否可以凭空打开(没有任何挂载的目录)(举例:vscode),如果可以的话,我都不知道新文件该保存在哪个位置。

您觉得这种情况该如何处理呢?

typora是可以凭空打开的。如果你之前打开过typora,可以直接点击左上角,选择「新建窗口」,就是凭空打开的状态

image

不用知道新文件的保存位置,就像上面的图片一样,

你可以理解为我使用「文件模板」“填充”了页面,内容是“aaassa”。

你可以进行检测用户是否打开了文件夹,如果这个不好实现,文件就是属于未保存的状态。

本身 typora 也是基于用户是否打开目录以后,才去判断文件的保存状态(我猜的)

  • 用户打开了目录,此时新建文件,就默认保存在该目录,文件名应该 untitled.md
  • 用户没有目录,文件就处于未保存状态

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

@DoubleW2w

需求已完成,已经支持在空白页调用此插件。代码在 dev

预计今晚发版。

好的,我现在试用一波。很感谢大大的及时反馈。

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

复现过程:

  1. 克隆 dev 分支代码
  2. 备份 插件目录下的setting文件夹
  3. 覆盖整个 plugin 目录
  4. 备份的setting目录去覆盖回去

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

我现在的逻辑很简单:

  1. 若当前打开了文件,就获取当前文件的目录作为 dirpath。如果没有,走下一步
  2. 若当前有挂载目录,就使用挂载目录作为 dirpath。如果没有,走下一步
  3. 直接报错

您是希望怎么做呢?

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

我现在的逻辑很简单:

  1. 若当前打开了文件,就获取当前文件的目录作为 dirpath。如果没有,走下一步
  2. 若当前有挂载目录,就使用挂载目录作为 dirpath。如果没有,走下一步
  3. 直接报错

您是希望怎么做呢?

凭空打开的文件应该是不存在 dirpath 的吧

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

凭空打开的文件应该是不存在 dirpath 的吧

对,所以,凭空打开的 Typora 执行此插件会报错

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

想问一下,您觉得比较好的方案是什么呢?

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

应该是文件名限制了这个思路

想问一下,您觉得比较好的方案是什么呢?

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

我一开始以为这个功能是一种页面填充,后续,用户想保存在哪里,用户自己决定。

如果大大你一开始的设计是基于文件的话,那应该是没问题的。

如果要完成填充的话,文件名这个地方就和 填充就会冲突了。(文件名存在就说明文件已经被保存过了,而填充是没有的)

  1. 若当前打开了文件,就获取当前文件的目录作为 dirpath。如果没有,走下一步
  2. 若当前有挂载目录,就使用挂载目录作为 dirpath。如果没有,走下一步
  3. (这个时候是凭空打开的,应该不允许填写文件名,只可以用模块,包括模板中title变量是默认的 untitled)
  4. 直接报错

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

说的有不对的地方,还请谅解。.... 😭

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

@DoubleW2w

  1. 似乎市面上类似软件的模板功能,都是创建新文件,而不是填充内容的。
  2. 填充内容的方式好像更奇怪,如果此时页面有未保存的内容该怎么办?

我认为比较好的方式是:当走到第三步时(凭空打开状态),给一个弹窗,弹窗内容是生成的文字内容,让用户自己选择后续该如何操作。

但是这样又会出现一个问题,当 模板内容包含 {{ mountFolder }} 获取 当前文件的挂载目录,就会报错……

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

@obgnail

填充内容的方式好像更奇怪,如果此时页面有未保存的内容该怎么办?

对于未保存的内容而言,这些新增的内容是新增,就像是用户自己输入了 他自己自定义的一串文本。
但是对于格式上,确实会有影响,比如一些格式

---
这种格式
---

但严格来说也不算影响,因为用户硬要这么操作,本身就不符合规范,但是自由度交给用户了。
image

似乎市面上类似软件的模板功能,都是创建新文件,而不是填充内容的。

应该没有创建文件,它们的填充方式算是一种模板语法。

动画1

我也不知道算不算创建了一个文件,但是这个文件并没有保存,却可以使用 “自定义模板”。

{{ mountFolder }} 关于这个

因为之前的设计是基于文件名,如果要改的话,估计要做一波调整。

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

@DoubleW2w

你给的 vscode 操作图,这是 Snippets 功能呀。

这个功能在本项目也有一个类似的,slash_commands,你可以参考一下 readme

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

@obgnail

我给的图不是为了说明, html:5 这种用法。

我是为了说明

  1. 这算是创建了一个文件吗?
  2. 文件模板能否像这种形式一样,支持在 untitled.md 下支持使用。

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024
  1. 我注意到市面上叫做 【template / 模板】 的功能,都是【新建文件/页面】的逻辑。您这种在现有页面上新增内容的需求,更像是【snippets / 用户片段 / 代码模板】的功能。
  2. 如果您希望支持在 untitled.md 下新增自定义内容,可以使用 slash_comands 插件实现相同的功能。

2 (1)

from typora_plugin.

DoubleW2w avatar DoubleW2w commented on August 14, 2024

image

刚才试了一下,功能是符合需求的,配置上稍微麻烦了些而已。OK

从上面的图片,切换一下源码模式,然后再切换回来,就OK了

image

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

@DoubleW2w

新版本已经发布,已经修复了【需要切换一下源码模式】的 BUG,有兴趣的话可以升级试用一下

[[slash_commands.COMMANDS]]
enable = true
type = "snippet"
icon = "🧩"
hint = "示例片段"
keyword = "test"
callback = """
123
345

# asd

# asdasd


```js
console.log(111)
```

# asdasd

"""

3 (1)

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

如果您需要生成动态内容,可以将 type 改成 gen-snp,然后将 callback 改成回调函数的形式。

from typora_plugin.

obgnail avatar obgnail commented on August 14, 2024

此 issue 关闭,如有问题,麻烦在下面留言,或者另开 issue。

from typora_plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.