mirror of
https://github.com/codex-team/editor.js
synced 2024-06-29 02:40:23 +02:00
rename utils
This commit is contained in:
parent
ca49a34898
commit
d8666a36b6
|
@ -307,14 +307,14 @@ export default class BlockEvents extends Module {
|
|||
/**
|
||||
* If enter has been pressed at the start of the text, just insert paragraph Block above
|
||||
*/
|
||||
if (currentBlock.currentInput !== undefined && caretUtils.isAtStartOfInput(currentBlock.currentInput) && !currentBlock.hasMedia) {
|
||||
if (currentBlock.currentInput !== undefined && caretUtils.isCaretAtStartOfInput(currentBlock.currentInput) && !currentBlock.hasMedia) {
|
||||
this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex);
|
||||
|
||||
/**
|
||||
* If caret is at very end of the block, just append the new block without splitting
|
||||
* to prevent unnecessary dom mutation observing
|
||||
*/
|
||||
} else if (currentBlock.currentInput && caretUtils.isAtEndOfInput(currentBlock.currentInput)) {
|
||||
} else if (currentBlock.currentInput && caretUtils.isCaretAtEndOfInput(currentBlock.currentInput)) {
|
||||
blockToFocus = this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex + 1);
|
||||
} else {
|
||||
/**
|
||||
|
@ -357,7 +357,7 @@ export default class BlockEvents extends Module {
|
|||
/**
|
||||
* If caret is not at the start, leave native behaviour
|
||||
*/
|
||||
if (!currentBlock.currentInput || !caretUtils.isAtStartOfInput(currentBlock.currentInput)) {
|
||||
if (!currentBlock.currentInput || !caretUtils.isCaretAtStartOfInput(currentBlock.currentInput)) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
|
@ -440,7 +440,7 @@ export default class BlockEvents extends Module {
|
|||
/**
|
||||
* If caret is not at the end, leave native behaviour
|
||||
*/
|
||||
if (!caretUtils.isAtEndOfInput(currentBlock.currentInput)) {
|
||||
if (!caretUtils.isCaretAtEndOfInput(currentBlock.currentInput)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -544,7 +544,7 @@ export default class BlockEvents extends Module {
|
|||
this.Editor.Toolbar.close();
|
||||
|
||||
const { currentBlock } = this.Editor.BlockManager;
|
||||
const caretAtEnd = currentBlock?.currentInput !== undefined ? caretUtils.isAtEndOfInput(currentBlock.currentInput) : undefined;
|
||||
const caretAtEnd = currentBlock?.currentInput !== undefined ? caretUtils.isCaretAtEndOfInput(currentBlock.currentInput) : undefined;
|
||||
const shouldEnableCBS = caretAtEnd || this.Editor.BlockSelection.anyBlockSelected;
|
||||
|
||||
if (event.shiftKey && event.keyCode === _.keyCodes.DOWN && shouldEnableCBS) {
|
||||
|
@ -606,7 +606,7 @@ export default class BlockEvents extends Module {
|
|||
this.Editor.Toolbar.close();
|
||||
|
||||
const { currentBlock } = this.Editor.BlockManager;
|
||||
const caretAtStart = currentBlock?.currentInput !== undefined ? caretUtils.isAtStartOfInput(currentBlock.currentInput) : undefined;
|
||||
const caretAtStart = currentBlock?.currentInput !== undefined ? caretUtils.isCaretAtStartOfInput(currentBlock.currentInput) : undefined;
|
||||
const shouldEnableCBS = caretAtStart || this.Editor.BlockSelection.anyBlockSelected;
|
||||
|
||||
if (event.shiftKey && event.keyCode === _.keyCodes.UP && shouldEnableCBS) {
|
||||
|
|
|
@ -239,7 +239,7 @@ export default class Caret extends Module {
|
|||
}
|
||||
|
||||
const { nextInput, currentInput } = currentBlock;
|
||||
const isAtEnd = currentInput !== undefined ? caretUtils.isAtEndOfInput(currentInput) : undefined;
|
||||
const isAtEnd = currentInput !== undefined ? caretUtils.isCaretAtEndOfInput(currentInput) : undefined;
|
||||
|
||||
let blockToNavigate = nextBlock;
|
||||
|
||||
|
@ -311,7 +311,7 @@ export default class Caret extends Module {
|
|||
* - caret is at the start of the current block
|
||||
* - block does not contain any inputs (e.g. to allow go back when Delimiter is focused)
|
||||
*/
|
||||
const caretAtStart = currentInput !== undefined ? caretUtils.isAtStartOfInput(currentInput) : undefined;
|
||||
const caretAtStart = currentInput !== undefined ? caretUtils.isCaretAtStartOfInput(currentInput) : undefined;
|
||||
const navigationAllowed = force || caretAtStart || !currentBlock.focusable;
|
||||
|
||||
/** If previous Tool`s input exists, focus on it. Otherwise set caret to the previous Block */
|
||||
|
|
|
@ -111,7 +111,7 @@ export function checkContenteditableSliceForEmptiness(contenteditable: HTMLEleme
|
|||
*
|
||||
* @param input - input where caret should be checked
|
||||
*/
|
||||
export function isAtStartOfInput(input: HTMLElement): boolean {
|
||||
export function isCaretAtStartOfInput(input: HTMLElement): boolean {
|
||||
const firstNode = $.getDeepestNode(input);
|
||||
|
||||
if (firstNode === null || $.isEmpty(input)) {
|
||||
|
@ -158,7 +158,7 @@ export function isAtStartOfInput(input: HTMLElement): boolean {
|
|||
*
|
||||
* @param input - input where caret should be checked
|
||||
*/
|
||||
export function isAtEndOfInput(input: HTMLElement): boolean {
|
||||
export function isCaretAtEndOfInput(input: HTMLElement): boolean {
|
||||
const lastNode = $.getDeepestNode(input, true);
|
||||
|
||||
if (lastNode === null) {
|
||||
|
|
Loading…
Reference in a new issue