Skip to content

Inline element custom attribute #9038

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

Closed
WingDr opened this issue Aug 24, 2023 · 7 comments
Closed

Inline element custom attribute #9038

WingDr opened this issue Aug 24, 2023 · 7 comments
Assignees
Milestone

Comments

@WingDr
Copy link

WingDr commented Aug 24, 2023

给行内样式加入自定义属性

In what scenarios do you need this feature?

算是一个长期的请求吧,这个应该比较麻烦(出bug的可能性比较大),不着急实现。

目前所有的插件和主题想要识别特定的块基本只能靠自定义属性,但是很多行内样式包括备注、链接和块链接,都是没有(可以储存的)自定义属性的。Dark+主题甚至是在用style储存信息,虽然可以用但是很不规范,容易造成冲突。

如果实现了行内样式的自定义属性,可以做到对于行内样式进行分类和归属,包括备注甚至可以实现本体不能实现的重叠备注和同一样式多个备注(目前Dark+主题实现的),但是也不会污染到现有的方法内容,插件和主题只会在自定义属性内部操作

Describe the optimal solution

  • 使用更新dom更新行内样式的自定义属性,更新后的属性能体现在dom和kramdown里
  • 右键菜单中修改自定义属性
  • 自定义属性能够保存和重新读取
  • 能够通过SQL检索具有某种自定义属性的行内样式所在的块
  • 导出的时候可以不携带自定义属性
  • 如果能通过markdown(在原本的格式上添加一些带有特定标识符的内容)插入或者更新带有自定义属性的样式就更好了

Describe the candidate solution

No response

Other information

No response

@88250 88250 changed the title 给行内样式加入自定义属性 Inline element custom attribute Aug 25, 2023
@88250 88250 self-assigned this Aug 25, 2023
@88250
Copy link
Member

88250 commented Aug 25, 2023

行级元素只能通过更新块进行更新,所以还是使用 updateBlock 接口,有两种方式设置属性,一种是直接在 span 上带属性,另一种是使用 IAL 语法:

{
    "data": "foo <span data-type=\"text\" style=\"background-color: var(--b3-card-error-background); color: var(--b3-card-error-color);\" custom-data=\"test\">bar</span> baz",
    "dataType": "markdown",
    "id": "20230825093849-er9anul"
}

或者

{
    "data": "foo <span data-type=\"text\">bar</span>{: style=\"background-color: var(--b3-card-error-background); color: var(--b3-card-error-color);\" custom-data=\"test\"} baz",
    "dataType": "markdown",
    "id": "20230825093849-er9anul"
}

行级属性界面就不考虑提供了,这个能力主要由插件扩展发挥。

@88250 88250 added this to the 2.10.2 milestone Aug 25, 2023
88250 added a commit to 88250/lute that referenced this issue Aug 25, 2023

Verified

This commit was signed with the committer’s verified signature.
@88250 88250 closed this as completed Aug 25, 2023
@WingDr
Copy link
Author

WingDr commented Aug 25, 2023

emmm那么右键菜单的接口呢?可否支持?不然就不清楚想操作的是哪个元素了

@88250
Copy link
Member

88250 commented Aug 25, 2023 via email

@alvorithm
Copy link

Hi there! I would like to join in in asking for support of span inline attribute lists (IALs) as syntax in the editor, for the end user. It would greatly expand the uses of SiYuan if we could leverage the existing ability to parse and store Kramdown span ials.

This would be extremely useful for SiYuan to have qualified links, e.g. modifying the example from the official documentation, annotate a link as being a reference (vs. e.g. an example)

This *is*{:.underline} some `code`{:#id}{:.class}.
A [link](test.html){:rel='reference'} and some **tools**{:.tools}.

@88250 could you consider again enabling the parsing of span IALs in the editor? It would be fine for me if it is behind a feature flag (or if it requires a keybinding such as Ctrl-Alt-i).

For example: this would immediately solve my question on how to query to access inline memos, and even better because I could attach the :::DEP property strictly to the anchor span.

@88250
Copy link
Member

88250 commented May 23, 2024

@alvorithm Sorry, support for input in the editor is not considered, thank you.

@alvorithm
Copy link

Ok, understood.

Is there any other way for end users to annotate inline content so that the annotation can be later retrieved programmatically @88250 ?

@88250
Copy link
Member

88250 commented May 23, 2024

There is no interaction UI available for end-users, this is recommended through plugins, as mentioned earlier #9038 (comment)

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

No branches or pull requests

3 participants