@cocreate/selection 1.3.4 → 1.4.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +7 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [1.4.0](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.3.4...v1.4.0) (2022-01-22)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* removeClass and removeStyle to remove the className or property from CRDT string ([a610075](https://github.com/CoCreate-app/CoCreate-selection/commit/a6100751ec02da5cb3c592f9a1854376d52d55fc))
|
7
|
+
|
1
8
|
## [1.3.4](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.3.3...v1.3.4) (2022-01-01)
|
2
9
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -287,7 +287,7 @@ function getInsertPosition(element){
|
|
287
287
|
return {target, position};
|
288
288
|
}
|
289
289
|
|
290
|
-
export function getStringPosition({string, target, position, attribute, property, value}) {
|
290
|
+
export function getStringPosition({string, target, position, attribute, property, value, remove}) {
|
291
291
|
try {
|
292
292
|
let element;
|
293
293
|
let selector = cssPath(target, '[contenteditable]');
|
@@ -325,7 +325,10 @@ export function getStringPosition({string, target, position, attribute, property
|
|
325
325
|
let attrStart = elString.indexOf(` ${attribute}=`);
|
326
326
|
start = start + attrStart;
|
327
327
|
if (attribute == 'style') {
|
328
|
-
|
328
|
+
if (remove)
|
329
|
+
element.style.removeProperty(property);
|
330
|
+
else
|
331
|
+
element.style[property] = value;
|
329
332
|
value = element.getAttribute(attribute);
|
330
333
|
}
|
331
334
|
else if (attribute == 'class') {
|
@@ -340,7 +343,8 @@ export function getStringPosition({string, target, position, attribute, property
|
|
340
343
|
element.classList.remove(propString);
|
341
344
|
}
|
342
345
|
}
|
343
|
-
|
346
|
+
if (!remove)
|
347
|
+
element.classList.add(value);
|
344
348
|
value = element.getAttribute(attribute);
|
345
349
|
}
|
346
350
|
else {
|