|
@@ -20,11 +20,12 @@ function uuid(len = 16, radix = 16) {
|
|
|
return value.join('')
|
|
|
}
|
|
|
|
|
|
-let markCount = 1
|
|
|
-
|
|
|
class ContentEdit {
|
|
|
constructor(options) {
|
|
|
- this.options = options
|
|
|
+ this.options = {
|
|
|
+ markCountKey: 'markCount',
|
|
|
+ ...options
|
|
|
+ }
|
|
|
this.container = document.querySelector(options.el)
|
|
|
this.hiddenMark = options.hiddenMark
|
|
|
this.selection = null
|
|
@@ -106,9 +107,6 @@ class ContentEdit {
|
|
|
this.parcelNodeContent()
|
|
|
this.selection.removeAllRanges()
|
|
|
this.options.change && this.options.change(this.innerHTML)
|
|
|
- if(!this.markNum){
|
|
|
- markCount++
|
|
|
- }
|
|
|
return this.ctrid
|
|
|
} catch (e) {
|
|
|
return this.ctrid
|
|
@@ -201,7 +199,7 @@ class ContentEdit {
|
|
|
createMark() {
|
|
|
if (this.hiddenMark) return document.createDocumentFragment()
|
|
|
const img = document.createElement('img')
|
|
|
- const index = this.markNum || markCount
|
|
|
+ const index = this.markNum || window[this.options.markCountKey]
|
|
|
img.classList.add('scapegoat')
|
|
|
img.setAttribute('height', 20)
|
|
|
img.setAttribute('data-ctrid', this.ctrid)
|