suggestion for non-core transform syntax
See original GitHub issueslate-edit-table
is an example of a Slate plugin that exports its own transforms.
The problem is that the transform syntax is rather ugly when using non-core transforms.
Here is an example to illustrate:
const {insertRow, moveSelectionBy} = slateEditTableInstance.transforms;
let transform = state.transform();
insertRow(transform);
transform.moveTo(state.selection);
moveSelectionBy(transform, 1, 0);
return transform.apply();
What I don’t like about the syntax is that
- because core transforms are chained, it helps to show that they are all part of the same transform
- non-core transforms lose this clarity
I would like to add a method, maybe something like call
that is just syntactic sugar for calling a non-core transform with the first argument being the transform
object and the remaining arguments being being the remaining arguments in the call.
The code below would then be equivalent to the code above but more readable.
const {insertRow, moveSelectionBy} = slateEditTableInstance.transforms;
return state.transform()
.call(insertRow)
.moveTo(state.selection)
.call(moveSelectionBy, 1, 0)
.apply();
What do you (a) think of the idea and (b) the name of the method call
. I can create a pull request for this if you think this is a good idea.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
XML Signature Syntax and Processing Version 1.1 - W3C
This document specifies XML digital signature processing rules and syntax. XML Signatures provide integrity, message authentication, ...
Read more >Migrating build logic from Groovy to Kotlin - Gradle User Manual
The syntax for configuring tasks is where the Groovy and Kotlin DSLs start to differ significantly. In Kotlin, Tasks are namespaced into the...
Read more >Using non-core EXSLT date functions with Xalan Java
Any suggestions for how to use this non-core EXSLT function? Here is my current template, still telling me that it's trying to call ......
Read more >How to lookup values in another table in the Query Editor?
I want to make a new column in this table that contains Region, by looking up the Customer # in another table that...
Read more >XML-Signature Syntax and Processing RFC 3075
XML-Signature Syntax and Processing (RFC 3075, March 2001; obsoleted by ... Internet community, and requests discussion and suggestions for improvements.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Worked on this last night including a unit test. Just need to clean up a little and will post a pull request.
That’s a good idea, and regarding the different raises issues with extending the Transform object, I think the initial
.call
solution is quite clean and simple to do. 👍