Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
videosFolder: 'test/cypress/videos',
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
// You may want to clean this up later by importing new cypress plugins here.
setupNodeEvents(on, config) {
on('file:preprocessor', vitePreprocessor({
configFile: path.resolve(__dirname, './vite.config.test.js'),
Expand Down
215 changes: 49 additions & 166 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"dependencies": {
"@editorjs/caret": "^1.0.1",
"codex-notifier": "^1.1.2",
"codex-tooltip": "^1.0.5"
"codex-tooltip": "^1.0.5",
"vanilla-caret-js": "^1.1.0"
}
}
}
7 changes: 2 additions & 5 deletions src/components/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
/**
* @class Block
* @classdesc This class describes editor`s block, including block`s HTMLElement, data and tool
* @property {BlockTool} tool β€” current block tool (Paragraph, for example)

Check warning on line 70 in src/components/block/index.ts

View workflow job for this annotation

GitHub Actions / ESlint

The type 'BlockTool' is undefined
* @property {object} CSS β€” block`s css classes
*/

Expand Down Expand Up @@ -98,7 +98,7 @@

/**
* @classdesc Abstract Block class that contains Block information, Tool name and Tool class instance
* @property {BlockTool} tool - Tool instance

Check warning on line 101 in src/components/block/index.ts

View workflow job for this annotation

GitHub Actions / ESlint

The type 'BlockTool' is undefined
* @property {HTMLElement} holder - Div element that wraps block content with Tool's content. Has `ce-block` CSS class
* @property {HTMLElement} pluginsContent - HTML content that returns by Tool's render function
*/
Expand Down Expand Up @@ -226,7 +226,7 @@
this.name = tool.name;
this.id = id;
this.settings = tool.settings;
this.config = tool.settings.config || {};

Check warning on line 229 in src/components/block/index.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected any value in conditional. An explicit comparison or type cast is required
this.editorEventBus = eventBus || null;
this.blockAPI = new BlockAPI(this);

Expand Down Expand Up @@ -867,15 +867,12 @@
* - undefined β€” manual triggering of block.dispatchChange()
*/
private readonly didMutated = (mutationsOrInputEvent: MutationRecord[] | InputEvent = undefined): void => {
/**
* Block API have dispatchChange() method. In this case, mutations list will be undefined.
*/
const isManuallyDispatched = mutationsOrInputEvent === undefined;
const isInputEventHandler = mutationsOrInputEvent instanceof InputEvent;

/**
* True if didMutated has been called as "input" event handler
* Block API have dispatchChange() method. In this case, mutations list will be undefined.
*/
const isInputEventHandler = mutationsOrInputEvent instanceof InputEvent;

/**
* If tool updates its own root element, we need to renew it in our memory
Expand Down Expand Up @@ -917,7 +914,7 @@
node = node.parentElement;
}

return node && (node as HTMLElement).closest('[data-mutation-free="true"]') !== null;

Check warning on line 917 in src/components/block/index.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected object value in conditional. The condition is always true
});
});

Expand Down
1 change: 1 addition & 0 deletions src/components/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
/**
* If holderId is preset, assign him to holder property and work next only with holder
*/
_.deprecationAssert(!!this.config.holderId, 'config.holderId', 'config.holder');

Check warning on line 108 in src/components/core.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected value in conditional. A boolean expression is required
if (this.config.holderId && !this.config.holder) {

Check warning on line 109 in src/components/core.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected value in conditional. A boolean expression is required

Check warning on line 109 in src/components/core.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected value in conditional. A boolean expression is required
this.config.holder = this.config.holderId;
this.config.holderId = null;
}
Expand All @@ -118,7 +118,7 @@
this.config.holder = 'editorjs';
}

if (!this.config.logLevel) {

Check warning on line 121 in src/components/core.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected value in conditional. A boolean expression is required
this.config.logLevel = _.LogLevels.VERBOSE;
}

Expand All @@ -128,7 +128,7 @@
* If default Block's Tool was not passed, use the Paragraph Tool
*/
_.deprecationAssert(Boolean(this.config.initialBlock), 'config.initialBlock', 'config.defaultBlock');
this.config.defaultBlock = this.config.defaultBlock || this.config.initialBlock || 'paragraph';

Check warning on line 131 in src/components/core.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected nullable string value in conditional. Please handle the nullish/empty cases explicitly

/**
* Height of Editor's bottom area that allows to set focus on the last Block
Expand Down Expand Up @@ -253,6 +253,7 @@
'RectangleSelection',
'CrossBlockSelection',
'ReadOnly',
'History',
];

await modulesToPrepare.reduce(
Expand Down
4 changes: 2 additions & 2 deletions src/components/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,12 @@ export default class Dom {

/**
* Returns the closest ancestor anchor (A tag) of the given element (including itself)
*
*
* @param element - element to check
* @returns {HTMLAnchorElement | null}
*/
public static getClosestAnchor(element: Element): HTMLAnchorElement | null {
return element.closest("a");
return element.closest('a');
}

/**
Expand Down
56 changes: 56 additions & 0 deletions src/components/modules/api/history.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { History as HistoryInterface } from '../../../../types/api';
import Module from '../../__module';

/**
* @class HistoryAPI
* @classdesc Public API for undo/redo operations
*/
export default class HistoryAPI extends Module {
/**
* Available methods exposed on editor.history
*/
public get methods(): HistoryInterface {
return {
undo: (): Promise<void> => this.undo(),
redo: (): Promise<void> => this.redo(),
canUndo: (): boolean => this.canUndo(),
canRedo: (): boolean => this.canRedo(),
clear: (): Promise<void> => this.clear(),
};
}

/**
* Undo the last change
*/
public undo(): Promise<void> {
return this.Editor.History.undo();
}

/**
* Redo the last undone change
*/
public redo(): Promise<void> {
return this.Editor.History.redo();
}

/**
* Returns true if undo is possible
*/
public canUndo(): boolean {
return this.Editor.History.canUndo();
}

/**
* Returns true if redo is possible
*/
public canRedo(): boolean {
return this.Editor.History.canRedo();
}

/**
* Clear the history stack
*/
public async clear(): Promise<void> {
await this.Editor.History.clear();
}
}
1 change: 1 addition & 0 deletions src/components/modules/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class API extends Module {
i18n: this.Editor.I18nAPI.methods,
readOnly: this.Editor.ReadOnlyAPI.methods,
ui: this.Editor.UiAPI.methods,
history: this.Editor.HistoryAPI.methods,
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/modules/blockManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,8 @@ export default class BlockManager extends Module {
const queue = new PromiseQueue();

// Create a copy of the blocks array to avoid issues with array modification during iteration
const blocksToRemove = [...this.blocks];
const blocksToRemove = [ ...this.blocks ];

blocksToRemove.forEach((block) => {
queue.add(async () => {
await this.removeBlock(block, false);
Expand Down
Loading
Loading