Improve paste function of multiple lines (#1016)

Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com>
This commit is contained in:
Tomoyuki Hata 2020-03-15 05:37:39 +09:00 committed by GitHub
parent a5513a3d59
commit c1860c94c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

2
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -13,6 +13,7 @@
- `New` Block [lifecycle hook](tools.md#block-lifecycle-hooks) `moved`
- `Deprecated` — [`blocks.swap(fromIndex, toIndex)`](api.md) method is deprecated. Use `blocks.move(toIndex, fromIndex)` instead.
- `Fix` — Improve plain text paste [#1012](https://github.com/codex-team/editor.js/issues/1012)
- `Fix` — Fix multiline paste [#1015](https://github.com/codex-team/editor.js/issues/1015)
### 2.16.1

View file

@ -641,7 +641,11 @@ export default class Paste extends Module {
if (BlockManager.currentBlock && BlockManager.currentBlock.currentInput) {
const currentToolSanitizeConfig = Sanitizer.getInlineToolsConfig(BlockManager.currentBlock.name);
document.execCommand('insertHTML', false, Sanitizer.clean(content.innerHTML, currentToolSanitizeConfig));
document.execCommand(
'insertHTML',
false,
Sanitizer.clean(content.innerHTML, currentToolSanitizeConfig),
);
} else {
this.insertBlock(dataToInsert);
}
@ -765,10 +769,6 @@ export default class Paste extends Module {
case Node.ELEMENT_NODE:
const element = node as HTMLElement;
if (element.tagName === 'BR') {
return [...nodes, destNode, new DocumentFragment()];
}
const {tool = ''} = this.toolsTags[element.tagName] || {};
const toolTags = this.tagsByTool[tool] || [];

View file

@ -204,6 +204,12 @@ export default class Sanitizer extends Module {
});
}
/**
* Allow linebreaks
*/
config['br'] = true;
config['wbr'] = true;
return config;
}