@cocreate/text 1.20.11 → 1.20.13

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.
@@ -1,32 +1,32 @@
1
- /*globals CustomEvent*/
2
- import action from '@cocreate/actions';
3
- import crud from '@cocreate/crud-client';
4
- import crdt from '@cocreate/crdt';
5
-
6
- function save(btn){
7
- const { collection, document_id, name, namespace, room, broadcast, broadcastSender, isUpsert} = crud.getAttributes(btn);
8
- crdt.getText({collection, document_id, name}).then(response => {
9
- crud.updateDocument({
10
- collection,
11
- document: {
12
- _id: document_id,
13
- [name]: response
14
- },
15
- upsert: isUpsert,
16
- namespace,
17
- room,
18
- broadcast,
19
- broadcastSender
20
- });
21
-
22
- document.dispatchEvent(new CustomEvent('savedDomText'));
23
- });
24
- }
25
-
26
- action.init({
27
- name: "saveDomText",
28
- endEvent: "savedDomText",
29
- callback: (btn, data) => {
30
- save(btn);
31
- },
32
- });
1
+ /*globals CustomEvent*/
2
+ import action from '@cocreate/actions';
3
+ import crud from '@cocreate/crud-client';
4
+ import crdt from '@cocreate/crdt';
5
+
6
+ function save(btn){
7
+ const { collection, document_id, name, namespace, room, broadcast, broadcastSender, isUpsert} = crud.getAttributes(btn);
8
+ crdt.getText({collection, document_id, name}).then(response => {
9
+ crud.updateDocument({
10
+ collection,
11
+ document: {
12
+ _id: document_id,
13
+ [name]: response
14
+ },
15
+ upsert: isUpsert,
16
+ namespace,
17
+ room,
18
+ broadcast,
19
+ broadcastSender
20
+ });
21
+
22
+ document.dispatchEvent(new CustomEvent('savedDomText'));
23
+ });
24
+ }
25
+
26
+ action.init({
27
+ name: "saveDomText",
28
+ endEvent: "savedDomText",
29
+ callback: (btn, data) => {
30
+ save(btn);
31
+ },
32
+ });
package/src/updateDom.js CHANGED
@@ -1,209 +1,209 @@
1
- import {sendPosition, _dispatchInputEvent} from './index';
2
- import {getSelection, processSelection, getElementPosition} from '@cocreate/selection';
3
- import {domParser} from '@cocreate/utils';
4
-
5
- export function updateDom({domTextEditor, value, start, end, html}) {
6
- if (!domTextEditor.htmlString)
7
- domTextEditor.htmlString = html;
8
- if (start < 0 || start > domTextEditor.htmlString.length)
9
- throw new Error('position is out of range');
10
-
11
- let {element, path, position, type} = getElementPosition(domTextEditor.htmlString, start, end);
12
- parseHtml(domTextEditor, html);
13
-
14
- let domEl, oldEl, curCaret, newEl;
15
- // console.log('element', element)
16
- // console.log('path', path)
17
-
18
- try {
19
- newEl = domTextEditor.newHtml.querySelector(path);
20
- } catch(err){
21
- console.log('error', err)
22
- }
23
-
24
- if (path && !newEl){
25
- let index
26
- do {
27
- index = path.lastIndexOf(' >')
28
- if (index != -1)
29
- path = path.slice(0, index)
30
- newEl = domTextEditor.newHtml.querySelector(path);
31
- } while (!newEl && index != -1)
32
- }
33
-
34
- if (!newEl){
35
- // console.log("no newEL", path)
36
- newEl = domTextEditor.cloneNode(true);
37
- if (html != undefined)
38
- newEl.innerHTML = html;
39
- else
40
- newEl.innerHTML = domTextEditor.htmlString;
41
- domEl = domTextEditor;
42
- type = 'innerHTML';
43
- }
44
- else if (element.tagName == 'HTML') {
45
- // console.log('element = html')
46
- domEl = domTextEditor;
47
- type = 'innerHTML';
48
- }
49
- else if (path) {
50
- // console.log("else path", path)
51
- domEl = domTextEditor.querySelector(path);
52
- // if (!domEl || !oldEl){
53
- // let eid = newEl.getAttribute('eid');
54
- // if (!domEl && eid){
55
- // domEl = domTextEditor.querySelector(`[eid='${eid}']`);
56
- // }
57
- // if (!oldEl && eid){
58
- // oldEl = domTextEditor.oldHtml.querySelector(`[eid='${eid}']`);
59
- // }
60
- // }
61
- }
62
-
63
- if (!domEl) {
64
- // console.log('no domEl')
65
- let index
66
- do {
67
- index = path.lastIndexOf(' >')
68
- if (index != -1)
69
- path = path.slice(0, index)
70
- domEl = domTextEditor.querySelector(path);
71
- } while (!domEl && index != -1)
72
-
73
- if (domEl) {
74
- newEl = domTextEditor.newHtml.querySelector(path);
75
- }
76
-
77
- if (!domEl || !newEl){
78
- newEl = domTextEditor.cloneNode(true);
79
- if (html != undefined)
80
- newEl.innerHTML = html;
81
- else
82
- newEl.innerHTML = domTextEditor.htmlString;
83
- domEl = domTextEditor;
84
- type = 'innerHTML';
85
- }
86
- }
87
-
88
- if (domEl && newEl) {
89
- let activeElement = domEl.ownerDocument.activeElement;
90
- if (activeElement == domEl)
91
- curCaret = getSelection(activeElement);
92
- else if (activeElement && activeElement.tagName == 'BODY')
93
- curCaret = getSelection(domEl);
94
- else
95
- curCaret = getSelection(activeElement);
96
-
97
-
98
- if (!value && type != 'isStartTag' && type != 'textNode'){
99
- type = 'innerHTML';
100
- }
101
-
102
- // console.log('domEl', domEl)
103
- // console.log('newEl', newEl)
104
- if (start != end && type == 'innerHTML') {
105
- domTextEditor.htmlString = html;
106
- if (domEl.tagName != 'HTML'){
107
- if (newEl.parentElement) {
108
- domEl.parentElement.replaceChildren(...newEl.parentElement.childNodes);
109
- // console.log('parent', domEl.parentElement)
110
- } else {
111
- domEl.replaceChildren(...newEl.childNodes);
112
- // console.log('domEl', domEl)
113
- }
114
- }
115
- else {
116
- domEl.replaceChildren(...newEl.childNodes);
117
- // console.log('Html tag', domEl)
118
- }
119
- if (curCaret && curCaret.range) {
120
- curCaret.range.startContainer = domEl;
121
- curCaret.range.endContainer = domEl;
122
- }
123
- }
124
- else if (type == 'isStartTag') {
125
- oldEl = domTextEditor.oldHtml.querySelector(path);
126
- if (!oldEl && domEl.tagName == 'HTML')
127
- oldEl = domTextEditor.oldHtml
128
- assignAttributes(newEl, oldEl, domEl);
129
- // console.log('isStartTag', domEl, newEl)
130
-
131
- }
132
- else if (type == 'insertAdjacent') {
133
- domEl.insertAdjacentHTML(position, value);
134
- // console.log('insertAdjacent', domEl, value)
135
- }
136
- else if (type == 'textNode'){
137
- if (start != end)
138
- domTextEditor.htmlString = html;
139
- domEl.innerHTML = newEl.innerHTML;
140
- // console.log('textnode', domEl.innerHTML, newEl.innerHTML)
141
-
142
- }
143
- else if (type == 'innerHTML') {
144
- domEl.replaceChildren(...newEl.childNodes);
145
- // console.log('innerHtml', domEl, newEl)
146
- }
147
- domTextEditor.htmlString = html;
148
-
149
- if (curCaret && start >= 0 && end >= 0) {
150
- if (curCaret.range && curCaret.range.startContainer == domEl)
151
- if (curCaret.start >= curCaret.range.startOffset) {
152
- let p = processSelection(domEl, value, curCaret.start, curCaret.end, start, end, curCaret.range);
153
- sendPosition(domEl);
154
- _dispatchInputEvent(p.element, p.value, p.start, p.end, p.prev_start, p.prev_end);
155
- }
156
- }
157
-
158
- if (['HTML', 'HEAD', 'BODY', 'SCRIPT'].includes(newEl.tagName)){
159
- let scripts;
160
- if (newEl.tagName == 'SCRIPT'){
161
- scripts = [newEl];
162
- }
163
- else{
164
- scripts = domEl.querySelectorAll('script');
165
- }
166
- for (let script of scripts) {
167
- let newScript = domEl.ownerDocument.createElement('script');
168
- for(let attribute of script.attributes) {
169
- newScript.setAttribute(attribute.name, attribute.value);
170
- }
171
- newScript.innerHTML = script.innerHTML;
172
- script.replaceWith(newScript);
173
- }
174
- }
175
- }
176
- }
177
-
178
- function parseHtml(domTextEditor, html) {
179
- var dom = domParser(html);
180
- if (domTextEditor.newHtml) {
181
- domTextEditor.oldHtml = domTextEditor.newHtml;
182
- } else {
183
- domTextEditor.oldHtml = dom;
184
- }
185
- domTextEditor.newHtml = dom;
186
- }
187
-
188
- function assignAttributes(newEl, oldEl, domEl) {
189
- if (!oldEl) return;
190
- for(let newElAtt of newEl.attributes) {
191
- if (!oldEl.attributes[newElAtt.name] || oldEl.attributes[newElAtt.name].value !== newElAtt.value)
192
- try {
193
- domEl.setAttribute(newElAtt.name, newElAtt.value);
194
- }
195
- catch(err) {
196
- throw new Error("assignAttributes: " + err.message, err.name);
197
- }
198
- }
199
-
200
- if (newEl.attributes.length !== oldEl.attributes.length) {
201
- for(let i = 0, len = oldEl.attributes.length; i < len; i++) {
202
- let oldElAtt = oldEl.attributes[i];
203
- if (!newEl.attributes[oldElAtt.name]) {
204
- domEl.removeAttribute(oldElAtt.name);
205
- i--, len--;
206
- }
207
- }
208
- }
1
+ import {sendPosition, _dispatchInputEvent} from './index';
2
+ import {getSelection, processSelection, getElementPosition} from '@cocreate/selection';
3
+ import {domParser} from '@cocreate/utils';
4
+
5
+ export function updateDom({domTextEditor, value, start, end, html}) {
6
+ if (!domTextEditor.htmlString)
7
+ domTextEditor.htmlString = html;
8
+ if (start < 0 || start > domTextEditor.htmlString.length)
9
+ throw new Error('position is out of range');
10
+
11
+ let {element, path, position, type} = getElementPosition(domTextEditor.htmlString, start, end);
12
+ parseHtml(domTextEditor, html);
13
+
14
+ let domEl, oldEl, curCaret, newEl;
15
+ // console.log('element', element)
16
+ // console.log('path', path)
17
+
18
+ try {
19
+ newEl = domTextEditor.newHtml.querySelector(path);
20
+ } catch(err){
21
+ console.log('error', err)
22
+ }
23
+
24
+ if (path && !newEl){
25
+ let index
26
+ do {
27
+ index = path.lastIndexOf(' >')
28
+ if (index != -1)
29
+ path = path.slice(0, index)
30
+ newEl = domTextEditor.newHtml.querySelector(path);
31
+ } while (!newEl && index != -1)
32
+ }
33
+
34
+ if (!newEl){
35
+ // console.log("no newEL", path)
36
+ newEl = domTextEditor.cloneNode(true);
37
+ if (html != undefined)
38
+ newEl.innerHTML = html;
39
+ else
40
+ newEl.innerHTML = domTextEditor.htmlString;
41
+ domEl = domTextEditor;
42
+ type = 'innerHTML';
43
+ }
44
+ else if (element.tagName == 'HTML') {
45
+ // console.log('element = html')
46
+ domEl = domTextEditor;
47
+ type = 'innerHTML';
48
+ }
49
+ else if (path) {
50
+ // console.log("else path", path)
51
+ domEl = domTextEditor.querySelector(path);
52
+ // if (!domEl || !oldEl){
53
+ // let eid = newEl.getAttribute('eid');
54
+ // if (!domEl && eid){
55
+ // domEl = domTextEditor.querySelector(`[eid='${eid}']`);
56
+ // }
57
+ // if (!oldEl && eid){
58
+ // oldEl = domTextEditor.oldHtml.querySelector(`[eid='${eid}']`);
59
+ // }
60
+ // }
61
+ }
62
+
63
+ if (!domEl) {
64
+ // console.log('no domEl')
65
+ let index
66
+ do {
67
+ index = path.lastIndexOf(' >')
68
+ if (index != -1)
69
+ path = path.slice(0, index)
70
+ domEl = domTextEditor.querySelector(path);
71
+ } while (!domEl && index != -1)
72
+
73
+ if (domEl) {
74
+ newEl = domTextEditor.newHtml.querySelector(path);
75
+ }
76
+
77
+ if (!domEl || !newEl){
78
+ newEl = domTextEditor.cloneNode(true);
79
+ if (html != undefined)
80
+ newEl.innerHTML = html;
81
+ else
82
+ newEl.innerHTML = domTextEditor.htmlString;
83
+ domEl = domTextEditor;
84
+ type = 'innerHTML';
85
+ }
86
+ }
87
+
88
+ if (domEl && newEl) {
89
+ let activeElement = domEl.ownerDocument.activeElement;
90
+ if (activeElement == domEl)
91
+ curCaret = getSelection(activeElement);
92
+ else if (activeElement && activeElement.tagName == 'BODY')
93
+ curCaret = getSelection(domEl);
94
+ else
95
+ curCaret = getSelection(activeElement);
96
+
97
+
98
+ if (!value && type != 'isStartTag' && type != 'textNode'){
99
+ type = 'innerHTML';
100
+ }
101
+
102
+ // console.log('domEl', domEl)
103
+ // console.log('newEl', newEl)
104
+ if (start != end && type == 'innerHTML') {
105
+ domTextEditor.htmlString = html;
106
+ if (domEl.tagName != 'HTML'){
107
+ if (newEl.parentElement) {
108
+ domEl.parentElement.replaceChildren(...newEl.parentElement.childNodes);
109
+ // console.log('parent', domEl.parentElement)
110
+ } else {
111
+ domEl.replaceChildren(...newEl.childNodes);
112
+ // console.log('domEl', domEl)
113
+ }
114
+ }
115
+ else {
116
+ domEl.replaceChildren(...newEl.childNodes);
117
+ // console.log('Html tag', domEl)
118
+ }
119
+ if (curCaret && curCaret.range) {
120
+ curCaret.range.startContainer = domEl;
121
+ curCaret.range.endContainer = domEl;
122
+ }
123
+ }
124
+ else if (type == 'isStartTag') {
125
+ oldEl = domTextEditor.oldHtml.querySelector(path);
126
+ if (!oldEl && domEl.tagName == 'HTML')
127
+ oldEl = domTextEditor.oldHtml
128
+ assignAttributes(newEl, oldEl, domEl);
129
+ // console.log('isStartTag', domEl, newEl)
130
+
131
+ }
132
+ else if (type == 'insertAdjacent') {
133
+ domEl.insertAdjacentHTML(position, value);
134
+ // console.log('insertAdjacent', domEl, value)
135
+ }
136
+ else if (type == 'textNode'){
137
+ if (start != end)
138
+ domTextEditor.htmlString = html;
139
+ domEl.innerHTML = newEl.innerHTML;
140
+ // console.log('textnode', domEl.innerHTML, newEl.innerHTML)
141
+
142
+ }
143
+ else if (type == 'innerHTML') {
144
+ domEl.replaceChildren(...newEl.childNodes);
145
+ // console.log('innerHtml', domEl, newEl)
146
+ }
147
+ domTextEditor.htmlString = html;
148
+
149
+ if (curCaret && start >= 0 && end >= 0) {
150
+ if (curCaret.range && curCaret.range.startContainer == domEl)
151
+ if (curCaret.start >= curCaret.range.startOffset) {
152
+ let p = processSelection(domEl, value, curCaret.start, curCaret.end, start, end, curCaret.range);
153
+ sendPosition(domEl);
154
+ _dispatchInputEvent(p.element, p.value, p.start, p.end, p.prev_start, p.prev_end);
155
+ }
156
+ }
157
+
158
+ if (['HTML', 'HEAD', 'BODY', 'SCRIPT'].includes(newEl.tagName)){
159
+ let scripts;
160
+ if (newEl.tagName == 'SCRIPT'){
161
+ scripts = [newEl];
162
+ }
163
+ else{
164
+ scripts = domEl.querySelectorAll('script');
165
+ }
166
+ for (let script of scripts) {
167
+ let newScript = domEl.ownerDocument.createElement('script');
168
+ for(let attribute of script.attributes) {
169
+ newScript.setAttribute(attribute.name, attribute.value);
170
+ }
171
+ newScript.innerHTML = script.innerHTML;
172
+ script.replaceWith(newScript);
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ function parseHtml(domTextEditor, html) {
179
+ var dom = domParser(html);
180
+ if (domTextEditor.newHtml) {
181
+ domTextEditor.oldHtml = domTextEditor.newHtml;
182
+ } else {
183
+ domTextEditor.oldHtml = dom;
184
+ }
185
+ domTextEditor.newHtml = dom;
186
+ }
187
+
188
+ function assignAttributes(newEl, oldEl, domEl) {
189
+ if (!oldEl) return;
190
+ for(let newElAtt of newEl.attributes) {
191
+ if (!oldEl.attributes[newElAtt.name] || oldEl.attributes[newElAtt.name].value !== newElAtt.value)
192
+ try {
193
+ domEl.setAttribute(newElAtt.name, newElAtt.value);
194
+ }
195
+ catch(err) {
196
+ throw new Error("assignAttributes: " + err.message, err.name);
197
+ }
198
+ }
199
+
200
+ if (newEl.attributes.length !== oldEl.attributes.length) {
201
+ for(let i = 0, len = oldEl.attributes.length; i < len; i++) {
202
+ let oldElAtt = oldEl.attributes[i];
203
+ if (!newEl.attributes[oldElAtt.name]) {
204
+ domEl.removeAttribute(oldElAtt.name);
205
+ i--, len--;
206
+ }
207
+ }
208
+ }
209
209
  }
package/src/updateText.js CHANGED
@@ -1,79 +1,79 @@
1
- import crud from '@cocreate/crud-client';
2
- import crdt from '@cocreate/crdt';
3
- import {getStringPosition} from '@cocreate/selection';
4
-
5
- export function insertAdjacentElement({ domTextEditor, target, position, element, elementValue }) {
6
- let remove;
7
- if (element && !elementValue) {
8
- remove = getStringPosition({ string: domTextEditor.htmlString, target: element });
9
- if (!remove.start && !remove.end)
10
- throw new Error('insertAdjacentElement: element not found');
11
- elementValue = domTextEditor.htmlString.substring(remove.start, remove.end);
12
- }
13
-
14
- let {start} = getStringPosition({ string: domTextEditor.htmlString, target, position, value: elementValue });
15
- if (remove)
16
- _updateText({domTextEditor, start: remove.start, end: remove.end});
17
- if (remove && remove.start < start){
18
- let length = remove.end - remove.start;
19
- _updateText({ domTextEditor, value: elementValue, start: start - length});
20
- }
21
- else
22
- _updateText({ domTextEditor, value: elementValue, start});
23
- }
24
-
25
- export function removeElement({ domTextEditor, target }) {
26
- updateDomText({ domTextEditor, target });
27
- }
28
-
29
- export function setInnerText({ domTextEditor, target, value, start, end }) {
30
- updateDomText({ domTextEditor, target, value, pos: {start, end} });
31
- }
32
-
33
- export function setClass({ domTextEditor, target, value }) {
34
- updateDomText({ domTextEditor, target, attribute: 'class', value });
35
- }
36
- export function removeClass({ domTextEditor, target, value }) {
37
- updateDomText({ domTextEditor, target, attribute: 'class', value, remove: true });
38
- }
39
-
40
- export function setStyle({ domTextEditor, target, property, value }) {
41
- updateDomText({ domTextEditor, target, attribute: 'style', property, value });
42
- }
43
-
44
- export function removeStyle({ domTextEditor, target, property }) {
45
- updateDomText({ domTextEditor, target, attribute: 'style', property, remove: true });
46
- }
47
-
48
- export function setAttribute({ domTextEditor, target, name, value }) {
49
- updateDomText({ domTextEditor, target, attribute: name, value });
50
- }
51
-
52
- export function removeAttribute({ domTextEditor, target, name }) {
53
- updateDomText({ domTextEditor, target, attribute: name, remove: 'true'});
54
- }
55
-
56
- export function replaceInnerText({ domTextEditor, target, value }) {
57
- updateDomText({ domTextEditor, target, value });
58
- }
59
-
60
- export function updateDomText({ domTextEditor, target, position, element, elementValue, attribute, value, property, pos, remove }) {
61
- let {start, end, newValue} = getStringPosition({ string: domTextEditor.htmlString, target, attribute, property, value, remove });
62
- if (pos){
63
- start += pos.start;
64
- end += pos.end;
65
- }
66
- if (start != end)
67
- _updateText({domTextEditor, start, end});
68
- if (attribute && remove != 'true' || attribute && value)
69
- _updateText({ domTextEditor, value: ` ${attribute}="${newValue}"`, start });
70
- else if (value)
71
- _updateText({ domTextEditor, value, start });
72
- }
73
-
74
- function _updateText({ domTextEditor, value, start, end}) {
75
- if (domTextEditor.tagName =='HTML')
76
- domTextEditor = domTextEditor.ownerDocument.defaultView.frameElement;
77
- const { collection, document_id, name, isCrud } = crud.getAttributes(domTextEditor);
78
- crdt.updateText({ collection, document_id, name, value, start, length: end - start, crud: isCrud });
79
- }
1
+ import crud from '@cocreate/crud-client';
2
+ import crdt from '@cocreate/crdt';
3
+ import {getStringPosition} from '@cocreate/selection';
4
+
5
+ export function insertAdjacentElement({ domTextEditor, target, position, element, elementValue }) {
6
+ let remove;
7
+ if (element && !elementValue) {
8
+ remove = getStringPosition({ string: domTextEditor.htmlString, target: element });
9
+ if (!remove.start && !remove.end)
10
+ throw new Error('insertAdjacentElement: element not found');
11
+ elementValue = domTextEditor.htmlString.substring(remove.start, remove.end);
12
+ }
13
+
14
+ let {start} = getStringPosition({ string: domTextEditor.htmlString, target, position, value: elementValue });
15
+ if (remove)
16
+ _updateText({domTextEditor, start: remove.start, end: remove.end});
17
+ if (remove && remove.start < start){
18
+ let length = remove.end - remove.start;
19
+ _updateText({ domTextEditor, value: elementValue, start: start - length});
20
+ }
21
+ else
22
+ _updateText({ domTextEditor, value: elementValue, start});
23
+ }
24
+
25
+ export function removeElement({ domTextEditor, target }) {
26
+ updateDomText({ domTextEditor, target });
27
+ }
28
+
29
+ export function setInnerText({ domTextEditor, target, value, start, end }) {
30
+ updateDomText({ domTextEditor, target, value, pos: {start, end} });
31
+ }
32
+
33
+ export function setClass({ domTextEditor, target, value }) {
34
+ updateDomText({ domTextEditor, target, attribute: 'class', value });
35
+ }
36
+ export function removeClass({ domTextEditor, target, value }) {
37
+ updateDomText({ domTextEditor, target, attribute: 'class', value, remove: true });
38
+ }
39
+
40
+ export function setStyle({ domTextEditor, target, property, value }) {
41
+ updateDomText({ domTextEditor, target, attribute: 'style', property, value });
42
+ }
43
+
44
+ export function removeStyle({ domTextEditor, target, property }) {
45
+ updateDomText({ domTextEditor, target, attribute: 'style', property, remove: true });
46
+ }
47
+
48
+ export function setAttribute({ domTextEditor, target, name, value }) {
49
+ updateDomText({ domTextEditor, target, attribute: name, value });
50
+ }
51
+
52
+ export function removeAttribute({ domTextEditor, target, name }) {
53
+ updateDomText({ domTextEditor, target, attribute: name, remove: 'true'});
54
+ }
55
+
56
+ export function replaceInnerText({ domTextEditor, target, value }) {
57
+ updateDomText({ domTextEditor, target, value });
58
+ }
59
+
60
+ export function updateDomText({ domTextEditor, target, position, element, elementValue, attribute, value, property, pos, remove }) {
61
+ let {start, end, newValue} = getStringPosition({ string: domTextEditor.htmlString, target, attribute, property, value, remove });
62
+ if (pos){
63
+ start += pos.start;
64
+ end += pos.end;
65
+ }
66
+ if (start != end)
67
+ _updateText({domTextEditor, start, end});
68
+ if (attribute && remove != 'true' || attribute && value)
69
+ _updateText({ domTextEditor, value: ` ${attribute}="${newValue}"`, start });
70
+ else if (value)
71
+ _updateText({ domTextEditor, value, start });
72
+ }
73
+
74
+ function _updateText({ domTextEditor, value, start, end}) {
75
+ if (domTextEditor.tagName =='HTML')
76
+ domTextEditor = domTextEditor.ownerDocument.defaultView.frameElement;
77
+ const { collection, document_id, name, isCrud } = crud.getAttributes(domTextEditor);
78
+ crdt.updateText({ collection, document_id, name, value, start, length: end - start, crud: isCrud });
79
+ }