mirror of
https://github.com/codex-team/editor.js
synced 2024-06-29 10:50:23 +02:00
Set caret when block data pasted (#1470)
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
This commit is contained in:
parent
527ff4e6d1
commit
3f39cb735d
|
@ -7,6 +7,7 @@
|
||||||
- `Improvements` - Remove unused `force` option in `Caret.navigateNext()` and `Caret.navigatePrevious()` [#857](https://github.com/codex-team/editor.js/issues/857#issuecomment-770363438).
|
- `Improvements` - Remove unused `force` option in `Caret.navigateNext()` and `Caret.navigatePrevious()` [#857](https://github.com/codex-team/editor.js/issues/857#issuecomment-770363438).
|
||||||
- `Improvements` - Remove bundles from the repo [#1541](https://github.com/codex-team/editor.js/pull/1541).
|
- `Improvements` - Remove bundles from the repo [#1541](https://github.com/codex-team/editor.js/pull/1541).
|
||||||
- `Improvements` - Document will be scrolled when blocks are selected with `SHIFT+UP` or `SHIFT+DOWN` [#1447](https://github.com/codex-team/editor.js/issues/1447)
|
- `Improvements` - Document will be scrolled when blocks are selected with `SHIFT+UP` or `SHIFT+DOWN` [#1447](https://github.com/codex-team/editor.js/issues/1447)
|
||||||
|
- `Improvements` - The caret will be set on editor copy/paste [#1470](https://github.com/codex-team/editor.js/pull/1470)
|
||||||
- `Fix` - Fix BlockManager.setCurrentBlockByChildNode() with multiple Editor.js instances [#1503](https://github.com/codex-team/editor.js/issues/1503).
|
- `Fix` - Fix BlockManager.setCurrentBlockByChildNode() with multiple Editor.js instances [#1503](https://github.com/codex-team/editor.js/issues/1503).
|
||||||
- `Fix` - Fix an unstable block cut process [#1489](https://github.com/codex-team/editor.js/issues/1489).
|
- `Fix` - Fix an unstable block cut process [#1489](https://github.com/codex-team/editor.js/issues/1489).
|
||||||
- `Fix` - Type definition of the Sanitizer config: the sanitize function now contains param definition [#1491](https://github.com/codex-team/editor.js/pull/1491).
|
- `Fix` - Type definition of the Sanitizer config: the sanitize function now contains param definition [#1491](https://github.com/codex-team/editor.js/pull/1491).
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
|
|
||||||
- `Improvements` - The [Cypress](https://www.cypress.io) was integrated as the end-to-end testing framework
|
- `Improvements` - The [Cypress](https://www.cypress.io) was integrated as the end-to-end testing framework
|
||||||
- `Improvements` - Native `typeof`replaced with custom utils methods
|
- `Improvements` - Native `typeof`replaced with custom utils methods
|
||||||
- `Improvements` - Bind shortcuts listeners on the editor wrapper instead of document (#1391)(https://github.com/codex-team/editor.js/issues/1391)
|
- `Improvements` - Bind shortcuts listeners on the editor wrapper instead of document [#1391](https://github.com/codex-team/editor.js/issues/1391)
|
||||||
- `Fix` - The problem with destroy() method [#1380](https://github.com/codex-team/editor.js/issues/1380).
|
- `Fix` - The problem with destroy() method [#1380](https://github.com/codex-team/editor.js/issues/1380).
|
||||||
- `Fix` - add getter keyword to `block.mergeable` method [#1415](https://github.com/codex-team/editor.js/issues/1415).
|
- `Fix` - add getter keyword to `block.mergeable` method [#1415](https://github.com/codex-team/editor.js/issues/1415).
|
||||||
- `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393)
|
- `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393)
|
||||||
|
|
|
@ -760,7 +760,7 @@ export default class Paste extends Module {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
private insertEditorJSData(blocks: Array<Pick<SavedData, 'data' | 'tool'>>): void {
|
private insertEditorJSData(blocks: Array<Pick<SavedData, 'data' | 'tool'>>): void {
|
||||||
const { BlockManager, Sanitizer, Tools } = this.Editor;
|
const { BlockManager, Caret, Sanitizer, Tools } = this.Editor;
|
||||||
const sanitizedBlocks = Sanitizer.sanitizeBlocks(blocks);
|
const sanitizedBlocks = Sanitizer.sanitizeBlocks(blocks);
|
||||||
|
|
||||||
sanitizedBlocks.forEach(({ tool, data }, i) => {
|
sanitizedBlocks.forEach(({ tool, data }, i) => {
|
||||||
|
@ -772,11 +772,13 @@ export default class Paste extends Module {
|
||||||
needToReplaceCurrentBlock = isCurrentBlockDefault && BlockManager.currentBlock.isEmpty;
|
needToReplaceCurrentBlock = isCurrentBlockDefault && BlockManager.currentBlock.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockManager.insert({
|
const block = BlockManager.insert({
|
||||||
tool,
|
tool,
|
||||||
data,
|
data,
|
||||||
replace: needToReplaceCurrentBlock,
|
replace: needToReplaceCurrentBlock,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Caret.setToBlock(block, Caret.positions.END);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue