Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What do you want to do with plugins? #375

Open
Jocs opened this issue Jun 20, 2018 · 53 comments
Open

What do you want to do with plugins? #375

Jocs opened this issue Jun 20, 2018 · 53 comments
Labels
🐮 good first issue Good for new comers 🐼 plugin you can write a plugin of Mark Text to implement this feature in the future 🐳 help wanted Extra attention is needed

Comments

@Jocs
Copy link
Member

Jocs commented Jun 20, 2018

Hi, everyone

Because of love of markdown, I usually likes to write some documents or technical blog. Therefore, I decided to write a markdown editor. The first thing I planned to do was write an editor for myself use. By the way, open sourced to GitHub. Mark Text has received more and more attention, with more feature requests, in order to meet these needs, I began to do some more in-depth thinking on Mark Text, such as support for different editing modes, customized settings, auto-completion of picture paths, etc.

The 0.12.25 version was recently released, with support for sidebars and tabs, which makes it easier to edit projects and search for keywords in projects.

As the new functional requirements will always appear, the marktext volume (code size) will also become larger and larger. After the 1.0 release, we consider supporting plug-in so that we can write our own plug-ins to achieve the functions we want.. such as:

  • Upload Evernote
        
  • Custom theme
        
  • Turn marktext into a memo
        
    Of course, there are still many functions that plug-ins can implement. We also hope that everyone can provide some ideas or what do you want to use plug-ins to do something? This also makes it easier for us to better design plug-in APIs.

Finally, everyone is welcome to download Mark Text and experience it, although it is not yet perfect.

@Jocs Jocs added 🐮 good first issue Good for new comers 🐼 plugin you can write a plugin of Mark Text to implement this feature in the future labels Jun 20, 2018
@Jocs
Copy link
Member Author

Jocs commented Jun 20, 2018

related issues #282 #224 #174

@Jocs Jocs added the 🐳 help wanted Extra attention is needed label Jun 20, 2018
@stefnotch
Copy link
Contributor

stefnotch commented Jul 2, 2018

A bunch of plugin ideas:

  • A plugin that turns this
> [!Tip]
> You don't have to pay or buy any *Pro* version to have a *Dark Theme* in the Flax Editor.

into
image

  • A plugin that adds mermaid support to marktext.
  • A plugin that adds an "execute" button below every JavaScript code block.
  • A plugin that allows you to embed and display 3D models in a Markdown file

@rainfu
Copy link

rainfu commented Jul 16, 2018

关于插件机制,提几点建议

  1. 这个自研的editor已经做了相当多的工作👍🏻,我又研究了下代码,觉得可以将marktext扩展为标记式语言编辑器支持更多文本格式,核心解析markdown,扩展支持其它格式,这样会类似codemirror 有更大的社会价值及商业价值,后续我会开个分支研究下这个支持作者
  2. 现有parser代码仍有扩展上的困难,希望以marked为原型,以插件方式实现每个标记,让每个标记实现rule,renderer,activerender这样的抽象方法全局解析,这样每种标记文件仅需在配置中包括block与inline插件即可,Markdown基本标记可作为全局标记,每种标记文件可拥有私有扩展插件
  3. css尽量不要全局定义,交给插件本身,这样扩展会更轻松,比如sourcecode模式,完全无需codemirror实现,在插件中修改下CSS即可
  4. 插件化我不够专业,作者可以联系下minimajs的作者,我觉得他应该能提供更多建设性意见.

@Jocs
Copy link
Member Author

Jocs commented Jul 17, 2018

@stefnotch This feature maybe will support in the next version natively.(not in plugin).

@Jocs
Copy link
Member Author

Jocs commented Jul 17, 2018

这个自研的editor已经做了相当多的工作👍🏻,我又研究了下代码,觉得可以将marktext扩展为标记式语言编辑器支持更多文本格式,核心解析markdown,扩展支持其它格式,这样会类似codemirror 有更大的社会价值及商业价值,后续我会开个分支研究下这个支持作者

