@cocreate/text 1.15.15 → 1.16.0
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 +21 -0
- package/demo/demos.html +12 -5
- package/docs/index.html +1 -1
- package/package.json +10 -10
- package/src/index.js +26 -14
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# [1.16.0](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.17...v1.16.0) (2022-06-11)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* undo and redo text ([fb9292e](https://github.com/CoCreate-app/CoCreate-text/commit/fb9292e74dde4b02e5dc977b1afecebb7bc33e73))
|
7
|
+
|
8
|
+
## [1.15.17](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.16...v1.15.17) (2022-05-23)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* bump all dependencies ([f939228](https://github.com/CoCreate-app/CoCreate-text/commit/f939228c67acb693a15c61537385f93f0f2ee692))
|
14
|
+
|
15
|
+
## [1.15.16](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.15...v1.15.16) (2022-05-19)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* update document_id on link index.css ([6b65da1](https://github.com/CoCreate-app/CoCreate-text/commit/6b65da1be856e5f30d3adda18a2406ee8f505c97))
|
21
|
+
|
1
22
|
## [1.15.15](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.14...v1.15.15) (2022-05-06)
|
2
23
|
|
3
24
|
|
package/demo/demos.html
CHANGED
@@ -9,12 +9,12 @@
|
|
9
9
|
</head>
|
10
10
|
|
11
11
|
<body class="padding:20px">
|
12
|
-
<form collection="
|
12
|
+
<form collection="test" document_id="62a3f5d5e6dfc91d581cdd2d">
|
13
13
|
<input type="text" name="name"></textarea>
|
14
|
+
<h1 name='name' collection="test"></h1>
|
15
|
+
<!-- <textarea name="name2"></textarea> -->
|
14
16
|
<!--<h1 name='name' contenteditable>I will be replaced by crdt</h1>-->
|
15
|
-
<
|
16
|
-
<!--<h1 name='name' contenteditable>I will be replaced by crdt</h1>-->
|
17
|
-
<div name='name2' contenteditable>I will be replaced by crud</div>
|
17
|
+
<!-- <div name='name2' contenteditable>I will be replaced by crud</div> -->
|
18
18
|
|
19
19
|
<div class="padding:20px">
|
20
20
|
CoCreateCrdt.init({collection: "apples1", document_id: "60bea334b25613e8da1b4bdf", name: "src"});
|
@@ -26,7 +26,14 @@
|
|
26
26
|
CoCreate.crdt.getText({collection: "apples1", document_id: "5fe9e0a11b4a703e71c51ba8", name: "name"});
|
27
27
|
</div>
|
28
28
|
</form>
|
29
|
-
|
29
|
+
<script>
|
30
|
+
var config = {
|
31
|
+
apiKey: '2061acef-0451-4545-f754-60cf8160', // Your apiKey can be retrived after signing up at https://cocreate.app
|
32
|
+
organization_id: '5ff747727005da1c272740ab', // Your organization_id can be retrived after signing up at https://cocreate.app
|
33
|
+
host: 'general.cocreate.app' // Points to socket server. If not defined it will use the url in web browser by default
|
34
|
+
}
|
35
|
+
</script>
|
36
|
+
|
30
37
|
<!--<script src="../dist/CoCreate-text.js" ></script>-->
|
31
38
|
<script src="../../../CoCreateJS/dist/CoCreate.js"></script>
|
32
39
|
|
package/docs/index.html
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<meta name="keywords" content="helper classes, utility classes, css framework, css library, inline style classes" />
|
11
11
|
<meta name="robots" content="index,follow" />
|
12
12
|
<meta property="og:image" content="https://cdn.cocreate.app/docs/boilerplate.png">
|
13
|
-
<link rel="stylesheet" href="/docs/index.css" collection="files" document_id="
|
13
|
+
<link rel="stylesheet" href="/docs/index.css" collection="files" document_id="62827d7e8082ce05b081430b" name="src" type="text/css" save="true"/>
|
14
14
|
</head>
|
15
15
|
|
16
16
|
<body>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cocreate/text",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.16.0",
|
4
4
|
"description": "A simple text component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
5
5
|
"keywords": [
|
6
6
|
"text",
|
@@ -61,14 +61,14 @@
|
|
61
61
|
"webpack-log": "^3.0.1"
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
|
-
"@cocreate/actions": "^1.
|
65
|
-
"@cocreate/crdt": "^1.
|
66
|
-
"@cocreate/crud-client": "^1.
|
67
|
-
"@cocreate/cursors": "^1.11.
|
68
|
-
"@cocreate/docs": "^1.
|
69
|
-
"@cocreate/hosting": "^1.
|
70
|
-
"@cocreate/observer": "^1.
|
71
|
-
"@cocreate/selection": "^1.4.
|
72
|
-
"@cocreate/uuid": "^1.1
|
64
|
+
"@cocreate/actions": "^1.4.2",
|
65
|
+
"@cocreate/crdt": "^1.10.0",
|
66
|
+
"@cocreate/crud-client": "^1.6.2",
|
67
|
+
"@cocreate/cursors": "^1.11.19",
|
68
|
+
"@cocreate/docs": "^1.3.1",
|
69
|
+
"@cocreate/hosting": "^1.3.1",
|
70
|
+
"@cocreate/observer": "^1.5.1",
|
71
|
+
"@cocreate/selection": "^1.4.9",
|
72
|
+
"@cocreate/uuid": "^1.2.1"
|
73
73
|
}
|
74
74
|
}
|
package/src/index.js
CHANGED
@@ -7,6 +7,7 @@ import uuid from '@cocreate/uuid';
|
|
7
7
|
import {updateDom} from './updateDom';
|
8
8
|
import {insertAdjacentElement, removeElement, setInnerText, setAttribute, removeAttribute, setClass, setStyle, setClassStyle, replaceInnerText} from './updateText';
|
9
9
|
import {getSelection, processSelection} from '@cocreate/selection';
|
10
|
+
import action from '@cocreate/actions';
|
10
11
|
import './saveDomText';
|
11
12
|
|
12
13
|
let eventObj;
|
@@ -85,16 +86,9 @@ function initDocument(doc) {
|
|
85
86
|
let element = doc.activeElement;
|
86
87
|
sendPosition(element);
|
87
88
|
});
|
88
|
-
// doc.removeEventListener('selectionchange', _selectionchange);
|
89
|
-
// doc.addEventListener('selectionchange', _selectionchange)
|
90
89
|
}
|
91
90
|
}
|
92
91
|
|
93
|
-
// function _selectionchange(event){
|
94
|
-
// let element = event.currentTarget.activeElement;
|
95
|
-
// sendPosition(element);
|
96
|
-
// }
|
97
|
-
|
98
92
|
export function _addEventListeners (element) {
|
99
93
|
element.addEventListener('mousedown', _mousedown);
|
100
94
|
element.addEventListener('blur', _blur);
|
@@ -199,10 +193,13 @@ function _keydown (event) {
|
|
199
193
|
event.preventDefault();
|
200
194
|
}
|
201
195
|
else if (event.ctrlKey) {
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
196
|
+
const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(element);
|
197
|
+
if (event.keyCode == 90) {
|
198
|
+
crdt.undoText({ collection, document_id, name, isCrud, isCrdt, isSave })
|
199
|
+
}
|
200
|
+
else if (event.keyCode == 89) {
|
201
|
+
crdt.redoText({ collection, document_id, name, isCrud, isCrdt, isSave })
|
202
|
+
}
|
206
203
|
}
|
207
204
|
}
|
208
205
|
|
@@ -301,9 +298,6 @@ function updateElements({elements, collection, document_id, name, value, start,
|
|
301
298
|
|
302
299
|
elements.forEach((element) => {
|
303
300
|
let isCrdt = element.getAttribute('crdt');
|
304
|
-
// if (isCrdt == 'false' && !element.hasAttribute('crdt') && !element.contentEditable) return;
|
305
|
-
// if (element.hasAttribute('contenteditable')){
|
306
|
-
// let isEditable = element.getAttribute('contenteditable');
|
307
301
|
if (!element.hasAttribute('contenteditable') && isCrdt == 'false') return;
|
308
302
|
|
309
303
|
updateElement({element, collection, document_id, name, value, start, length, string});
|
@@ -395,6 +389,24 @@ observer.init({
|
|
395
389
|
}
|
396
390
|
});
|
397
391
|
|
392
|
+
action.init({
|
393
|
+
name: "undo",
|
394
|
+
endEvent: "undo",
|
395
|
+
callback: (btn, data) => {
|
396
|
+
const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(btn);
|
397
|
+
crdt.undoText({ collection, document_id, name, isCrud, isCrdt, isSave })
|
398
|
+
}
|
399
|
+
});
|
400
|
+
|
401
|
+
action.init({
|
402
|
+
name: "redo",
|
403
|
+
endEvent: "redo",
|
404
|
+
callback: (btn, data) => {
|
405
|
+
const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(btn);
|
406
|
+
crdt.redoText({ collection, document_id, name, isCrud, isCrdt, isSave })
|
407
|
+
}
|
408
|
+
});
|
409
|
+
|
398
410
|
init();
|
399
411
|
|
400
412
|
export default {initElements, initElement, updateText, updateElement, _addEventListeners, insertAdjacentElement, removeElement, setInnerText, setAttribute, removeAttribute, setClass, setStyle, setClassStyle, replaceInnerText};
|