Repository navigation
Trigger transforms on siblings - #964
Conversation
| node.isAttached() && | ||
| // You shouldn't be able to transform these types of | ||
| // nodes. | ||
| !node.isImmutable() && |
There was a problem hiding this comment.
@trueadm - Transforms have to trigger on immutable nodes, otherwise they'll never be able to listen to changes. I.e. a DelightNode has to trigger when a sibling is removed
| (isTextNode(previousSibling) && | ||
| previousSibling.isSimpleText() && | ||
| previousSibling.getTextContent().endsWith(' ')); | ||
| const nextIsNullOrSpace = |
There was a problem hiding this comment.
Could isNullOrSpace be separate function?
There was a problem hiding this comment.
@acywatson - Really good idea. I'll move it NodeHelpers and add the LineBreak check that we have on WWW since surprisingly this function can come useful on a few plugins.
| init(); | ||
| const executeTransform = jest.fn(); | ||
| let hasBeenRemoved = false; | ||
| const listener = editor.addTransform(TextNode, (node) => { |
There was a problem hiding this comment.
nit: call it removeListener so it's more clear what's happening when you invoke it below.
| removeTransform(); | ||
| }); | ||
|
|
||
| it('on remove', async () => { |
There was a problem hiding this comment.
nit: more descriptive descriptions might make these tests a bit easier to understand.
There was a problem hiding this comment.
@acywatson - There's a describe above, this just complements it. So this reads like transforms on siblings > on remove
To prevent subtrees triggering transforms in #953 we first have to trigger transforms on siblings.
I'll follow up on these: