@azrico/reactgrid 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/example.js +20 -4
- package/dist/src/{views/func → func}/helpers.d.ts +0 -0
- package/dist/src/{views/func → func}/helpers.js +32 -23
- package/dist/src/views/DataGrid.d.ts +7 -3
- package/dist/src/views/DataGrid.js +9 -3
- package/package.json +1 -1
- package/src/example.tsx +15 -3
- package/src/func/helpers.ts +74 -0
- package/src/views/DataGrid.tsx +12 -5
- package/src/views/func/helpers.ts +0 -65
package/dist/src/example.js
CHANGED
|
@@ -50,19 +50,29 @@ const customColumns = [{
|
|
|
50
50
|
const contextMenuItems = ['test'];
|
|
51
51
|
function getData() {
|
|
52
52
|
const fd = [];
|
|
53
|
-
for (let index = 0; index <
|
|
53
|
+
for (let index = 0; index < 16; index++) {
|
|
54
54
|
fd.push({
|
|
55
55
|
__table_id: String(index),
|
|
56
56
|
username: 'user-' + index,
|
|
57
57
|
age: 20
|
|
58
58
|
});
|
|
59
59
|
if (index % 5 == 0) {
|
|
60
|
+
const sub_selfid = 's' + index;
|
|
60
61
|
fd.push({
|
|
61
|
-
__table_id:
|
|
62
|
+
__table_id: sub_selfid,
|
|
62
63
|
__parent__table_id: String(index),
|
|
63
|
-
username: 'sub-
|
|
64
|
+
username: 'sub-' + index,
|
|
64
65
|
age: 20
|
|
65
66
|
});
|
|
67
|
+
if (index % 2 == 0) {
|
|
68
|
+
const sub2_selfid = 'ss' + index;
|
|
69
|
+
fd.push({
|
|
70
|
+
__table_id: sub2_selfid,
|
|
71
|
+
__parent__table_id: sub_selfid,
|
|
72
|
+
username: 'sub2-' + index,
|
|
73
|
+
age: 20
|
|
74
|
+
});
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
}
|
|
68
78
|
return fd;
|
|
@@ -74,11 +84,17 @@ function ExampleGrid() {
|
|
|
74
84
|
return _react.default.createElement("div", null, _react.default.createElement("div", null, 'Test'));
|
|
75
85
|
};
|
|
76
86
|
const [selected, setSelected] = _react.default.useState(null);
|
|
87
|
+
const [rows, set_rows] = _react.default.useState([]);
|
|
77
88
|
const onSelectionChange = _react.default.useCallback(({
|
|
78
89
|
selected
|
|
79
90
|
}) => {
|
|
80
91
|
setSelected(selected);
|
|
81
92
|
}, []);
|
|
93
|
+
_react.default.useEffect(() => {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
set_rows(getData());
|
|
96
|
+
}, 1000);
|
|
97
|
+
}, []);
|
|
82
98
|
return _react.default.createElement(_DataGrid.default, {
|
|
83
99
|
dark: true,
|
|
84
100
|
allowChildRows: true,
|
|
@@ -87,7 +103,7 @@ function ExampleGrid() {
|
|
|
87
103
|
contextMenuItems: contextMenuItems,
|
|
88
104
|
customColumns: customColumns,
|
|
89
105
|
columns: columns,
|
|
90
|
-
rows:
|
|
106
|
+
rows: rows,
|
|
91
107
|
leftColumns: leftColumns,
|
|
92
108
|
gridOptions: {
|
|
93
109
|
rowIndexColumn: true,
|
|
File without changes
|
|
@@ -5,33 +5,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fix_parent_child_relations = fix_parent_child_relations;
|
|
7
7
|
exports.func_selection = void 0;
|
|
8
|
+
function get_parentId(obj) {
|
|
9
|
+
return obj.__parent__table_id || obj.parent;
|
|
10
|
+
}
|
|
11
|
+
function get_selfId(obj) {
|
|
12
|
+
return obj.__table_id;
|
|
13
|
+
}
|
|
8
14
|
//given an array of rows, fixes parent,child relations
|
|
9
15
|
function fix_parent_child_relations(rows) {
|
|
10
16
|
if (!Array.isArray(rows)) rows = [];
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const child = child_rows[index];
|
|
24
|
-
const parentOfChild = parent_rows.find(s => s.__table_id == child.__parent__table_id);
|
|
25
|
-
if (!parentOfChild) continue; //no parent :(
|
|
26
|
-
//@ts-ignore
|
|
27
|
-
parentOfChild.__children.push(child);
|
|
17
|
+
const converted_rows = rows.filter(r => r != null).map(r => {
|
|
18
|
+
return {
|
|
19
|
+
parent: get_parentId(r),
|
|
20
|
+
self: get_selfId(r),
|
|
21
|
+
data: r
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const top_level_rows = converted_rows.filter(r => !r.parent);
|
|
25
|
+
//find children of top-level parents:
|
|
26
|
+
for (let index = 0; index < top_level_rows.length; index++) {
|
|
27
|
+
const mrow = top_level_rows[index];
|
|
28
|
+
assign_children(mrow, converted_rows);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const result = top_level_rows.map(r => r.data);
|
|
31
|
+
//console.log(result);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function assign_children(row, all_rows) {
|
|
35
|
+
const my_children = all_rows.filter(s => row.self == s.parent);
|
|
36
|
+
if (my_children.length > 0) {
|
|
37
|
+
//find children of my children:
|
|
38
|
+
for (let index = 0; index < my_children.length; index++) {
|
|
39
|
+
const child = my_children[index];
|
|
40
|
+
assign_children(child, all_rows);
|
|
41
|
+
}
|
|
42
|
+
row.data.__children = my_children.map(r => r.data);
|
|
43
|
+
} else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
|
|
35
44
|
}
|
|
36
45
|
class func_selection {
|
|
37
46
|
static getVirtualElement(x = 0, y = 0) {
|
|
@@ -13,13 +13,15 @@ export type DataRowDefinition = any;
|
|
|
13
13
|
export type DataSourceDefinition = TypeDataSource;
|
|
14
14
|
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
15
15
|
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
16
|
-
type
|
|
17
|
-
title: string;
|
|
16
|
+
type loose_column_names = {
|
|
18
17
|
key: string;
|
|
19
18
|
field: string;
|
|
20
19
|
columnName: string;
|
|
21
20
|
name: string;
|
|
22
21
|
};
|
|
22
|
+
type loose_column_fields = loose_column_names & {
|
|
23
|
+
title: string;
|
|
24
|
+
};
|
|
23
25
|
export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
|
|
24
26
|
type columnOrString = string | LooseColumnDefinition;
|
|
25
27
|
type customColumnData = {
|
|
@@ -32,7 +34,9 @@ export type AzGridProps = {
|
|
|
32
34
|
rows?: any[];
|
|
33
35
|
licenseKey?: string;
|
|
34
36
|
gridOptions?: GridOptions;
|
|
35
|
-
tableColumnExtensions?:
|
|
37
|
+
tableColumnExtensions?: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
} & Partial<ColumnDefinition>>;
|
|
36
40
|
editableColumns?: string[];
|
|
37
41
|
leftColumns?: string[];
|
|
38
42
|
rightColumns?: string[];
|
|
@@ -9,7 +9,7 @@ require("@inovua/reactdatagrid-enterprise/index.css");
|
|
|
9
9
|
require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
|
|
10
10
|
require("../themes/styles.css");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
var _helpers = require("
|
|
12
|
+
var _helpers = require("../func/helpers");
|
|
13
13
|
var _controls = require("@azrico/controls");
|
|
14
14
|
var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
|
|
15
15
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -76,8 +76,11 @@ function AzGrid(props) {
|
|
|
76
76
|
const ext = mcolExts[index];
|
|
77
77
|
const ext_cl = get_col_name(ext);
|
|
78
78
|
const mcol = final_columns.find(s => s.name === ext_cl);
|
|
79
|
-
if (
|
|
80
|
-
|
|
79
|
+
if (mcol) {
|
|
80
|
+
for (const key in ext) {
|
|
81
|
+
if (!mcol[key] && key != 'name') mcol[key] = ext[key];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
81
84
|
// if (ext.widthGrow) mcol.widthGrow = ext.widthGrow;
|
|
82
85
|
}
|
|
83
86
|
/* ------------------------------- frozen cols ------------------------------ */
|
|
@@ -131,6 +134,7 @@ function AzGrid(props) {
|
|
|
131
134
|
/* -------------------------------------------------------------------------- */
|
|
132
135
|
_react.default.useEffect(() => {
|
|
133
136
|
if (pendingChanges <= 0) return;
|
|
137
|
+
//console.log('Updated Pending Changes: ', pendingChanges);
|
|
134
138
|
let new_rows = [];
|
|
135
139
|
if (typeof props.get_rows === 'function') {
|
|
136
140
|
new_rows = props.get_rows();
|
|
@@ -144,9 +148,11 @@ function AzGrid(props) {
|
|
|
144
148
|
set_pendingChanges(0);
|
|
145
149
|
}, [pendingChanges]);
|
|
146
150
|
_react.default.useEffect(() => {
|
|
151
|
+
//console.log('Rows Changed !');
|
|
147
152
|
set_pendingChanges(r => r + 1);
|
|
148
153
|
}, [props.rows]);
|
|
149
154
|
function onRowsChange(rows, options) {
|
|
155
|
+
//console.log('onRowsChange');
|
|
150
156
|
if (props.onRowsChange) props.onRowsChange(rows, options);
|
|
151
157
|
set_pendingChanges(r => r + 1); //notify the cache to update rows after we made changes to them
|
|
152
158
|
}
|
package/package.json
CHANGED
package/src/example.tsx
CHANGED
|
@@ -24,10 +24,15 @@ const customColumns = [
|
|
|
24
24
|
const contextMenuItems = ['test'];
|
|
25
25
|
function getData() {
|
|
26
26
|
const fd: any[] = [];
|
|
27
|
-
for (let index = 0; index <
|
|
27
|
+
for (let index = 0; index < 16; index++) {
|
|
28
28
|
fd.push({ __table_id: String(index), username: 'user-' + index, age: 20 });
|
|
29
29
|
if (index % 5 == 0) {
|
|
30
|
-
|
|
30
|
+
const sub_selfid = 's' + index;
|
|
31
|
+
fd.push({ __table_id: sub_selfid, __parent__table_id: String(index), username: 'sub-' + index, age: 20 });
|
|
32
|
+
if (index % 2 == 0) {
|
|
33
|
+
const sub2_selfid = 'ss' + index;
|
|
34
|
+
fd.push({ __table_id: sub2_selfid, __parent__table_id: sub_selfid, username: 'sub2-' + index, age: 20 });
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
return fd;
|
|
@@ -42,9 +47,16 @@ export function ExampleGrid() {
|
|
|
42
47
|
);
|
|
43
48
|
};
|
|
44
49
|
const [selected, setSelected] = React.useState(null);
|
|
50
|
+
const [rows, set_rows] = React.useState<any[]>([]);
|
|
45
51
|
const onSelectionChange = React.useCallback(({ selected }) => {
|
|
46
52
|
setSelected(selected);
|
|
47
53
|
}, []);
|
|
54
|
+
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
set_rows(getData());
|
|
58
|
+
}, 1000);
|
|
59
|
+
}, []);
|
|
48
60
|
return (
|
|
49
61
|
<AzGrid
|
|
50
62
|
dark
|
|
@@ -54,7 +66,7 @@ export function ExampleGrid() {
|
|
|
54
66
|
contextMenuItems={contextMenuItems}
|
|
55
67
|
customColumns={customColumns}
|
|
56
68
|
columns={columns}
|
|
57
|
-
rows={
|
|
69
|
+
rows={rows}
|
|
58
70
|
leftColumns={leftColumns}
|
|
59
71
|
gridOptions={{ rowIndexColumn: true, checkboxColumn: true }}
|
|
60
72
|
/>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
type mrow = { __parent__table_id: any; __table_id: any; __children?: any[] };
|
|
2
|
+
type converted_row = { parent: any; self: any; data: mrow };
|
|
3
|
+
|
|
4
|
+
function get_parentId(obj) {
|
|
5
|
+
return obj.__parent__table_id || obj.parent;
|
|
6
|
+
}
|
|
7
|
+
function get_selfId(obj) {
|
|
8
|
+
return obj.__table_id;
|
|
9
|
+
}
|
|
10
|
+
//given an array of rows, fixes parent,child relations
|
|
11
|
+
export function fix_parent_child_relations<T extends mrow>(rows: T[]): T[] {
|
|
12
|
+
if (!Array.isArray(rows)) rows = [];
|
|
13
|
+
|
|
14
|
+
const converted_rows: converted_row[] = rows
|
|
15
|
+
.filter((r) => r != null)
|
|
16
|
+
.map((r) => {
|
|
17
|
+
return { parent: get_parentId(r), self: get_selfId(r), data: r };
|
|
18
|
+
});
|
|
19
|
+
const top_level_rows: converted_row[] = converted_rows.filter((r) => !r.parent);
|
|
20
|
+
|
|
21
|
+
//find children of top-level parents:
|
|
22
|
+
for (let index = 0; index < top_level_rows.length; index++) {
|
|
23
|
+
const mrow = top_level_rows[index];
|
|
24
|
+
assign_children(mrow, converted_rows);
|
|
25
|
+
}
|
|
26
|
+
const result = top_level_rows.map((r) => r.data) as T[];
|
|
27
|
+
//console.log(result);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function assign_children(row: converted_row, all_rows: converted_row[]) {
|
|
32
|
+
const my_children = all_rows.filter((s) => row.self == s.parent);
|
|
33
|
+
if (my_children.length > 0) {
|
|
34
|
+
//find children of my children:
|
|
35
|
+
for (let index = 0; index < my_children.length; index++) {
|
|
36
|
+
const child = my_children[index];
|
|
37
|
+
assign_children(child, all_rows);
|
|
38
|
+
}
|
|
39
|
+
row.data.__children = my_children.map((r) => r.data);
|
|
40
|
+
} else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
|
|
41
|
+
}
|
|
42
|
+
export class func_selection {
|
|
43
|
+
static getVirtualElement(x = 0, y = 0) {
|
|
44
|
+
return () => ({
|
|
45
|
+
getBoundingClientRect: func_selection.generateGetBoundingClientRect(x, y),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
static generateGetBoundingClientRect(x = 0, y = 0) {
|
|
49
|
+
return () => ({
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
top: y,
|
|
53
|
+
right: x,
|
|
54
|
+
bottom: y,
|
|
55
|
+
left: x,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
static get_selectedText(): string {
|
|
59
|
+
var text: any = '';
|
|
60
|
+
if (window.getSelection) {
|
|
61
|
+
text = window.getSelection()?.toString();
|
|
62
|
+
} else if ((document as any).selection && (document as any).selection.type != 'Control') {
|
|
63
|
+
text = (document as any).selection.createRange()?.text;
|
|
64
|
+
}
|
|
65
|
+
return text || '';
|
|
66
|
+
}
|
|
67
|
+
static has_selection(): boolean {
|
|
68
|
+
const slct = window.getSelection();
|
|
69
|
+
if (slct == null) return false;
|
|
70
|
+
if (slct.type == null) return func_selection.get_selectedText().length !== 0;
|
|
71
|
+
if (slct.type === 'Range') return true;
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
TypeRowProps,
|
|
12
12
|
TypeRowSelection,
|
|
13
13
|
} from '@inovua/reactdatagrid-community/types';
|
|
14
|
-
import { fix_parent_child_relations, func_selection } from '
|
|
14
|
+
import { fix_parent_child_relations, func_selection } from '../func/helpers';
|
|
15
15
|
|
|
16
16
|
import { ContextMenu } from '@azrico/controls';
|
|
17
17
|
import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
|
|
@@ -35,7 +35,8 @@ export type DataSourceDefinition = TypeDataSource;
|
|
|
35
35
|
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
36
36
|
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
37
37
|
/* -------------------------------------------------------------------------- */
|
|
38
|
-
type
|
|
38
|
+
type loose_column_names = { key: string; field: string; columnName: string; name: string };
|
|
39
|
+
type loose_column_fields = loose_column_names & { title: string };
|
|
39
40
|
export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
|
|
40
41
|
//
|
|
41
42
|
type columnOrString = string | LooseColumnDefinition;
|
|
@@ -52,7 +53,7 @@ export type AzGridProps = {
|
|
|
52
53
|
|
|
53
54
|
gridOptions?: GridOptions;
|
|
54
55
|
|
|
55
|
-
tableColumnExtensions?:
|
|
56
|
+
tableColumnExtensions?: Array<{ name: string } & Partial<ColumnDefinition>>;
|
|
56
57
|
editableColumns?: string[];
|
|
57
58
|
leftColumns?: string[];
|
|
58
59
|
rightColumns?: string[];
|
|
@@ -151,8 +152,11 @@ export function AzGrid(props: AzGridProps) {
|
|
|
151
152
|
const ext = mcolExts[index];
|
|
152
153
|
const ext_cl = get_col_name(ext);
|
|
153
154
|
const mcol = final_columns.find((s) => s.name === ext_cl);
|
|
154
|
-
if (
|
|
155
|
-
|
|
155
|
+
if (mcol) {
|
|
156
|
+
for (const key in ext) {
|
|
157
|
+
if (!mcol[key] && key != 'name') mcol[key] = ext[key];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
156
160
|
// if (ext.widthGrow) mcol.widthGrow = ext.widthGrow;
|
|
157
161
|
}
|
|
158
162
|
|
|
@@ -209,6 +213,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
209
213
|
/* -------------------------------------------------------------------------- */
|
|
210
214
|
React.useEffect(() => {
|
|
211
215
|
if (pendingChanges <= 0) return;
|
|
216
|
+
//console.log('Updated Pending Changes: ', pendingChanges);
|
|
212
217
|
let new_rows: any[] = [];
|
|
213
218
|
if (typeof props.get_rows === 'function') {
|
|
214
219
|
new_rows = props.get_rows();
|
|
@@ -224,10 +229,12 @@ export function AzGrid(props: AzGridProps) {
|
|
|
224
229
|
}, [pendingChanges]);
|
|
225
230
|
|
|
226
231
|
React.useEffect(() => {
|
|
232
|
+
//console.log('Rows Changed !');
|
|
227
233
|
set_pendingChanges((r) => r + 1);
|
|
228
234
|
}, [props.rows]);
|
|
229
235
|
|
|
230
236
|
function onRowsChange(rows: any[], options: any) {
|
|
237
|
+
//console.log('onRowsChange');
|
|
231
238
|
if (props.onRowsChange) props.onRowsChange(rows, options);
|
|
232
239
|
set_pendingChanges((r) => r + 1); //notify the cache to update rows after we made changes to them
|
|
233
240
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
type mrow = { __parent__table_id: any; __table_id: any; __children?: any[] };
|
|
2
|
-
//given an array of rows, fixes parent,child relations
|
|
3
|
-
export function fix_parent_child_relations<T extends mrow>(rows: T[]): T[] {
|
|
4
|
-
if (!Array.isArray(rows)) rows = [];
|
|
5
|
-
const child_rows: T[] = [];
|
|
6
|
-
const parent_rows: T[] = [];
|
|
7
|
-
for (let index = 0; index < rows.length; index++) {
|
|
8
|
-
const r = rows[index];
|
|
9
|
-
if (r.__parent__table_id != undefined) child_rows.push(r);
|
|
10
|
-
else parent_rows.push(r);
|
|
11
|
-
}
|
|
12
|
-
for (let index = 0; index < parent_rows.length; index++) {
|
|
13
|
-
const pr = parent_rows[index];
|
|
14
|
-
pr.__children = [];
|
|
15
|
-
}
|
|
16
|
-
//find parent for these children !
|
|
17
|
-
for (let index = 0; index < child_rows.length; index++) {
|
|
18
|
-
const child = child_rows[index];
|
|
19
|
-
const parentOfChild = parent_rows.find((s) => s.__table_id == child.__parent__table_id);
|
|
20
|
-
if (!parentOfChild) continue; //no parent :(
|
|
21
|
-
//@ts-ignore
|
|
22
|
-
parentOfChild.__children.push(child);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
for (let index = 0; index < parent_rows.length; index++) {
|
|
26
|
-
const pr = parent_rows[index];
|
|
27
|
-
//@ts-ignore
|
|
28
|
-
if (pr.__children.length == 0) pr.__children = undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return parent_rows;
|
|
32
|
-
}
|
|
33
|
-
export class func_selection {
|
|
34
|
-
static getVirtualElement(x = 0, y = 0) {
|
|
35
|
-
return () => ({
|
|
36
|
-
getBoundingClientRect: func_selection.generateGetBoundingClientRect(x, y),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
static generateGetBoundingClientRect(x = 0, y = 0) {
|
|
40
|
-
return () => ({
|
|
41
|
-
width: 0,
|
|
42
|
-
height: 0,
|
|
43
|
-
top: y,
|
|
44
|
-
right: x,
|
|
45
|
-
bottom: y,
|
|
46
|
-
left: x,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
static get_selectedText(): string {
|
|
50
|
-
var text: any = '';
|
|
51
|
-
if (window.getSelection) {
|
|
52
|
-
text = window.getSelection()?.toString();
|
|
53
|
-
} else if ((document as any).selection && (document as any).selection.type != 'Control') {
|
|
54
|
-
text = (document as any).selection.createRange()?.text;
|
|
55
|
-
}
|
|
56
|
-
return text || '';
|
|
57
|
-
}
|
|
58
|
-
static has_selection(): boolean {
|
|
59
|
-
const slct = window.getSelection();
|
|
60
|
-
if (slct == null) return false;
|
|
61
|
-
if (slct.type == null) return func_selection.get_selectedText().length !== 0;
|
|
62
|
-
if (slct.type === 'Range') return true;
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|