mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 09:52:36 +02:00
fix caret loosing after caret (#2697)
This commit is contained in:
parent
c48fca1be3
commit
efa0a34f8e
|
@ -12,6 +12,7 @@
|
|||
- `Fix` - Block removing while Enter press on Block Tunes
|
||||
– `Fix` – Unwanted scroll on first typing on iOS devices
|
||||
- `Fix` - Unwanted soft line break on Enter press after period and space (". |") on iOS devices
|
||||
- `Fix` - Caret lost after block conversion on mobile devices.
|
||||
|
||||
### 2.29.1
|
||||
|
||||
|
|
|
@ -370,10 +370,10 @@ export default class BlockManager extends Module {
|
|||
* @param newTool - new Tool name
|
||||
* @param data - new Tool data
|
||||
*/
|
||||
public replace(block: Block, newTool: string, data: BlockToolData): void {
|
||||
public replace(block: Block, newTool: string, data: BlockToolData): Block {
|
||||
const blockIndex = this.getBlockIndex(block);
|
||||
|
||||
this.insert({
|
||||
return this.insert({
|
||||
tool: newTool,
|
||||
data,
|
||||
index: blockIndex,
|
||||
|
@ -821,7 +821,7 @@ export default class BlockManager extends Module {
|
|||
* @param targetToolName - name of the Tool to convert to
|
||||
* @param blockDataOverrides - optional new Block data overrides
|
||||
*/
|
||||
public async convert(blockToConvert: Block, targetToolName: string, blockDataOverrides?: BlockToolData): Promise<void> {
|
||||
public async convert(blockToConvert: Block, targetToolName: string, blockDataOverrides?: BlockToolData): Promise<Block> {
|
||||
/**
|
||||
* At first, we get current Block data
|
||||
*/
|
||||
|
@ -866,7 +866,7 @@ export default class BlockManager extends Module {
|
|||
newBlockData = Object.assign(newBlockData, blockDataOverrides);
|
||||
}
|
||||
|
||||
this.replace(blockToConvert, replacingTool.name, newBlockData);
|
||||
return this.replace(blockToConvert, replacingTool.name, newBlockData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -289,18 +289,16 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
|
|||
icon: toolboxItem.icon,
|
||||
title: toolboxItem.title,
|
||||
name: toolName,
|
||||
onActivate: () => {
|
||||
onActivate: async () => {
|
||||
const { BlockManager, BlockSelection, Caret } = this.Editor;
|
||||
|
||||
BlockManager.convert(this.Editor.BlockManager.currentBlock, toolName, toolboxItem.data);
|
||||
const newBlock = await BlockManager.convert(this.Editor.BlockManager.currentBlock, toolName, toolboxItem.data);
|
||||
|
||||
BlockSelection.clearSelection();
|
||||
|
||||
this.close();
|
||||
|
||||
window.requestAnimationFrame(() => {
|
||||
Caret.setToBlock(this.Editor.BlockManager.currentBlock, Caret.positions.END);
|
||||
});
|
||||
Caret.setToBlock(newBlock, Caret.positions.END);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue