Skip to content

Commit

Permalink
update insert component command so it works with non collapsed select…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
elpoelma committed Jun 15, 2022
1 parent 45729a1 commit 8177287
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions addon/commands/insert-component-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ export default class InsertComponentCommand extends Command {
const component = new ModelInlineComponent(componentSpec, props, state);
this.model.change(
(mutator) => {
const newRange = mutator.insertNodes(selection.lastRange, component);
const resultingRange = mutator.insertNodes(
selection.lastRange,
component
);
resultingRange.collapse();
const brAfterComponent = new ModelElement('br');
brAfterComponent.setAttribute('class', 'trailing');
mutator.insertNodes(newRange, brAfterComponent);
this.model.selectRange(newRange);
mutator.insertNodes(resultingRange, brAfterComponent);
this.model.selectRange(resultingRange);
},
true,
createSnapshot
Expand Down

0 comments on commit 8177287

Please sign in to comment.