@cocreate/text 1.16.1 → 1.16.2
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.html +3 -1
- package/package.json +1 -1
- package/src/index.js +11 -10
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.16.2](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.1...v1.16.2) (2022-06-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* updateElementText if input ant type = text,tel, url ([7eabd9a](https://github.com/CoCreate-app/CoCreate-text/commit/7eabd9acf331ed5012e49a519a9270dd59c2d3bf))
|
7
|
+
|
1
8
|
## [1.16.1](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.0...v1.16.1) (2022-06-12)
|
2
9
|
|
3
10
|
|
package/demo/demos.html
CHANGED
@@ -10,7 +10,9 @@
|
|
10
10
|
|
11
11
|
<body class="padding:20px">
|
12
12
|
<form collection="test" document_id="62a3f5d5e6dfc91d581cdd2d">
|
13
|
-
<input type="
|
13
|
+
<input type="email" name="email">
|
14
|
+
<input type="tel" name="tel">
|
15
|
+
<input type="url" name="url">
|
14
16
|
<h1 name='name' collection="test"></h1>
|
15
17
|
<!-- <textarea name="name2"></textarea> -->
|
16
18
|
<!--<h1 name='name' contenteditable>I will be replaced by crdt</h1>-->
|
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -31,7 +31,7 @@ function initElement (element) {
|
|
31
31
|
if (document_id == "pending") return;
|
32
32
|
if (isCrdt == "false" || isRealtime == "false" || element.type == 'number' || name == '_id') return;
|
33
33
|
if (!crud.checkAttrValue(collection) || !crud.checkAttrValue(document_id)) return;
|
34
|
-
if (element.tagName === "INPUT" && ["text", "
|
34
|
+
if (element.tagName === "INPUT" && ["text", "tel", "url"].includes(element.type) || element.tagName === "TEXTAREA" || element.hasAttribute('contenteditable')) {
|
35
35
|
if (!collection || !document_id || !name) return;
|
36
36
|
|
37
37
|
if (!isCrdt) {
|
@@ -341,15 +341,16 @@ async function updateElement ({element, collection, document_id, name, value, st
|
|
341
341
|
}
|
342
342
|
|
343
343
|
function _updateElementText (element, value, start, end) {
|
344
|
-
if (element.tagName
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
344
|
+
if (element.tagName === "INPUT" && ["text", "tel", "url"].includes(element.type) || element.tagName === "TEXTAREA") {
|
345
|
+
let prev_start = element.selectionStart;
|
346
|
+
let prev_end = element.selectionEnd;
|
347
|
+
let activeElement = element.ownerDocument.activeElement;
|
348
|
+
element.setRangeText(value, start, end, "end");
|
349
|
+
let p = processSelection(element, value, prev_start, prev_end, start, end);
|
350
|
+
if (activeElement == element)
|
351
|
+
sendPosition(element);
|
352
|
+
_dispatchInputEvent(element, p.value, p.start, p.end, p.prev_start, p.prev_end);
|
353
|
+
}
|
353
354
|
}
|
354
355
|
|
355
356
|
export function _dispatchInputEvent(element, content, start, end, prev_start, prev_end) {
|