question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

suggestion for non-core transform syntax

See original GitHub issue

slate-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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thesunnycommented, Dec 6, 2016

Worked on this last night including a unit test. Just need to clean up a little and will post a pull request.

0reactions
Soreinecommented, Dec 3, 2016

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. 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found