forked from codex-team/editor.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection.ts
More file actions
41 lines (38 loc) · 1.19 KB
/
selection.ts
File metadata and controls
41 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
}
}