mirror of
https://github.com/codex-team/editor.js
synced 2024-05-03 07:03:47 +02:00
3272efc3f7
* update eslint + autofix * a bunch of eslint fixes * some spelling & eslint fixes * fix some eslint errors and spells * Update __module.ts * a bunch of eslint fixes in tests * Update cypress.yml * Update cypress.yml * fix cypress docker image name * fixes for tests * more tests fixed * rm rule ignore * rm another ignored rule * Update .eslintrc
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import SelectionUtils from '../../selection';
|
|
import { Selection as SelectionAPIInterface } from '../../../../types/api';
|
|
import Module from '../../__module';
|
|
|
|
/**
|
|
* @class SelectionAPI
|
|
* Provides with methods working with SelectionUtils
|
|
*/
|
|
export default class SelectionAPI extends Module {
|
|
/**
|
|
* Available methods
|
|
*
|
|
* @returns {SelectionAPIInterface}
|
|
*/
|
|
public get methods(): SelectionAPIInterface {
|
|
return {
|
|
findParentTag: (tagName: string, className?: string): HTMLElement | null => this.findParentTag(tagName, className),
|
|
expandToTag: (node: HTMLElement): void => this.expandToTag(node),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Looks ahead from selection and find passed tag with class name
|
|
*
|
|
* @param {string} tagName - tag to find
|
|
* @param {string} className - tag's class name
|
|
* @returns {HTMLElement|null}
|
|
*/
|
|
public findParentTag(tagName: string, className?: string): HTMLElement | null {
|
|
return new SelectionUtils().findParentTag(tagName, className);
|
|
}
|
|
|
|
/**
|
|
* Expand selection to passed tag
|
|
*
|
|
* @param {HTMLElement} node - tag that should contain selection
|
|
*/
|
|
public expandToTag(node: HTMLElement): void {
|
|
new SelectionUtils().expandToTag(node);
|
|
}
|
|
}
|