@livingdocs/editable.js 3.0.16 → 3.1.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@livingdocs/editable.js",
3
3
  "description": "Friendly contenteditable API",
4
- "version": "3.0.16",
4
+ "version": "3.1.0",
5
5
  "dependencies": {
6
6
  "@babel/runtime": "^7.16.7",
7
7
  "bowser": "2.11.0",
@@ -83,11 +83,11 @@
83
83
  "isCi": true,
84
84
  "name": "Drone",
85
85
  "service": "drone",
86
- "commit": "85752c5c2a4de6108413bc50b0433086ce0d0435",
87
- "build": "469",
86
+ "commit": "2e7b8ed5efd8fb418a159ded67be45ddf9941999",
87
+ "build": "482",
88
88
  "branch": "master",
89
89
  "isPr": false,
90
90
  "slug": "livingdocsIO/editable.js",
91
- "date": "2022-03-15T10:07:49.382Z"
91
+ "date": "2022-03-22T20:40:52.111Z"
92
92
  }
93
93
  }
package/src/config.js CHANGED
@@ -10,6 +10,7 @@ export default {
10
10
  editableClass: 'js-editable',
11
11
  editableDisabledClass: 'js-editable-disabled',
12
12
  pastingAttribute: 'data-editable-is-pasting',
13
+ trimLeadingAndTrailingWhitespaces: true,
13
14
  boldMarkup: {
14
15
  type: 'tag',
15
16
  name: 'strong',
package/src/content.js CHANGED
@@ -4,6 +4,7 @@ import * as rangeSaveRestore from './range-save-restore'
4
4
  import * as parser from './parser'
5
5
  import * as string from './util/string'
6
6
  import {createElement} from './util/dom'
7
+ import config from './config'
7
8
 
8
9
  function restoreRange (host, range, func) {
9
10
  range = rangeSaveRestore.save(range)
@@ -161,7 +162,9 @@ function removeWhitespaces (node, type, firstCall = true) {
161
162
  if (elem?.nodeType !== nodeType.textNode) return
162
163
  // Remove whitespaces at the end or start of a block with content
163
164
  // e.g. ' Hello world' > 'Hello World'
164
- elem.textContent = elem.textContent.replace(type.startsWith('last') ? /\s+$/ : /^\s+/, '')
165
+ if (config.trimLeadingAndTrailingWhitespaces) {
166
+ elem.textContent = elem.textContent.replace(type.startsWith('last') ? / +$/ : /^ +/, '')
167
+ }
165
168
  }
166
169
 
167
170
  // Remove elements that were inserted for internal or user interface purposes