支持更多的文本格式?这是指支持更多的markdown 语法(标准和非标准的)吗?正如你下面说的,这个需要去扩展marked,我问了marked 维护者,他们暂时还没有支持 plugin 的打算,如果我们去做的话,和你理解的一样,需要考虑 rule,render,Lexical analysis,parser 等,所以一个marked 插件可能需要包含这些方面。

marktext 在编辑器内部的渲染不是依赖 marked的,是通过snabbdom 来进行渲染的,所以其是marked 只是提供了block 的解析(不包含inline语法)以及输出markdown 时候会用到(包含block 和 inline 语法)。

非常感谢你开分支,也真挚希望你为 marktext 贡献一份力量,有任何代码可优化的地方,以及问题都可以联系我?

现有parser代码仍有扩展上的困难,希望以marked为原型,以插件方式实现每个标记,让每个标记实现rule,renderer,activerender这样的抽象方法全局解析,这样每种标记文件仅需在配置中包括block与inline插件即可,Markdown基本标记可作为全局标记,每种标记文件可拥有私有扩展插件

正如上面所说,我也有这方面的打算,这样就能够更加方面的扩展markdown 语法,当然这不属于marktext 的插件,而应该是 muya 的插件。

css尽量不要全局定义,交给插件本身,这样扩展会更轻松,比如sourcecode模式,完全无需codemirror实现,在插件中修改下CSS即可

正如上面所说,marktext 的渲染是通过 snabbdom 来负责的,所以这个应该和插件没有太大关系,但是css 模块化管理更有利于维护。sourcecode mode 现在实现起来比较简单,就是使用的codemirror。最开始我是不打算做sourcecode mode 的,因为我当初认为这没什么价值,后来一个朋友用上marktext ,他希望有source code mode,然后我就加上了,优化的地方挺多的,比如现在不支持插入图片、快捷键、搜索等功能,不通过codemirror 单独来实现应该会更好,但是毕竟现在我把重点放在了realtime mode 上面。我还是不太明白你说的通过修改CSS 就可以支持sourcecode mode?

插件化我不够专业,作者可以联系下minimajs的作者,我觉得他应该能提供更多建设性意见.

谢谢,是https://github.com/lorry2018/minimajs 这个吗?

@rainfu
Copy link

rainfu commented Jul 17, 2018

第1点的意思跟marked无关。我是说marktext目前仅是一个markdown编辑器,但如果规划良好(实际已经完成了80%的工作),很容易做所有mark语言的编辑器,markdown仅是mark语言的一种,其它仅github就提供reStructedText,Textile等上十种格式,在实际应用中其它行业与公司也有自用的mark语言,marktext核心可专注 markdown,但提供接口让其它人进行扩展,类似以下这种方案,因为仅是示例,载图也仓促,见谅。

支持新格式

编辑器为每种文件格式配置一个设置文件,比如
{ type:'markdown',block:{block1,block2,...},inline:{inline1,inline2...}},{type:'textile',block:{....}} ,每个标记都按插件加载,这样子,用户就可以扩展出任何想要实现的 mark语言:)

@Jocs
Copy link
Member Author

Jocs commented Jul 17, 2018

@rainfu 我大概明白你的意思了,这需要去调研下相关 mark 语言的语法。你有这有的列表吗

@rainfu
Copy link

rainfu commented Jul 17, 2018

第3点我理解的是既然每个标记都已经得到解析,那么sourcecode模式以 snabbdom 解析的话实际就是换个class的模型,比如 h2在常规模式的class类同html,在sourcecode模式下将样式变化为codemirror指定的高亮语法,因为没研究codemirror,这点不知我理解的对不对,。

@rainfu
Copy link

rainfu commented Jul 17, 2018

@Jocs 本项目wiki页,在新建一个wiki的时候会有个编辑器其中包含一个 mark标记语言列表,实际上你不需要知道别人怎么实现他们,你只需要提供一个接口,象codemirror那样让用户有清晰的扩展动机,主版本更新也不会影响他们的代码即可。

@Jocs
Copy link
Member Author

Jocs commented Jul 17, 2018

@rainfu 你的理解是对的,只需要对 sourcecode mode 重写一套渲染,但不是简简单单改CSS,比如图片,在 realtime mode 下回实时渲染图片出来,在 sourcecode mode 下面就不会渲染 img 标签。重写一套渲染有个好处就是,可以很好地控制,比如可以添加插入图片、搜索等功能。也能更好的做到 realtime 和 sourcecode 切换时光标的保持位置不变。

@rainfu
Copy link

rainfu commented Jul 27, 2018

能不能开个plugin的分支,我会做些尝试工作,因为现在合并到master不太现实,对核心代码的更攻需要与你反复的沟通与优化,目前来讲也不宜太激进

我想可以这样,

  1. 定义主要扩展点与核心服务
  2. 实现菜单的插件化,这个不难,但会重新定义目前menu里的所有菜单以便在插件加载完后生成所有menuitem更灵活
  3. 实现文件格式的插件化,支持多种文件格式,不同文件格式加载不同的block与inline插件,这是核心内容,看能不能直接parse到h函数,rule,parse,render,sourcerender分解到每个插件

@Jocs
Copy link
Member Author

Jocs commented Jul 27, 2018

@rainfu 你可以先在自己的仓库实践一下你的方案,我也可以直接到你 fork 的仓库看代码,等最终确定方案了,就可以开始开一个分支插件分支了

@rainfu
Copy link

rainfu commented Jul 28, 2018

我已经提交了一部分实验代码,代码位置:https://github.com/rainfu/marktext/tree/develop 目标仍旧是希望marktext通过插件化实现多文件格式支持,插件易于第三方扩展。目前完成菜单相关部分的内容

菜单相关

  1. 菜单插件化
    • 菜单的任意位置,包括一级菜单均可扩展
    • 扩展的菜单可精确指定父菜单,同级排序,指定位置
  2. 对菜单的扩展点进行初步规划
    • 文件格式在菜单中的扩展
      - 新文件格式在文件>新建文件建立子菜单
      - 新文件格式在帮助>syntax中建立子菜单
      - 新文件格式的block,inline的菜单将在切换时动态生成
    • 文件来源在菜单中的扩展
      - 通过第三方网盘dropbox等获得文件时在文件》打开网盘》建立子菜单
    • 设置的扩展
      - 插件扩展>设置中的子级菜单对设置进行完整控制
      - 插件扩展>设置>通用>配置内容添加设置项

文件格式相关

这一部分处于探索阶段,,目前对可能处理的核心parser做了些标记,对多文件格式支持的plugin做了些规划,规划的plugins分为二级目录,包括 mime,block,inline,cloud等子目录,minimajs也需要做些扩展工作,已提交至作者处,希望你研究一下这个预案是否可行,会触到什么雷,3ks。

@pici-masp
Copy link

Export to Gmail Draft

Using marktext to copy/paste as html into other web apps is super nice. Sadly sometimes other web apps like Gmail do not allow pasting html into their mail editor. In case of Gmail i found no simple solution to this problem without using bloated chrome extension or cloud services.

Gmail Api

With google's gmail api and nodejs client lib [github] [npm] one could easily develop a plugin to create a draft from marktext.

Export Plugins

Specifically export plugins could improve working with markdown drastically. Even if other web apps accept copy/paste html, an export could speed up and improve the experience. Like Export to Gmail Draft could open the gmail draft in your browser after export is done.

@Jocs
Copy link
Member Author

Jocs commented Sep 11, 2018

@MarcusSpecht Very good idea, exporting to gmail is also very suitable for plugins. When designing the plugin system, I will take this usage scenario into consideration, and also provide plugin APIs and examples.

