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

Add plugin API renderSnippet, renderSnippets #9559

Closed

Conversation

Zuoqiu-Yingyi
Copy link
Contributor

  • Please commit to the dev branch
  • For contributing new features, please supplement and improve the corresponding user guide documents
  • For bug fixes, please describe the problem and solution via code comments
  • For text improvements (such as typos and wording adjustments), please submit directly

为插件添加一个用于设置动态样式的 API
Add an API for dynamic styling of the plugin

REF: #8036, siyuan-note/petal#19

@88250 88250 requested a review from Vanessa219 October 30, 2023 13:06
@Vanessa219
Copy link
Member

Vanessa219 commented Oct 31, 2023

这两个方法很类似,是不是导出一个就可以了?

如果是需要维护 snippet,是不是需要再添加增删改的 API?如果不是,是不是就不需要这些 API, 开发者自己维护好自己的代码就行。

还有具体的使用场景可以描述一下么?本身作为插件的可塑性就很强,为什么还要添加代码片段?

@Zuoqiu-Yingyi
Copy link
Contributor Author

这两个方法很类似,是不是导出一个就可以了?

可以只导出 renderSnippets


如果是需要维护 snippet,是不是需要再添加增删改的 API?如果不是,是不是就不需要这些 API, 开发者自己维护好自己的代码就行。

renderSnippets 配合 getSnippetsetSnippet 即可实现增删改查


还有具体的使用场景可以描述一下么?本身作为插件的可塑性就很强,为什么还要添加代码片段?

使用场景例如自定义字体列表,插件的样式文件 index.css 不适用于动态的样式(根据用户自定义设置生成的 CSS 片段),同时需要在导出时也需要应用这些样式,显然代码片段是一个理想方案

@Vanessa219
Copy link
Member

renderSnippets 提供出去的话会影响优先级顺序,按照使用场景也许添加一个叫 addSnippet 的更为合适。

@Zuoqiu-Yingyi
Copy link
Contributor Author

renderSnippets 提供出去的话会影响优先级顺序,按照使用场景也许添加一个叫 addSnippet 的更为合适。

影响优先级顺序是指?不同的 snippet 之间也有顺序吗

@Vanessa219
Copy link
Member

style 标签可能会高于 siyuanStyle。

@Zuoqiu-Yingyi
Copy link
Contributor Author

style 标签可能会高于 siyuanStyle。

目的就是为了影响最终呈现效果

@Vanessa219
Copy link
Member

这样的话使用 pulgin 里面的 style 也可以吧

@Zuoqiu-Yingyi
Copy link
Contributor Author

这样的话使用 pulgin 里面的 style 也可以吧

这个不能动态设置

@Vanessa219
Copy link
Member

但是 siyuanStyle 的顺便是不能随便调整的。这个不能被插件干扰了达到 目的就是为了影响最终呈现效果

@Zuoqiu-Yingyi
Copy link
Contributor Author

siyuanStyle 为啥要严防死守👀

@Vanessa219
Copy link
Member

如果优先加载的话,系统相关设置会失效。

@Vanessa219 Vanessa219 closed this Nov 3, 2023
@Zuoqiu-Yingyi
Copy link
Contributor Author

好吧,那我用自己实现的 renderSnippets

@Zuoqiu-Yingyi Zuoqiu-Yingyi deleted the feat/render-snippets branch November 3, 2023 04:28
@Vanessa219
Copy link
Member

Vanessa219 commented Nov 4, 2023

嗯嗯,十分感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants