@iyio/rtxt 0.7.0 → 0.7.5
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/esm/src/lib/RTxtEditor.js +52 -72
- package/esm/src/lib/RTxtEditor.js.map +1 -1
- package/esm/src/lib/RTxtRenderer.js +15 -21
- package/esm/src/lib/RTxtRenderer.js.map +1 -1
- package/esm/src/lib/rtxt-descriptors.js +10 -17
- package/esm/src/lib/rtxt-descriptors.js.map +1 -1
- package/esm/src/lib/rtxt-lib.js +12 -19
- package/esm/src/lib/rtxt-lib.js.map +1 -1
- package/esm/src/lib/rtxt-style-editor.js +3 -4
- package/esm/src/lib/rtxt-style-editor.js.map +1 -1
- package/esm/src/lib/rtxt-style-renderer.js +3 -4
- package/esm/src/lib/rtxt-style-renderer.js.map +1 -1
- package/esm/src/lib/rtxt-tool-lib.js +22 -29
- package/esm/src/lib/rtxt-tool-lib.js.map +1 -1
- package/esm/src/lib/rtxt-tools.js +31 -45
- package/esm/src/lib/rtxt-tools.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/RTxtEditor.js +52 -72
- package/src/lib/RTxtEditor.js.map +1 -1
- package/src/lib/RTxtRenderer.js +15 -21
- package/src/lib/RTxtRenderer.js.map +1 -1
- package/src/lib/rtxt-descriptors.js +10 -17
- package/src/lib/rtxt-descriptors.js.map +1 -1
- package/src/lib/rtxt-lib.js +12 -19
- package/src/lib/rtxt-lib.js.map +1 -1
- package/src/lib/rtxt-style-editor.js +3 -4
- package/src/lib/rtxt-style-editor.js.map +1 -1
- package/src/lib/rtxt-style-renderer.js +3 -4
- package/src/lib/rtxt-style-renderer.js.map +1 -1
- package/src/lib/rtxt-tool-lib.js +22 -29
- package/src/lib/rtxt-tool-lib.js.map +1 -1
- package/src/lib/rtxt-tools.js +31 -45
- package/src/lib/rtxt-tools.js.map +1 -1
|
@@ -88,9 +88,8 @@ export const getDefaultRTxtTools = ({ fontFamilies, } = {}) => {
|
|
|
88
88
|
innerHTML: 'clear',
|
|
89
89
|
className: 'button-clear',
|
|
90
90
|
onClick: () => {
|
|
91
|
-
var _a, _b;
|
|
92
91
|
const sel = editor.selection;
|
|
93
|
-
const elem =
|
|
92
|
+
const elem = editor.renderer?.elem;
|
|
94
93
|
if (!sel) {
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
@@ -99,7 +98,7 @@ export const getDefaultRTxtTools = ({ fontFamilies, } = {}) => {
|
|
|
99
98
|
for (const type of types) {
|
|
100
99
|
editor.removeFromSelection(sel, type);
|
|
101
100
|
}
|
|
102
|
-
|
|
101
|
+
editor.renderer?.render();
|
|
103
102
|
}
|
|
104
103
|
if (elem) {
|
|
105
104
|
selectRTxtSelection(sel, elem);
|
|
@@ -109,48 +108,39 @@ export const getDefaultRTxtTools = ({ fontFamilies, } = {}) => {
|
|
|
109
108
|
},
|
|
110
109
|
{
|
|
111
110
|
types: [],
|
|
112
|
-
render: (editor) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
},
|
|
111
|
+
render: (editor) => createRTxtToolButton({
|
|
112
|
+
editor,
|
|
113
|
+
innerHTML: getRTxtIcon({ type: 'alignLeft', fill: editor.options.style?.foregroundColor ?? '#ffffff' }),
|
|
114
|
+
onClick: () => {
|
|
115
|
+
editor.setSelectedLineAlignment('start');
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
122
118
|
isSelected: ({ editor }) => {
|
|
123
119
|
return editor.getSelectedLines().some(l => !l.align || l.align === 'start');
|
|
124
120
|
},
|
|
125
121
|
},
|
|
126
122
|
{
|
|
127
123
|
types: [],
|
|
128
|
-
render: (editor) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
},
|
|
124
|
+
render: (editor) => createRTxtToolButton({
|
|
125
|
+
editor,
|
|
126
|
+
innerHTML: getRTxtIcon({ type: 'alignCenter', fill: editor.options.style?.foregroundColor ?? '#ffffff' }),
|
|
127
|
+
onClick: () => {
|
|
128
|
+
editor.setSelectedLineAlignment('center');
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
138
131
|
isSelected: ({ editor }) => {
|
|
139
132
|
return editor.getSelectedLines().some(l => l.align === 'center');
|
|
140
133
|
},
|
|
141
134
|
},
|
|
142
135
|
{
|
|
143
136
|
types: [],
|
|
144
|
-
render: (editor) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
},
|
|
137
|
+
render: (editor) => createRTxtToolButton({
|
|
138
|
+
editor,
|
|
139
|
+
innerHTML: getRTxtIcon({ type: 'alignRight', fill: editor.options.style?.foregroundColor ?? '#ffffff' }),
|
|
140
|
+
onClick: () => {
|
|
141
|
+
editor.setSelectedLineAlignment('end');
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
154
144
|
isSelected: ({ editor }) => {
|
|
155
145
|
return editor.getSelectedLines().some(l => l.align === 'end');
|
|
156
146
|
},
|
|
@@ -177,23 +167,19 @@ export const createRTxtFontFamilyTool = (families) => ({
|
|
|
177
167
|
editor,
|
|
178
168
|
options: [
|
|
179
169
|
{ clearType: 'f', label: 'default' },
|
|
180
|
-
...families.map(f => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
value: (_b = (_a = f.family) !== null && _a !== void 0 ? _a : f.className) !== null && _b !== void 0 ? _b : f.label,
|
|
188
|
-
});
|
|
189
|
-
})
|
|
170
|
+
...families.map(f => ({
|
|
171
|
+
clearType: 'f',
|
|
172
|
+
type: 'f',
|
|
173
|
+
label: f.label,
|
|
174
|
+
atts: { font: f.family, ['font-class']: f.className },
|
|
175
|
+
value: f.family ?? f.className ?? f.label,
|
|
176
|
+
}))
|
|
190
177
|
]
|
|
191
178
|
}),
|
|
192
179
|
],
|
|
193
180
|
onSelectionChange: ({ toolElem, nodeAtCursor }) => {
|
|
194
|
-
var _a, _b, _c, _d;
|
|
195
181
|
if (toolElem instanceof HTMLSelectElement) {
|
|
196
|
-
toolElem.value =
|
|
182
|
+
toolElem.value = nodeAtCursor?.atts?.['font'] ?? nodeAtCursor?.atts?.['font-class'] ?? '';
|
|
197
183
|
}
|
|
198
184
|
},
|
|
199
185
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtxt-tools.js","sourceRoot":"","sources":["../../../../../../packages/rtxt/src/lib/rtxt-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAsB,oBAAoB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG7I,MAAM,CAAC,MAAM,mBAAmB,GAAC,CAAC,EAC9B,YAAY,MACI,EAAE,EAAY,EAAE;IAEhC,MAAM,QAAQ,GAAwB;QAClC,CAAC,YAAY,CAAA,CAAC,CAAA,SAAS,CAAA,CAAC,CAAA,wBAAwB,CAAC,YAAY,CAAC;QAC9D;YACI,KAAK,EAAC,CAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,CAAC;YACnD,MAAM,EAAC,MAAM,CAAA,EAAE,CAAA;gBACX,mBAAmB,CAAC,MAAM,CAAC;gBAC3B,sBAAsB,CAAC;oBACnB,MAAM;oBACN,OAAO,EAAC;wBACJ,EAAC,IAAI,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC;wBACvB,EAAC,IAAI,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC;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AC;oBAC/C,KAAK,EAAC,CAAC,CAAC,MAAM,IAAE,CAAC,CAAC,SAAS,IAAE,CAAC,CAAC,KAAK;iBACvC,CAAC,CAAC;aACN;SACJ,CAAC;KACL;IACD,iBAAiB,EAAC,CAAC,EAAC,QAAQ,EAAC,YAAY,EAAC,EAAC,EAAE;QACzC,IAAG,QAAQ,YAAY,iBAAiB,EAAC,CAAC;YACtC,QAAQ,CAAC,KAAK,GAAC,YAAY,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,IAAE,YAAY,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,IAAE,EAAE,CAAC;QACxF,CAAC;IACL,CAAC;CACJ,CACA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyio/rtxt",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"date-fns": ">=2.29.3",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"zod": ">=3.21.4"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@iyio/common": "^0.7.
|
|
12
|
+
"@iyio/common": "^0.7.5"
|
|
13
13
|
},
|
|
14
14
|
"main": "./src/index.js",
|
|
15
15
|
"module": "./esm/src/index.js"
|
package/src/lib/RTxtEditor.js
CHANGED
|
@@ -43,22 +43,18 @@ class RTxtEditor {
|
|
|
43
43
|
get selectionSubject() { return this._selection; }
|
|
44
44
|
get selection() { return this._selection.value; }
|
|
45
45
|
constructor(options = {}) {
|
|
46
|
-
var _a, _b, _c, _d, _e;
|
|
47
46
|
this._renderer = new rxjs_1.BehaviorSubject(null);
|
|
48
47
|
this._selection = new rxjs_1.BehaviorSubject(null);
|
|
49
48
|
this._isDisposed = false;
|
|
50
49
|
this.onInput = () => {
|
|
51
|
-
var _a;
|
|
52
50
|
this.syncElemToDoc();
|
|
53
|
-
|
|
51
|
+
this.renderer?.queueExport();
|
|
54
52
|
};
|
|
55
53
|
this.onFocus = () => {
|
|
56
|
-
|
|
57
|
-
(_b = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.elem) === null || _b === void 0 ? void 0 : _b.classList.add(`${this.renderer.classPrefix}focus`);
|
|
54
|
+
this.renderer?.elem?.classList.add(`${this.renderer.classPrefix}focus`);
|
|
58
55
|
};
|
|
59
56
|
this.onBlur = () => {
|
|
60
|
-
|
|
61
|
-
(_b = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.elem) === null || _b === void 0 ? void 0 : _b.classList.remove(`${this.renderer.classPrefix}focus`);
|
|
57
|
+
this.renderer?.elem?.classList.remove(`${this.renderer.classPrefix}focus`);
|
|
62
58
|
};
|
|
63
59
|
this.bodyMouseDown = (e) => {
|
|
64
60
|
if (!this.menu || !(e.target instanceof Node)) {
|
|
@@ -69,23 +65,21 @@ class RTxtEditor {
|
|
|
69
65
|
}
|
|
70
66
|
};
|
|
71
67
|
this.bodyMouseUp = () => {
|
|
72
|
-
|
|
73
|
-
(_a = this.menu) === null || _a === void 0 ? void 0 : _a.classList.remove(`${this.classPrefix}disable-mouse`);
|
|
68
|
+
this.menu?.classList.remove(`${this.classPrefix}disable-mouse`);
|
|
74
69
|
};
|
|
75
70
|
this.onSelectionChange = () => {
|
|
76
|
-
var _a;
|
|
77
71
|
if (!this.renderer) {
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
80
|
-
const sel =
|
|
74
|
+
const sel = globalThis.document?.getSelection();
|
|
81
75
|
if (this.renderer.isEmpty ||
|
|
82
76
|
!sel ||
|
|
83
77
|
!sel.rangeCount ||
|
|
84
78
|
!sel.anchorNode ||
|
|
85
79
|
!sel.focusNode ||
|
|
86
80
|
(sel.anchorNode === sel.focusNode && sel.anchorOffset === sel.focusOffset) ||
|
|
87
|
-
!(0, common_1.isDomNodeDescendantOf)(sel
|
|
88
|
-
!(0, common_1.isDomNodeDescendantOf)(sel
|
|
81
|
+
!(0, common_1.isDomNodeDescendantOf)(sel?.anchorNode, this.renderer.elem, true) ||
|
|
82
|
+
!(0, common_1.isDomNodeDescendantOf)(sel?.focusNode, this.renderer.elem, true)) {
|
|
89
83
|
if (!sel ||
|
|
90
84
|
(!(0, common_1.isDomNodeDescendantOf)(sel.anchorNode, this.menu, false) &&
|
|
91
85
|
!(0, common_1.isDomNodeDescendantOf)(sel.focusNode, this.menu, false))) {
|
|
@@ -118,37 +112,35 @@ class RTxtEditor {
|
|
|
118
112
|
else if (renderer) {
|
|
119
113
|
this.renderer = new RTxtRenderer_1.RTxtRenderer(renderer, true);
|
|
120
114
|
}
|
|
121
|
-
this.classPrefix =
|
|
115
|
+
this.classPrefix = classPrefix ?? this.renderer?.options.classPrefix ?? rtxt_types_1.defaultRTxtClassNamePrefix;
|
|
122
116
|
this.tools = tools;
|
|
123
117
|
if (!useCustomStyleSheet) {
|
|
124
118
|
(0, rtxt_style_editor_1.insertRTxtEditorStyleSheet)();
|
|
125
119
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
globalThis.document?.addEventListener('selectionchange', this.onSelectionChange);
|
|
121
|
+
globalThis.document?.body.addEventListener('mousedown', this.bodyMouseDown);
|
|
122
|
+
globalThis.document?.body.addEventListener('mouseup', this.bodyMouseUp);
|
|
129
123
|
this.menu = this.renderMenu();
|
|
130
124
|
}
|
|
131
125
|
get isDisposed() { return this._isDisposed; }
|
|
132
126
|
dispose() {
|
|
133
|
-
var _a, _b, _c, _d;
|
|
134
127
|
if (this._isDisposed) {
|
|
135
128
|
return;
|
|
136
129
|
}
|
|
137
130
|
this._isDisposed = true;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
globalThis.document?.removeEventListener('selectionchange', this.onSelectionChange);
|
|
132
|
+
globalThis.document?.body.removeEventListener('mousedown', this.bodyMouseDown);
|
|
133
|
+
globalThis.document?.body.removeEventListener('mouseup', this.bodyMouseUp);
|
|
134
|
+
this.menu?.remove();
|
|
142
135
|
this.renderer = null;
|
|
143
136
|
}
|
|
144
137
|
deselectAllTools() {
|
|
145
|
-
var _a, _b;
|
|
146
138
|
const className = `${this.classPrefix}selected`;
|
|
147
139
|
for (const group of this.toolElemGroupings) {
|
|
148
140
|
for (const elem of group.elems) {
|
|
149
141
|
elem.classList.remove(className);
|
|
150
142
|
}
|
|
151
|
-
|
|
143
|
+
group.tool.onSelectionChange?.({
|
|
152
144
|
editor: this,
|
|
153
145
|
selection: null,
|
|
154
146
|
descriptors: [],
|
|
@@ -160,7 +152,6 @@ class RTxtEditor {
|
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
154
|
setToolSelection(selection) {
|
|
163
|
-
var _a, _b, _c, _d;
|
|
164
155
|
if (!this.renderer) {
|
|
165
156
|
this.deselectAllTools();
|
|
166
157
|
return;
|
|
@@ -168,9 +159,9 @@ class RTxtEditor {
|
|
|
168
159
|
const className = `${this.classPrefix}selected`;
|
|
169
160
|
const singleAry = [''];
|
|
170
161
|
const elemAtCursor = this.getElementAt(selection.cursorIndex);
|
|
171
|
-
const styleAtCursor = elemAtCursor ?
|
|
172
|
-
const colorAtCursor =
|
|
173
|
-
const sizeAtCursor = styleAtCursor
|
|
162
|
+
const styleAtCursor = elemAtCursor ? globalThis.window?.getComputedStyle?.((0, rtxt_internal_1.getDeepestElem)(elemAtCursor)) : undefined;
|
|
163
|
+
const colorAtCursor = styleAtCursor?.color ? (0, common_1.convertRgbToHex)(styleAtCursor.color) : undefined;
|
|
164
|
+
const sizeAtCursor = styleAtCursor?.fontSize;
|
|
174
165
|
const nodeAtCursor = this.renderer.nodeLookup[selection.cursorIndex];
|
|
175
166
|
for (const group of this.toolElemGroupings) {
|
|
176
167
|
const types = [];
|
|
@@ -260,13 +251,12 @@ class RTxtEditor {
|
|
|
260
251
|
}
|
|
261
252
|
}
|
|
262
253
|
}
|
|
263
|
-
|
|
254
|
+
group.tool.onSelectionChange?.(toolSel);
|
|
264
255
|
}
|
|
265
256
|
}
|
|
266
257
|
renderMenu() {
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const menu = (_b = globalThis.document) === null || _b === void 0 ? void 0 : _b.createElement('div');
|
|
258
|
+
const container = globalThis.document?.createElement('div');
|
|
259
|
+
const menu = globalThis.document?.createElement('div');
|
|
270
260
|
if (!container || !menu) {
|
|
271
261
|
return null;
|
|
272
262
|
}
|
|
@@ -293,7 +283,7 @@ class RTxtEditor {
|
|
|
293
283
|
grouping.elems.push(elem);
|
|
294
284
|
}
|
|
295
285
|
}
|
|
296
|
-
|
|
286
|
+
globalThis.document?.body.appendChild(container);
|
|
297
287
|
return container;
|
|
298
288
|
}
|
|
299
289
|
showMenu(left, top, bottom) {
|
|
@@ -326,7 +316,6 @@ class RTxtEditor {
|
|
|
326
316
|
}
|
|
327
317
|
}
|
|
328
318
|
applyToSection(selection, nodeType, atts) {
|
|
329
|
-
var _a, _b, _c;
|
|
330
319
|
if (!this.renderer) {
|
|
331
320
|
return;
|
|
332
321
|
}
|
|
@@ -339,11 +328,11 @@ class RTxtEditor {
|
|
|
339
328
|
}
|
|
340
329
|
if (!node.t.includes(nodeType)) {
|
|
341
330
|
const desc = this.renderer.descriptors[nodeType];
|
|
342
|
-
if (desc
|
|
331
|
+
if (desc?.group) {
|
|
343
332
|
for (let i = 0; i < node.t.length; i++) {
|
|
344
|
-
const otherDesc = this.renderer.descriptors[
|
|
345
|
-
if (
|
|
346
|
-
|
|
333
|
+
const otherDesc = this.renderer.descriptors[node.t[i] ?? ''];
|
|
334
|
+
if (otherDesc?.group === desc.group) {
|
|
335
|
+
otherDesc.remove?.(node);
|
|
347
336
|
node.t.splice(i, 1);
|
|
348
337
|
i--;
|
|
349
338
|
}
|
|
@@ -364,10 +353,9 @@ class RTxtEditor {
|
|
|
364
353
|
}
|
|
365
354
|
}
|
|
366
355
|
}
|
|
367
|
-
|
|
356
|
+
this.renderer?.queueExport();
|
|
368
357
|
}
|
|
369
358
|
removeFromSelection(selection, nodeType) {
|
|
370
|
-
var _a, _b;
|
|
371
359
|
if (!this.renderer) {
|
|
372
360
|
return;
|
|
373
361
|
}
|
|
@@ -380,20 +368,19 @@ class RTxtEditor {
|
|
|
380
368
|
}
|
|
381
369
|
if ((0, common_1.aryRemoveItem)(node.t, nodeType)) {
|
|
382
370
|
const desc = this.renderer.descriptors[nodeType];
|
|
383
|
-
|
|
371
|
+
desc?.remove?.(node);
|
|
384
372
|
}
|
|
385
373
|
}
|
|
386
|
-
|
|
374
|
+
this.renderer?.queueExport();
|
|
387
375
|
}
|
|
388
376
|
someHaveNodeType(selection, nodeType) {
|
|
389
|
-
var _a;
|
|
390
377
|
for (const node of selection.nodes) {
|
|
391
378
|
if (typeof node.t === 'string') {
|
|
392
379
|
if (node.t === nodeType) {
|
|
393
380
|
return true;
|
|
394
381
|
}
|
|
395
382
|
}
|
|
396
|
-
else if (
|
|
383
|
+
else if (node.t?.length) {
|
|
397
384
|
if (node.t.includes(nodeType)) {
|
|
398
385
|
return true;
|
|
399
386
|
}
|
|
@@ -405,14 +392,13 @@ class RTxtEditor {
|
|
|
405
392
|
return false;
|
|
406
393
|
}
|
|
407
394
|
allHaveNodeType(selection, nodeType) {
|
|
408
|
-
var _a;
|
|
409
395
|
for (const node of selection.nodes) {
|
|
410
396
|
if (typeof node.t === 'string') {
|
|
411
397
|
if (node.t !== nodeType) {
|
|
412
398
|
return false;
|
|
413
399
|
}
|
|
414
400
|
}
|
|
415
|
-
else if (
|
|
401
|
+
else if (node.t?.length) {
|
|
416
402
|
if (!node.t.includes(nodeType)) {
|
|
417
403
|
return false;
|
|
418
404
|
}
|
|
@@ -424,13 +410,12 @@ class RTxtEditor {
|
|
|
424
410
|
return true;
|
|
425
411
|
}
|
|
426
412
|
syncElemToDoc() {
|
|
427
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
428
413
|
if (!this.renderer) {
|
|
429
414
|
return;
|
|
430
415
|
}
|
|
431
416
|
const startEmpty = this.renderer.isEmpty;
|
|
432
|
-
const selection =
|
|
433
|
-
const caretNode = (selection &&
|
|
417
|
+
const selection = globalThis.document?.getSelection();
|
|
418
|
+
const caretNode = (selection && selection?.anchorNode === selection?.focusNode) ? selection.anchorNode : null;
|
|
434
419
|
let setCaretElem = null;
|
|
435
420
|
let reRender = false;
|
|
436
421
|
const docElem = this.renderer.elem;
|
|
@@ -438,7 +423,7 @@ class RTxtEditor {
|
|
|
438
423
|
return;
|
|
439
424
|
}
|
|
440
425
|
let hasChange = false;
|
|
441
|
-
const lineElemType =
|
|
426
|
+
const lineElemType = this.renderer.options.lineElem ?? rtxt_types_1.defaultRTxtLineElem;
|
|
442
427
|
let lineIndex = 0;
|
|
443
428
|
let nodeIndex = 0;
|
|
444
429
|
let lastFormattedElem = null;
|
|
@@ -450,7 +435,7 @@ class RTxtEditor {
|
|
|
450
435
|
if (!(lineElem instanceof Element)) {
|
|
451
436
|
hasChange = true;
|
|
452
437
|
reRender = true;
|
|
453
|
-
const replaceWith =
|
|
438
|
+
const replaceWith = globalThis.document?.createElement(lineElemType);
|
|
454
439
|
if (replaceWith) {
|
|
455
440
|
replaceWith.textContent = lineElem.textContent;
|
|
456
441
|
docElem.insertBefore(replaceWith, lineElem);
|
|
@@ -462,7 +447,7 @@ class RTxtEditor {
|
|
|
462
447
|
if (!lineIsNode) {
|
|
463
448
|
hasChange = true;
|
|
464
449
|
reRender = true;
|
|
465
|
-
lineElem.innerHTML = `<${lineElemType}>${(0, common_1.escapeHtml)(
|
|
450
|
+
lineElem.innerHTML = `<${lineElemType}>${(0, common_1.escapeHtml)(lineElem.textContent ?? '')}</${lineElemType}>`;
|
|
466
451
|
}
|
|
467
452
|
const lineAttValue = lineElem.getAttribute(rtxt_types_1.rTxtLineIndexAtt);
|
|
468
453
|
if (!lineAttValue || lineAttValue !== lineIndex.toString()) {
|
|
@@ -475,7 +460,7 @@ class RTxtEditor {
|
|
|
475
460
|
continue;
|
|
476
461
|
}
|
|
477
462
|
if (!(_elem instanceof Element)) {
|
|
478
|
-
const replaceWith =
|
|
463
|
+
const replaceWith = globalThis.document?.createElement(rtxt_types_1.defaultRTxtNodeType);
|
|
479
464
|
replaceWith.textContent = _elem.textContent;
|
|
480
465
|
lineElem.insertBefore(replaceWith, _elem);
|
|
481
466
|
_elem.remove();
|
|
@@ -503,7 +488,7 @@ class RTxtEditor {
|
|
|
503
488
|
else if ((0, rtxt_internal_1.hasForeignElems)(elem)) {
|
|
504
489
|
reRender = true;
|
|
505
490
|
hasChange = true;
|
|
506
|
-
elem.innerHTML = (0, common_1.escapeHtml)(
|
|
491
|
+
elem.innerHTML = (0, common_1.escapeHtml)(elem.textContent ?? '');
|
|
507
492
|
}
|
|
508
493
|
const indexAttValue = elem.getAttribute(rtxt_types_1.rTxtIndexLookupAtt);
|
|
509
494
|
if (!indexAttValue || indexAttValue !== nodeIndex.toString()) {
|
|
@@ -512,11 +497,11 @@ class RTxtEditor {
|
|
|
512
497
|
}
|
|
513
498
|
const hasFocus = caretNode ? true : false;
|
|
514
499
|
const textNode = (0, rtxt_internal_1.getTextNode)(elem);
|
|
515
|
-
if (
|
|
500
|
+
if (textNode?.textContent && textNode.textContent.length !== 1 && Array.from(textNode.textContent).length !== 1) {
|
|
516
501
|
hasChange = true;
|
|
517
502
|
//split
|
|
518
503
|
const text = Array.from(textNode.textContent);
|
|
519
|
-
textNode.textContent =
|
|
504
|
+
textNode.textContent = text[0] ?? null;
|
|
520
505
|
const elemNode = (0, rtxt_internal_1.getNodeElem)(textNode);
|
|
521
506
|
if (!elemNode) {
|
|
522
507
|
break;
|
|
@@ -528,9 +513,9 @@ class RTxtEditor {
|
|
|
528
513
|
nextNode.setAttribute(rtxt_types_1.rTxtIndexLookupAtt, nodeIndex.toString());
|
|
529
514
|
const nextTextNode = (0, rtxt_internal_1.getTextNode)(nextNode);
|
|
530
515
|
if (nextTextNode) {
|
|
531
|
-
nextTextNode.textContent = char
|
|
516
|
+
nextTextNode.textContent = char ?? null;
|
|
532
517
|
}
|
|
533
|
-
|
|
518
|
+
elemNode.parentElement?.insertBefore(nextNode, insertBefore);
|
|
534
519
|
if (hasFocus) {
|
|
535
520
|
setCaretElem = nextNode;
|
|
536
521
|
}
|
|
@@ -551,7 +536,7 @@ class RTxtEditor {
|
|
|
551
536
|
this.renderer.doc = doc;
|
|
552
537
|
}
|
|
553
538
|
if (reRender) {
|
|
554
|
-
const caretIndex = setCaretElem
|
|
539
|
+
const caretIndex = setCaretElem?.getAttribute(rtxt_types_1.rTxtIndexLookupAtt);
|
|
555
540
|
this.renderer.render();
|
|
556
541
|
if (caretIndex) {
|
|
557
542
|
setCaretElem = docElem.querySelector(`[${rtxt_types_1.rTxtIndexLookupAtt}='${caretIndex}']`);
|
|
@@ -563,35 +548,32 @@ class RTxtEditor {
|
|
|
563
548
|
this.renderer.focus();
|
|
564
549
|
}
|
|
565
550
|
else if (caretTo && selection) {
|
|
566
|
-
selection.collapse(caretTo,
|
|
551
|
+
selection.collapse(caretTo, caretTo.textContent?.length || 1);
|
|
567
552
|
}
|
|
568
553
|
else if (selection) {
|
|
569
554
|
const last = (0, rtxt_internal_1.getTextNode)(docElem, true, false);
|
|
570
555
|
if (last) {
|
|
571
556
|
selection.removeAllRanges();
|
|
572
|
-
selection.collapse(last,
|
|
557
|
+
selection.collapse(last, last.textContent?.length);
|
|
573
558
|
}
|
|
574
559
|
}
|
|
575
560
|
}
|
|
576
561
|
getElementAt(index) {
|
|
577
|
-
|
|
578
|
-
const docElem = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.elem;
|
|
562
|
+
const docElem = this.renderer?.elem;
|
|
579
563
|
if (!docElem) {
|
|
580
564
|
return undefined;
|
|
581
565
|
}
|
|
582
|
-
return
|
|
566
|
+
return docElem.querySelector(`[${rtxt_types_1.rTxtIndexLookupAtt}='${index}']`) ?? undefined;
|
|
583
567
|
}
|
|
584
568
|
getStyleAt(index) {
|
|
585
|
-
var _a, _b, _c;
|
|
586
569
|
const elem = this.getElementAt(index);
|
|
587
570
|
if (!elem) {
|
|
588
571
|
return undefined;
|
|
589
572
|
}
|
|
590
|
-
return
|
|
573
|
+
return globalThis.window?.getComputedStyle?.((0, rtxt_internal_1.getDeepestElem)(elem)) ?? undefined;
|
|
591
574
|
}
|
|
592
575
|
getCursorLine() {
|
|
593
|
-
|
|
594
|
-
const node = (_a = this.selection) === null || _a === void 0 ? void 0 : _a.cursorNode;
|
|
576
|
+
const node = this.selection?.cursorNode;
|
|
595
577
|
if (!node || !this.renderer) {
|
|
596
578
|
return undefined;
|
|
597
579
|
}
|
|
@@ -624,14 +606,12 @@ class RTxtEditor {
|
|
|
624
606
|
}
|
|
625
607
|
}
|
|
626
608
|
queueRenderer(renderer) {
|
|
627
|
-
var _a;
|
|
628
609
|
this.rendererQueue.push(renderer);
|
|
629
|
-
this.renderer =
|
|
610
|
+
this.renderer = this.rendererQueue[this.rendererQueue.length - 1] ?? null;
|
|
630
611
|
}
|
|
631
612
|
dequeueRenderer(renderer) {
|
|
632
|
-
var _a;
|
|
633
613
|
if ((0, common_1.aryRemoveItem)(this.rendererQueue, renderer)) {
|
|
634
|
-
this.renderer =
|
|
614
|
+
this.renderer = this.rendererQueue[this.rendererQueue.length - 1] ?? null;
|
|
635
615
|
}
|
|
636
616
|
}
|
|
637
617
|
}
|