@Jocs
Copy link
Member Author

Jocs commented Sep 11, 2018

@MarcusSpecht We also need the help of the designer, because we feel that marktext can be greatly improved in terms of interactive experience and appearance.

@saivan
Copy link

saivan commented Oct 5, 2018

I would add a plugin to color text, maybe something like:

This text can be color(#42c8f4)(colored blue perhaps) 

@saivan
Copy link

saivan commented Oct 5, 2018

Maybe we could have an inline youtube embedder as well 🤤
why not embed desmos graphs as well, geogebra files, why not!

Really take markdown to the next level.

@Jocs
Copy link
Member Author

Jocs commented Oct 5, 2018

@saivan But GFM or CommonMark Spec do not support colored text?

@saivan
Copy link

saivan commented Oct 6, 2018

Well, it depends on the spec, sure - but pandoc's spec supports html tags inline. So colored text could be achieved with a span tag with a css attribute set haha. But isn't the whole point of a plugin to enable us to add functionality that we might want for ourselves?

@stefnotch
Copy link
Contributor

stefnotch commented Oct 7, 2018

Academia plugin

Most academic publications have a rather similar format.

  • Pages with a header & footer
  • 2 columns of text
  • 12px Times New Roman
  • Numbered titles
  • Every picture has some text below it such as Figure 7: Illustrates the fact that this is an academic picture
  • References
  • etc.

A plugin could provide a number of those features to make creating dull super interesting academic publications easier than ever.

@saivan
Copy link

saivan commented Oct 9, 2018

Haha academic publications are as dull as a rainy day super interesting, I can't agree more!

@IssueHuntBot
Copy link

@BoostIO funded this issue with $10. See it on IssueHunt

@kmsmgsh
Copy link

kmsmgsh commented Nov 8, 2018

支持程序运行的plugin?如果太外行还请勿怪。。不知道这不是插件的工作范畴。

比如说支持python或者R。在代码chunk多一个运行按钮,然后就能在编辑器内书写和运行代码示例。
其中比如说R,可以用ServR包开一个R服务器进行交互,然后把代码chunk的东西传过去,然后用knitr包把结果变成md代码传回来,这样不影响主程序渲染逻辑。

@Jocs
Copy link
Member Author

Jocs commented Nov 8, 2018

@kmsmgsh 运行代码的功能确实不错?但是在markdown 编辑器中是用的多吗?

@kmsmgsh
Copy link

kmsmgsh commented Nov 9, 2018

@Jocs 多不多我不敢下结论,但是可以在以下环节使用:
可复现数据分析报告。
脚本语言(python,r,甚至js等等?)课程作业
代码文档。
技术博客等。
涉及数据分析图像文章:调用plot命令沉浸感和效率远高于在自己熟悉的分析软件里画好图,保存,再插入。
可以说只要涉及到高级语言的markdown使用环境,能运行代码就十分实用。而且这几个场景我个人感觉也是markdown主要发力的场景。

现有工具:我个人知道的还是以语言工具为主,python的jupyter notebook和R 的R markdown。
前者需要运行anaconda还有开服务器非常麻烦,而且是.ipynb使用和管理也不方便,虽然开发能力和交互式分析能力很强,但是书写能力就有点。。。后者的话不支持所见即所得的书写体验,缺乏沉浸感。

p.s. 对于我个人最想要的功能还是基于bibtex的参考文献功能,拿markdown写文献综述和算法说明(以及论文)比用latex爽很多!但是这个功能前面的大哥有提过所以就不重复提啦。。

@IssueHuntBot
Copy link

@issuehuntfest has funded $20.00 to this issue. See it on IssueHunt

@grahamannett
Copy link

Is there any chance this will ever be possible? It seems like from #1390 and others that javascript is disabled in html blocks, but it would really be useful if we can have some way to do a plugin or something so that we can do user defined things, for instance read csv file into table or whatever.

I understand theres probably some security issues to this but at least if you are given an option to do it at your own risk then it seems reasonable

@Jocs
Copy link
Member Author

Jocs commented Feb 6, 2020

@grahamannett The plugin we are talking about may not be executing JavaScript code in the html block. Instead, we will install a plugin package to enhance the functionality of Mark Text.

Any issue involving an XSS attack may not be easy to let go.

@bela127
Copy link

bela127 commented Mar 11, 2020

a simple drawing plugin would be perfect...
Like this markdown editor.

@bela127
Copy link

bela127 commented Mar 11, 2020

and the possibility to customise the passing process, would be helpful in a plug-in system.
for example registration of a plugin for:

  • a special character sequence
  • a start end end sequence
    the plugin then can process:
  • the line after start
  • or the hole text between start and end
    and outputs:
  • a virtual DOM element for display

@bela127
Copy link

bela127 commented Mar 11, 2020

the special sequences should allow variable placeholders
the definition of the image size like this:

![](https://miro.medium.com/max/1452/1*JDAuBt3aS9mz3aQQ7JKYKA.png =250x100)
![](https://miro.medium.com/max/1452/1*JDAuBt3aS9mz3aQQ7JKYKA.png =250x)

is used in some markdown editors.

with the above plugin proposal one could simply return a DOM element with the image of the appropriate size.
basically every possible markdown syntax could be implemented in this manner.

The registration for the plugin
![](https://miro.medium.com/max/1452/1*JDAuBt3aS9mz3aQQ7JKYKA.png =250x)
would be:
![$ALT]($URL =$SIZEXx)
![$ALT]($URL =$SIZEXx$SIZEY)

@bela127
Copy link

bela127 commented Mar 11, 2020

by the way, nice work, your plans of going international are working, marktext reached Germany ;)

@Likivik
Copy link

Likivik commented Mar 31, 2020

This: #549 - Support relative image directory 😄

by the way, nice work, your plans of going international are working, marktext reached Germany ;)

And Russia too 😉

@brainchild0
Copy link
Contributor

brainchild0 commented May 3, 2020

Planning ahead for plugin support is definitely wise. It ensures that a clean interface is available for plugin development to begin.

Regarding earlier comments, I offer the following two observations:

  1. Apparently, the demand is high for support for cloud-based notes solutions. Most of the functionality of editing files versus notes is the same, in fact, some simple solutions are achieving notes storage simply through file synchronization, with each note being simply a file. It appears to me that rather than considering how to create a plugin that would "turn marktext into a memo", it is wiser to design the core application with a pluggable model for backend storage, with file support available of course out of the box.

  2. A very common request is to support extensions to Markdown parsing and formatting. An editor with a diverse user base should not support every possible extension that someone has requested. Rather, the core application should support a few basic dialects, with pluggable support for further features.

Considering the above, it would be valuable to move toward a well-planned plugin interface that includes flexible support for both different backend storage types and further extensions to the Markdown language.

@weeman1337
Copy link

Some kind of plugin interface to hook into markdown would be handy.
A specific example for me would be "include UML diagrams".

There is an issue with an ongoing discussion about the solution.
Different users may prefer other UML backends.
With plugins the users a free to choose.

From the usability side I could imagine:

  • Hooking into code blocks with plantuml (or other)
  • A toggle button next to the code block to switch from code to visualisation and vice versa

@BrandoZhang
Copy link

BrandoZhang commented Sep 20, 2020

I am wondering if there is an API for customizing the sidebar?
For example, after enabling plugins, the corresponding plugin icon will be shown (like VS Code) on the most left and control the functionalities in the sidebar's content.
--- Update at 2020-10-18 15:08:58 ---
If it is possible, the sidebar's icons can be customized in a drag-and-drop arrangement.

@gilbertohasnofb
Copy link

gilbertohasnofb commented Oct 29, 2020

I know that custom themes have been requested, but some simple tweaks to the current themes would also be appreciated. For instance, Ulysses Light centralises headings while the other themes don't; the shape of the toggle boxes are different in different themes (some are square, others are circle), etc.

Another plugin that would be super useful is a table of content generator, which is implemented in other Markdown editors (see https://stackoverflow.com/questions/11948245/markdown-to-create-pages-and-table-of-contents). Basically, all headers would be gathered and hyperlinked into a table of contents at the top of the file.

@varlevi
Copy link

varlevi commented Nov 23, 2020

A plugin that automatically creates a table of contents for a file would be really nice. You could use something like markdown-toc to accomplish this probably.

@phileastv
Copy link

phileastv commented Mar 13, 2021

Being curently in the process of writing a screenplay, I can tell you that MarkText has a good potential to being a simple screenplay writing ecosystem - currently domiated a lot by propreitary softwares.

That would probably be features as :

  • Supporting Fountain, a Markdown-like syntax made for screenplays
  • Autocomplete when writing common screenplay lines (like INT. - DAY, INT. - NIGHT)
  • Autocomplete the name of the characters by a predefined list
  • Correct layout when writings dialogs

If a plugin architecture is realeased, I'll see if my little development skills are enough to develop a tool like this 😃

@NewUserHa
Copy link

The main editor should be able to be used as a LOCAL editor.

all the uploading and downloading features should be moved into the plug-in as optional features.

@brainchild0
Copy link
Contributor

I agree with the sense of the comment given by @NewUserHa, that the core application currently carries a great deal of bloat, much of it for connection to specific services. Moving service-specific functionality to extensions, and leaving the core application to handle standard formatting features, may be a wise strategy.

This was referenced Dec 29, 2021
@fatebugs
Copy link

Describe your feature request
能否在MacOS版本中加入uPic图床上传的功能,这样就能使用阿里云oss和别的oss了

What problem does this feature solve? [optional]
解决了现有免费只能上传5MB的窘境

这是uPIC的官网:https://blog.svend.cc/upic/

image
image

@derkrasseleo
Copy link

Would it be possible to support excalidraw drawings like Obisidian does?

@zhuzongzhen
Copy link

希望能够支持markmap的插件,在marktext中科院内嵌进去, 写法类型下面

```markmap
# test

## Links
- <https://markmap.js.org/>
- [GitHub](https://github.com/gera2ld/markmap)

## Related
- [coc-markmap](https://github.com/gera2ld/coc-markmap)
- [gatsby-remark-markmap](https://github.com/gera2ld/gatsby-remark-markmap)
` ` `

效果图如下:
image

@FBemf
Copy link

FBemf commented Apr 7, 2022

I'd be very interested writing a plugin that adds some basic knowledge base features such as [[wiki links]], backlinks, and tags. Marktext is an excellent markdown editor and it's only a couple features away from being perfect for maintaining a simple knowledge base. These features are probably out of scope for Marktext, but at the same time they're relatively small features, which makes them ideal for a plugin.

@mkasprz
Copy link

mkasprz commented Mar 24, 2023

Hi.

Have You considering using Obsidian API (possibly: https://github.com/obsidianmd/obsidian-api)? I imagine it may require some work and probably also creating some "dummy" methods or classes for example, but this way quite a lot of Obsidian plugins could be available right away. And I think quite a lot of them are published under MIT license.

And, by the way, thank You for all Your work and all put into this project!

@addlistener
Copy link

addlistener commented Aug 31, 2023

Hi @kmsmgsh @grahamannett , do you still care about script execution in markdown? We feel the same and already have a demo at https://union.anyscript.dev/. We want to make it a pluggable markdown editor in the future but would love to have a conversation to gain more insights. And here's my proposal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐮 good first issue Good for new comers 🐼 plugin you can write a plugin of Mark Text to implement this feature in the future 🐳 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests