Skip to content
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

Fix insertNodes and insertParagraph #5002

Merged
merged 73 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
45f23de
helping comments
GermanJablo Sep 13, 2023
dadfb30
first version splitBlock
GermanJablo Sep 13, 2023
539ec8f
splitBlock 2
GermanJablo Sep 13, 2023
79263fb
fix insertNodes
GermanJablo Sep 14, 2023
acee2ca
Merge 'main' into insertNodes
GermanJablo Sep 14, 2023
dbe5b51
make $isBlock an internal function
GermanJablo Sep 14, 2023
eddff37
WIP codehighlight
GermanJablo Sep 14, 2023
e18b4ed
WIP codehighlight
GermanJablo Sep 14, 2023
b01827a
fix insertNewAfter of CodeNode. Temporal highlight alg
GermanJablo Sep 15, 2023
815831a
plain text and code WIP
GermanJablo Sep 15, 2023
a8ecdb5
I DID IT!
GermanJablo Sep 15, 2023
9321873
simplify insertLineBreak
GermanJablo Sep 15, 2023
3c3adbe
collocate splitBlock inside insertParagraph
GermanJablo Sep 15, 2023
a5c1f06
solve failed tests on code blocks
GermanJablo Sep 15, 2023
76021ad
fix selection bug
GermanJablo Sep 15, 2023
5253c3f
revert clipboard improvement. Not ready yet :(
GermanJablo Sep 15, 2023
f908afc
temporal revert insertRawText. Fixes insertNodes. Refactor InsertPara…
GermanJablo Sep 16, 2023
a5780cc
refactor
GermanJablo Sep 16, 2023
30ac722
Fix insertNodes
GermanJablo Sep 17, 2023
9635b2b
fix html import
GermanJablo Sep 17, 2023
3e27cf7
fixed many tests
GermanJablo Sep 17, 2023
23bdfa3
100% unit test pass!
GermanJablo Sep 18, 2023
650912e
fix bug with inline nodes
GermanJablo Sep 18, 2023
a3eff0d
fix indent on code
GermanJablo Sep 18, 2023
6770bbc
Fix enter at beggining of link
GermanJablo Sep 18, 2023
b34a521
100% unit test pass!
GermanJablo Sep 18, 2023
46d6f20
fix inserparagraph on codenode on tabs
GermanJablo Sep 18, 2023
61b2954
going back to merBlock strategy! (but differently)
GermanJablo Sep 19, 2023
c75a97b
100% unit test pass! and some e2e tests more pass
GermanJablo Sep 19, 2023
7126830
fix some tests
GermanJablo Sep 19, 2023
b2ac2c8
fix bugs
GermanJablo Sep 19, 2023
ce95063
fix convert multiple blocks to codenode
GermanJablo Sep 19, 2023
240b675
fix several e2e tests
GermanJablo Sep 19, 2023
05d742d
fix unit tests
GermanJablo Sep 19, 2023
13f2ecf
fix bugs
GermanJablo Sep 19, 2023
2f550f2
Merge remote-tracking branch 'origin/main' into insertNodes
GermanJablo Oct 11, 2023
16e410e
Merge remote-tracking branch 'origin/main' into insertNodes
GermanJablo Oct 11, 2023
f6a763f
revert invariant of PR 5066
GermanJablo Oct 11, 2023
2e854d5
fix integrity (ES imcompability)
GermanJablo Oct 11, 2023
525e8e7
fix tests
GermanJablo Oct 16, 2023
f9fea22
fix type error
GermanJablo Oct 16, 2023
a4f87a1
merge from main
GermanJablo Oct 16, 2023
4d10528
Merge 'origin/main' into insertNodes
GermanJablo Oct 16, 2023
ae2634d
revert code changes
GermanJablo Oct 16, 2023
718af1e
temporal gitignore change
GermanJablo Oct 16, 2023
6ca9021
temporal gitignore
GermanJablo Oct 16, 2023
f280884
RE-WRITE FROM SCRATCH, SIMPLIFIED
GermanJablo Oct 17, 2023
48a9bb3
decouple insertNodes from code.insertNewAfter. insertnodes WIP for code
GermanJablo Oct 18, 2023
3fc0cb9
finished code case
GermanJablo Oct 18, 2023
eb607a1
100% unit test pass! 10 e2e tests fails
GermanJablo Oct 18, 2023
c84e4cb
fix code bugs
GermanJablo Oct 18, 2023
f283828
fix heading insertnewafter
GermanJablo Oct 19, 2023
591032a
fix heading insertnewafter 2
GermanJablo Oct 19, 2023
fc01494
ignore inline styles
GermanJablo Oct 19, 2023
4deb414
fix heading insertnewafter 3
GermanJablo Oct 19, 2023
fefc545
fix shift + enter on codenode
GermanJablo Oct 19, 2023
7de20be
fix insert/paste multiline on code
GermanJablo Oct 19, 2023
396e313
fix test "can wrap post-linebreak..."
GermanJablo Oct 19, 2023
d695f97
Merge remote-tracking branch 'origin/main' into insertnodes2
GermanJablo Oct 19, 2023
e81e054
revert gitignore
GermanJablo Oct 19, 2023
c086bd3
Merge branch 'insertNodes' of https://github.com/GermanJablo/lexical …
GermanJablo Oct 19, 2023
0641539
fix import codenode
GermanJablo Oct 19, 2023
7f29dee
fix again ctrl+O command on mac
GermanJablo Oct 19, 2023
d68853f
test.fixme
GermanJablo Oct 19, 2023
3c6a91e
fix flow
GermanJablo Oct 19, 2023
34a1d47
restore insertLineBreak(selectStart) on LexicalSelectionHelpers.test.ts
GermanJablo Oct 19, 2023
5dc6563
fix test "Can add new lines before..."
GermanJablo Oct 19, 2023
6075bdb
revert gitignore
GermanJablo Oct 19, 2023
87e6509
remove toThrow from test node
GermanJablo Oct 19, 2023
c3e9626
replace forEach with for... of
GermanJablo Oct 26, 2023
1c0b205
fix uppercase. Add explicit return type
GermanJablo Oct 26, 2023
0f30d68
add brackets to if blocks with one statement
GermanJablo Oct 26, 2023
e04bb0f
fixme - flaky test
GermanJablo Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/lexical-clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ export function $insertDataTransferForRichText(
if (text != null) {
if ($isRangeSelection(selection)) {
const parts = text.split(/(\r?\n|\t)/);
const partsLength = parts.length;
for (let i = 0; i < partsLength; i++) {
if (parts.at(-1) === '') parts.pop();
GermanJablo marked this conversation as resolved.
Show resolved Hide resolved
for (let i = 0; i < parts.length; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At one point there was a test that failed if an empty (unnecessary) string was added last.

const part = parts[i];
if (part === '\n' || part === '\r\n') {
selection.insertParagraph();
Expand Down
28 changes: 18 additions & 10 deletions packages/lexical-code/src/CodeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
ElementNode,
$isTabNode,
$createTabNode,
$isTextNode,
} from 'lexical';
import {
$isCodeHighlightNode,
Expand Down Expand Up @@ -254,14 +255,10 @@ export class CodeNode extends ElementNode {
// If the selection is within the codeblock, find all leading tabs and
// spaces of the current line. Create a new line that has all those
// tabs and spaces, such that leading indentation is preserved.
const anchor = selection.anchor;
const focus = selection.focus;
const {anchor, focus} = selection;
const firstPoint = anchor.isBefore(focus) ? anchor : focus;
const firstSelectionNode = firstPoint.getNode();
if (
$isCodeHighlightNode(firstSelectionNode) ||
$isTabNode(firstSelectionNode)
) {
if ($isTextNode(firstSelectionNode)) {
let node = getFirstCodeNodeOfLine(firstSelectionNode);
const insertNodes = [];
// eslint-disable-next-line no-constant-condition
Expand All @@ -285,10 +282,21 @@ export class CodeNode extends ElementNode {
break;
}
}
if (insertNodes.length > 0) {
selection.insertNodes([$createLineBreakNode(), ...insertNodes]);
return insertNodes[insertNodes.length - 1];
}
const split = firstSelectionNode.splitText(anchor.offset)[0];
const x = anchor.offset === 0 ? 0 : 1;
const index = split.getIndexWithinParent() + x;
const codeNode = firstSelectionNode.getParentOrThrow();
const nodesToInsert = [$createLineBreakNode(), ...insertNodes];
codeNode.splice(index, 0, nodesToInsert);
const last = insertNodes.at(-1);
if (last) last.select();
else if (anchor.offset === 0) split.selectPrevious();
else split.getNextSibling()!.selectNext(0, 0);
}
if ($isCodeNode(firstSelectionNode)) {
const {offset} = selection.anchor;
firstSelectionNode.splice(offset, 0, [$createLineBreakNode()]);
firstSelectionNode.select(offset + 1, offset + 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insertParagraph calls insertNewAfter, and insertNodes calls insertParagraph. To simplify things and avoid bugs and circular references (very common while refactoring), CodeNode's insertNewAfter no longer depends on insertNodes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So add what point would you draw the line between using insertNodes and having to handle it yourself? My first impression on the above code is that you're repeating the TextNode split logic present in insertNodes and insertText.

Also, this logic is particularly complicated for anyone else to replicate, is there a possibility to have utilities for this?

One of the reasons why users use insertNodes heavily is to avoid having to split nodes at selection (otherwise insertAfter would do)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InsertNodes is safe to use anywhere except in insertParagraph/insertNewAfter because of the circular dependency I mentioned.

What would be ideal is that insertNodes does not depend on insertParagraph. However, at this point I don't know if that's possible without implementing a long and convoluted logic, like what was used so far.

Much of the time I spent on this PR was trying to accomplish that. When I gave up, I would come up with some way that I thought it was possible, only to finally realize that it wasn't. Explaining it might be too long. But I can say that some tests that are reasonable make it horrible to achieve this ("Paste top level element in the middle of list" is perhaps the best example).

On your second question, I don't think there is a great benefit to reusing some utility here. What is here that is repeated in removeTextAndSplitBlock is only 3 lines of code actually (285-287). The rest is selection restoration (which is taken care of by insertNodes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that in insertNodes I am temporarily using the __language in node hack.

What I would like to do in another PR is an "INSERT_NODES_COMMAND" that is used in @lexical/code. Then this code would not be necessary either.

}

return null;
Expand Down
50 changes: 14 additions & 36 deletions packages/lexical-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import type {
SerializedElementNode,
} from 'lexical';

import {addClassNamesToElement, isHTMLAnchorElement} from '@lexical/utils';
import {
$getAncestor,
addClassNamesToElement,
isHTMLAnchorElement,
} from '@lexical/utils';
import {
$applyNodeReplacement,
$getSelection,
Expand Down Expand Up @@ -224,23 +228,16 @@ export class LinkNode extends ElementNode {
}

insertNewAfter(
selection: RangeSelection,
_: RangeSelection,
restoreSelection = true,
): null | ElementNode {
const element = this.getParentOrThrow().insertNewAfter(
selection,
restoreSelection,
);
if ($isElementNode(element)) {
const linkNode = $createLinkNode(this.__url, {
rel: this.__rel,
target: this.__target,
title: this.__title,
});
element.append(linkNode);
return linkNode;
}
return null;
const linkNode = $createLinkNode(this.__url, {
rel: this.__rel,
target: this.__target,
title: this.__title,
});
this.insertAfter(linkNode, restoreSelection);
return linkNode;
Comment on lines 230 to +240
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting from the PR description:

Due to design errors in those methods that were modified, insertNewAfter in LinkNode was not "inserting a new link after", but rather a new block. This hack has been fixed and removed as it is no longer needed. I've also added a to-do comment that insertNewAfter should not return LexicalNode | null but this | null. This would be easier to achieve now.

}

canInsertTextBefore(): false {
Expand Down Expand Up @@ -450,9 +447,7 @@ export function toggleLink(
const firstNode = nodes[0];
// if the first node is a LinkNode or if its
// parent is a LinkNode, we update the URL, target and rel.
const linkNode = $isLinkNode(firstNode)
? firstNode
: $getLinkAncestor(firstNode);
const linkNode = $getAncestor(firstNode, $isLinkNode);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One detail that I noticed the new $getAncestor function improved

if (linkNode !== null) {
linkNode.setURL(url);
if (target !== undefined) {
Expand Down Expand Up @@ -534,20 +529,3 @@ export function toggleLink(
});
}
}

function $getLinkAncestor(node: LexicalNode): null | LexicalNode {
return $getAncestor(node, $isLinkNode);
}

function $getAncestor<NodeType extends LexicalNode = LexicalNode>(
node: LexicalNode,
predicate: (ancestor: LexicalNode) => ancestor is NodeType,
): null | LexicalNode {
let parent: null | LexicalNode = node;
while (
parent !== null &&
(parent = parent.getParent()) !== null &&
!predicate(parent)
);
return parent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ test.describe('HTML CopyAndPaste', () => {
await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<div
Expand All @@ -229,7 +228,6 @@ test.describe('HTML CopyAndPaste', () => {
await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
Expand All @@ -241,9 +239,9 @@ test.describe('HTML CopyAndPaste', () => {
);
await assertSelection(page, {
anchorOffset: 16,
anchorPath: [2, 0, 0],
anchorPath: [1, 0, 0],
focusOffset: 16,
focusPath: [2, 0, 0],
focusPath: [1, 0, 0],
});
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be considered a bug fixed, since there is no need to insert an empty paragraph

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,27 +390,23 @@ test.describe('HTML Lists CopyAndPaste', () => {
dir="ltr">
<span data-lexical-text="true">one</span>
</li>
</ul>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<ul class="PlaygroundEditorTheme__ul">
<li
value="2"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
dir="ltr"
value="1">
Comment on lines +393 to +399
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another improvement to insertNodes.
It doesn't make sense for the hr to be inserted after the list-item the cursor is over, if the cursor is at the beginning.

<span data-lexical-text="true">two</span>
</li>
</ul>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<div
class="PlaygroundEditorTheme__blockCursor"
contenteditable="false"
data-lexical-cursor="true"></div>
<ul class="PlaygroundEditorTheme__ul">
<li
value="1"
value="2"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">three</span>
</li>
<li
value="2"
value="3"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">four</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,13 @@ test.describe('CopyAndPaste', () => {

test('Pasting a decorator node on a blank line inserts before the line', async ({
page,
isCollab,
isPlainText,
}) => {
test.fixme(
isCollab,
'Seems to be failing on collab, at least since PR 5002',
);
GermanJablo marked this conversation as resolved.
Show resolved Hide resolved
test.skip(isPlainText);

// copying and pasting the node is easier than creating the clipboard data
Expand Down Expand Up @@ -900,7 +905,10 @@ test.describe('CopyAndPaste', () => {
width="560"></iframe>
</div>
</div>
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<div
class="PlaygroundEditorTheme__blockCursor"
contenteditable="false"
data-lexical-cursor="true"></div>
`,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ test.describe('Lists CopyAndPaste', () => {
value="1"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">three</span>
<span data-lexical-text="true">two</span>
</li>
<li
value="2"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">two</span>
<span data-lexical-text="true">three</span>
Comment on lines +265 to +271
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expect was incorrect. This PR detected the bug and fixed it.

</li>
</ul>
<p
Expand Down Expand Up @@ -504,40 +504,44 @@ test.describe('Lists CopyAndPaste', () => {
<span data-lexical-text="true">five</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">12one</span>
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">12</span>
</p>
<ul class="PlaygroundEditorTheme__ul">
<li
value="1"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">two</span>
<span data-lexical-text="true">one</span>
</li>
<li
value="2"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">three</span>
<span data-lexical-text="true">two</span>
</li>
<li
value="3"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">four</span>
<span data-lexical-text="true">three</span>
</li>
<li
value="4"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">five</span>
<span data-lexical-text="true">four</span>
</li>
<li value="5" class="PlaygroundEditorTheme__listItem">
<span data-lexical-text="true">45</span>
<li
value="5"
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">five</span>
</li>
</ul>
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">45</span>
</p>
`,
);
});
Expand Down Expand Up @@ -600,13 +604,13 @@ test.describe('Lists CopyAndPaste', () => {

await assertHTML(
page,
'<ul class="PlaygroundEditorTheme__ul"><li value="1" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">one</span></li><li value="2" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">two</span></li><li value="3" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">three</span></li><li value="4" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">fourthree</span></li><li value="5" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">four</span></li><li value="6" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">five</span></li></ul>',
'<ul class="PlaygroundEditorTheme__ul"><li value="1" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">one</span></li><li value="2" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">two</span></li><li value="3" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">three</span></li><li value="4" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">four</span></li><li class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr" value="5"><span data-lexical-text="true">three</span></li><li value="6" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">four</span></li><li value="7" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">five</span></li></ul>',
);
await assertSelection(page, {
anchorOffset: 4,
anchorPath: [0, 4, 0, 0],
anchorPath: [0, 5, 0, 0],
focusOffset: 4,
focusPath: [0, 4, 0, 0],
focusPath: [0, 5, 0, 0],
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ test.describe('Tables', () => {
</table>
<p><br /></p>
`,
{ignoreClasses: true},
{ignoreClasses: true, ignoreInlineStyles: true},
);
});

Expand Down
9 changes: 6 additions & 3 deletions packages/lexical-rich-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,15 @@ export class HeadingNode extends ElementNode {
): ParagraphNode | HeadingNode {
const anchorOffet = selection ? selection.anchor.offset : 0;
const newElement =
anchorOffet > 0 && anchorOffet < this.getTextContentSize()
? $createHeadingNode(this.getTag())
: $createParagraphNode();
anchorOffet === this.getTextContentSize() || !selection
? $createParagraphNode()
: $createHeadingNode(this.getTag());
const direction = this.getDirection();
newElement.setDirection(direction);
this.insertAfter(newElement, restoreSelection);
if (anchorOffet === 0 && !this.isEmpty() && selection) {
this.replace($createParagraphNode(), restoreSelection);
}
Comment on lines +357 to +365
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously insertNewAfter delegated to insertParagraph or insertNodes the responsibility of replacing the heading with a paragraph. By moving that responsibility here we can further simplify insertNodes which is already too complex on its own.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thoughts as above even though in this case the resulting code is much simpler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code case is different from this one. There you avoid insertNodes. Here you avoid burdening insertNodes with the responsibility of replacing or transforming nodes.

Actually, everything would be clearer if insertNewAfter was called handleEnter.

return newElement;
}

Expand Down
Loading
Loading