editor.js/src/components/modules/api/selection.ts
Peter Savchenko 3272efc3f7
chore(linting): eslint updated, code linted (#2174)
* 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
2022-11-25 21:56:50 +04:00

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);
}
}