@cocreate/text 1.13.3 → 1.13.4
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/CHANGELOG.md +7 -0
- package/demo/demos.1.html +24 -0
- package/package.json +1 -1
- package/src/index.js +7 -2
- package/src/updateDom.js +2 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.13.4](https://github.com/CoCreate-app/CoCreate-text/compare/v1.13.3...v1.13.4) (2021-12-08)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* observer attribute contenteditable, get element to update using selection range.element ([2bb32bf](https://github.com/CoCreate-app/CoCreate-text/commit/2bb32bf5650505c76efb44d2f941b1b249deaebf))
|
7
|
+
|
1
8
|
## [1.13.3](https://github.com/CoCreate-app/CoCreate-text/compare/v1.13.2...v1.13.3) (2021-11-29)
|
2
9
|
|
3
10
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
8
|
+
<title>Text | CoCreate</title>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body class="padding:20px">
|
12
|
+
<form collection="apples1" document_id="61ad22d7a8b6b4001aa360d1">
|
13
|
+
<textarea name="name1" class="width:100%" rows="10"></textarea>
|
14
|
+
<textarea name="name2" class="width:100%" rows="10"></textarea>
|
15
|
+
<iframe name='name2' width="100%" contenteditable></iframe>
|
16
|
+
|
17
|
+
</form>
|
18
|
+
|
19
|
+
<!--<script src="../dist/CoCreate-text.js" ></script>-->
|
20
|
+
<script src="../../../CoCreateJS/dist/CoCreate.js"></script>
|
21
|
+
|
22
|
+
</body>
|
23
|
+
|
24
|
+
</html>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -183,7 +183,10 @@ function _removeEventListeners (element) {
|
|
183
183
|
|
184
184
|
export function sendPosition (element) {
|
185
185
|
if (!element) return;
|
186
|
-
|
186
|
+
|
187
|
+
const { start, end, range } = getSelection(element);
|
188
|
+
if(range && range.element)
|
189
|
+
element = range.element;
|
187
190
|
if (element.tagName == 'HTML' && !element.hasAttribute('collection') || !element.hasAttribute('collection'))
|
188
191
|
element = element.ownerDocument.defaultView.frameElement;
|
189
192
|
if (!element) return;
|
@@ -193,6 +196,8 @@ export function sendPosition (element) {
|
|
193
196
|
}
|
194
197
|
|
195
198
|
function updateText ({element, value, start, end, range}) {
|
199
|
+
if(range && range.element)
|
200
|
+
element = range.element;
|
196
201
|
if (element.tagName == 'HTML' && !element.hasAttribute('collection'))
|
197
202
|
element = element.ownerDocument.defaultView.frameElement;
|
198
203
|
const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(element);
|
@@ -310,7 +315,7 @@ observer.init({
|
|
310
315
|
observer.init({
|
311
316
|
name: 'CoCreateTextAttribtes',
|
312
317
|
observe: ['attributes'],
|
313
|
-
attributeName: ['collection', 'document_id', 'name'],
|
318
|
+
attributeName: ['collection', 'document_id', 'name', 'contenteditable'],
|
314
319
|
target: selectors,
|
315
320
|
callback (mutation) {
|
316
321
|
initElement(mutation.target);
|
package/src/updateDom.js
CHANGED
@@ -33,6 +33,8 @@ export function updateDom({domTextEditor, value, start, end, html}) {
|
|
33
33
|
curCaret = getSelection(activeElement);
|
34
34
|
else if (activeElement.tagName == 'BODY')
|
35
35
|
curCaret = getSelection(domEl);
|
36
|
+
else
|
37
|
+
curCaret = getSelection(activeElement);
|
36
38
|
|
37
39
|
if (!value && type != 'isStartTag' && type != 'textNode'){
|
38
40
|
type = 'innerHTML';
|