@cocreate/selection 1.3.4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/selection",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "A simple selection component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "selection",
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
- element.style[property] = value;
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
- element.classList.add(value);
346
+ if (!remove)
347
+ element.classList.add(value);
344
348
  value = element.getAttribute(attribute);
345
349
  }
346
350
  else {