mirror of
https://github.com/codex-team/editor.js
synced 2024-06-17 21:25:05 +02:00
Improve paste function of multiple lines (#1016)
Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com>
This commit is contained in:
parent
a5513a3d59
commit
c1860c94c9
2
dist/editor.js
vendored
2
dist/editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
|
||||
|
|
|
@ -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] || [];
|
||||
|
||||
|
|
|
@ -204,6 +204,12 @@ export default class Sanitizer extends Module {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow linebreaks
|
||||
*/
|
||||
config['br'] = true;
|
||||
config['wbr'] = true;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue