-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
ProseMirror: allow setting order of marks #5481
Comments
Sorry to bother you again... Now the order is hardcoded, this makes it impossible to define the ordering of custom marks, since they always come last in the Can I suggest a PR? Like a score based sorting. Similar to this: |
I like the idea of a score. I was wondering if there could also be some sort of configurable schema instead. markOrder: [
'footnote',
'link',
'italic'
] But maybe that's too much. |
I've reopened the issue until we have a solution for this. |
The advantage of a score is that it lets plugin authors eyeball what priority their mark should have without having to know what other marks will be installed. In most cases consumers would then be able to just install plugins from different vendors and don't think or know about it. The disadvantage of a score, which is defined by plugin vendors, is that it takes away control from the consumer. I can't really think of an intuitive way to manually reorder them however... I mean the way it worked before (the order in the blueprint mattered), was easy if you knew about it, but on the other hand created an opportunity for developers to mess things up if they didn't know about it (also because the issue is invisible when not looking at the html, or listening to a screenreader which suddenly talks about 3 links instead of 1). So maybe a Or an explicit priority property for "each mark"? marks:
- link
- email
- italic
- bold
- type: footnote
priority: 1 # <- this shouldn't be split up Unrelated, but this could also open the doors to additional properties for the marks: marks:
- type: link
linktypes:
- page
query: page.children
- email
- italic
- bold
- type: footnote
priority: 1 # <- this shouldn't be split up
- type: highlight
colors:
- green
- yellow
- pink PS: Contrary to what I wrote before: if we do scores, the default marks should probably also be sorted by score (we shouldn't leave them on "100"). This would give developers a scale of what the score actually represents. (like, set |
Scores remind me of (probably old) Wordpress menu items. I think without any classification this just doesn't work. Plugin developers assign arbitrary score values not being able to oversee what configurations of other plugins and their arbitrary scores would conflict with their own picked number. And because of this mess a lot of conflicts can occur and one moved from a 1-10 score to a 1-100 score to a 1-1000 hoping bigger gaps could solve the issue. |
Well the classification would be the scale given by the core kirby marks. If you want to have your mark between "link" and "email", you need to have a score that puts you between them. If you end up with the same score as another plugin, chances are that it doesn't really matter. I first also thought about classification systems, but it seemed like it would end up as a "score with less freedom". Another approach could be a classification like "before: bold", "after: link", etc. But that would end immediately with "undefined behaviour" when 2 plugins want "before: link". Or to be precise, the order would probably depend on the name of the plugin folders, and I personally think that an arbitrary score chosen by developers who don't know each other is still a better heuristic than the folder name. In the end, "conflicts" aren't often a problem. I thought about this for some time, and the score still resulted the most flexible & comprehensible, even if the priority of marks at that point will probably, sometimes, be determined by the ego of developers (lots of "priority: 1"). |
I think such a "before and after" system makes a lot of sense because it defines the developer intent in a much more direct way. I don't see the problem of "order by folder name". After all you have the same issue if two plugins choose the same score. The result will in both cases have to be sorted arbitrarily. |
Opinions I guess. With a system like "before:link" a conflict to me seems inevitable, with numeric scores it's only possible. The most important part however, for me, is that we get some kind of control. And that the consumer has the last word on the order. |
Description
The order of nesting of the current prosemirror marks is unexpected: links are split up by formatting marks.
Expected behavior
Functional and focusable elements, such as links, should probably have a higher nesting priority than "decorative" marks
Screenshots
![image](https://private-user-images.githubusercontent.com/6684137/260449614-80872fc9-6222-4020-9e7a-a609e950bc38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTAyODAsIm5iZiI6MTczODk4OTk4MCwicGF0aCI6Ii82Njg0MTM3LzI2MDQ0OTYxNC04MDg3MmZjOS02MjIyLTQwMjAtOWU3YS1hNjA5ZTk1MGJjMzgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMDQ0NjIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGRkOWY1NDFjZDhmYjVjMWU0MzU2MDUxN2U0YzhkOGNlY2FkZjE1OWM3NGUwNWE3NjQ0OTgyNzQxMjFhYjQ5NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.xCQyMb0Fapq7G_ekG_-Pd_CBhiD3_NtwEXcVWjyxolc)
![image](https://private-user-images.githubusercontent.com/6684137/260449667-fa3b6482-67f8-458d-9fde-2611ec924368.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTAyODAsIm5iZiI6MTczODk4OTk4MCwicGF0aCI6Ii82Njg0MTM3LzI2MDQ0OTY2Ny1mYTNiNjQ4Mi02N2Y4LTQ1OGQtOWZkZS0yNjExZWM5MjQzNjgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMDQ0NjIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGZlOTExYzc2NTNkODQ2ODZmNTBkMmI0ZTkwODQ5NzIwZjQyNGM3Y2ExYWJjMGE2ZWU5YTc3OWI2MzBlMTAzNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.4hgur8Hzt8CP0QK0oDtyniHaI-JQpaDdiGOKSFAvbiM)
To reproduce
Your setup
Kirby Version
4.0.0.alpha-6 (but I guess it isn't new)
Additional context
The nesting order of prosemirror is given by the order of the schemas. In Kirby the order of the schemas is given by the order of the marks in the blueprint, and the default blueprint for a writer field puts the link and email marks at the end.
So this issue can be worked around by explicitly writing the order in your blueprint:
A fix could be to move those marks in the default blueprint to the start, but I understand that this isn't ideal UX wise, as it also moves the buttons to the front.
A more complete fix would be to uncouple schema and button order, for example by giving each mark some kind of "priority" score (either for the button order or the nesting order). However, this would have to be extended to custom writer marks too, as nesting order can be really important for custom tags.
This could also be solved with the new
toolbar
option in v4 (you can reorder the buttons there).The text was updated successfully, but these errors were encountered: