vue-editify 0.1.48 → 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +1 -1
- package/lib/editify.es.js +72 -73
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/editify/editify.less +2 -2
- package/src/index.ts +1 -1
package/examples/App.vue
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<template>
|
2
2
|
<div style="padding: 10px; height: 100%; box-sizing: border-box">
|
3
3
|
<button @click="setStart">setStart</button>
|
4
|
-
<Editify color="#
|
4
|
+
<Editify color="#1098f3" ref="editify" border v-model="val" :menu="menuConfig" style="height: 100%" placeholder="Please Enter Text..." :toolbar="toolbarConfig" locale="zh_CN" allow-paste-html :plugins="plugins" @rangeupdate="rangeUpdate"></Editify>
|
5
5
|
</div>
|
6
6
|
</template>
|
7
7
|
<script setup lang="ts">
|
package/lib/editify.es.js
CHANGED
@@ -2782,13 +2782,12 @@ const doPaste = async function(html, text2, files) {
|
|
2782
2782
|
if (typeof this.customHtmlPaste == "function") {
|
2783
2783
|
await this.customHtmlPaste.apply(this, [elements, html]);
|
2784
2784
|
} else {
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
} else {
|
2789
|
-
this.insertElement(elements[i], false);
|
2790
|
-
}
|
2785
|
+
this.insertElement(elements[0]);
|
2786
|
+
for (let i = elements.length - 1; i >= 1; i--) {
|
2787
|
+
this.addElementAfter(elements[i], elements[0]);
|
2791
2788
|
}
|
2789
|
+
this.range.anchor.moveToEnd(elements[elements.length - 1]);
|
2790
|
+
this.range.focus.moveToEnd(elements[elements.length - 1]);
|
2792
2791
|
this.emit("pasteHtml", elements, html);
|
2793
2792
|
}
|
2794
2793
|
} else if (text2) {
|
@@ -4260,6 +4259,9 @@ class AlexEditor {
|
|
4260
4259
|
if (child.isEmpty()) {
|
4261
4260
|
continue;
|
4262
4261
|
}
|
4262
|
+
if (!child.isText() && AlexElement.VOID_NODES.includes(child.parsedom)) {
|
4263
|
+
continue;
|
4264
|
+
}
|
4263
4265
|
if (child.isText() || child.isClosed()) {
|
4264
4266
|
el = child;
|
4265
4267
|
break;
|
@@ -4277,6 +4279,9 @@ class AlexEditor {
|
|
4277
4279
|
if (previousElement.isEmpty()) {
|
4278
4280
|
return fn(previousElement);
|
4279
4281
|
}
|
4282
|
+
if (!previousElement.isText() && AlexElement.VOID_NODES.includes(previousElement.parsedom)) {
|
4283
|
+
return fn(previousElement);
|
4284
|
+
}
|
4280
4285
|
if (previousElement.isText() || previousElement.isClosed()) {
|
4281
4286
|
return previousElement;
|
4282
4287
|
}
|
@@ -4358,6 +4363,18 @@ class AlexEditor {
|
|
4358
4363
|
flatList: []
|
4359
4364
|
};
|
4360
4365
|
}
|
4366
|
+
if (this.range.anchor.element.isEqual(this.range.focus.element)) {
|
4367
|
+
const anchorInStart = this.range.anchor.offset == 0;
|
4368
|
+
const focusInEnd = this.range.focus.offset == (this.range.focus.element.isText() ? this.range.focus.element.textContent.length : 1);
|
4369
|
+
const result = {
|
4370
|
+
element: this.range.anchor.element,
|
4371
|
+
offset: anchorInStart && focusInEnd ? false : [this.range.anchor.offset, this.range.focus.offset]
|
4372
|
+
};
|
4373
|
+
return {
|
4374
|
+
list: [result],
|
4375
|
+
flatList: [result]
|
4376
|
+
};
|
4377
|
+
}
|
4361
4378
|
const getFlatList = () => {
|
4362
4379
|
let flatList = [];
|
4363
4380
|
const anchorInStart = this.range.anchor.offset == 0;
|
@@ -4373,78 +4390,60 @@ class AlexEditor {
|
|
4373
4390
|
if (startIndex > 0 || endIndex < elements.length - 1) {
|
4374
4391
|
elements = elements.slice(startIndex, endIndex + 1);
|
4375
4392
|
}
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4393
|
+
const length = elements.length;
|
4394
|
+
for (let i = 0; i < length; i++) {
|
4395
|
+
if (this.range.anchor.element.isEqual(elements[i])) {
|
4396
|
+
if (anchorInStart) {
|
4397
|
+
flatList.push({
|
4398
|
+
element: this.range.anchor.element,
|
4381
4399
|
offset: false
|
4382
|
-
};
|
4383
|
-
})
|
4384
|
-
|
4385
|
-
flatList = [
|
4386
|
-
{
|
4400
|
+
});
|
4401
|
+
} else if (this.range.anchor.element.isText() && this.range.anchor.offset < this.range.anchor.element.textContent.length) {
|
4402
|
+
flatList.push({
|
4387
4403
|
element: this.range.anchor.element,
|
4388
|
-
offset: [this.range.anchor.offset, this.range.
|
4389
|
-
}
|
4390
|
-
|
4391
|
-
}
|
4392
|
-
|
4393
|
-
|
4394
|
-
|
4395
|
-
if (
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
} else if (this.range.anchor.element.isText() && this.range.anchor.offset < this.range.anchor.element.textContent.length) {
|
4402
|
-
flatList.push({
|
4403
|
-
element: this.range.anchor.element,
|
4404
|
-
offset: [this.range.anchor.offset, this.range.anchor.element.textContent.length]
|
4405
|
-
});
|
4406
|
-
}
|
4407
|
-
} else if (elements[i].isContains(this.range.anchor.element)) {
|
4408
|
-
const isFirst = this.range.anchor.element.isFirst(elements[i]);
|
4409
|
-
const hasFocus = elements[i].isContains(this.range.focus.element);
|
4410
|
-
const isLast = this.range.focus.element.isLast(elements[i]);
|
4411
|
-
if (anchorInStart && isFirst && hasFocus && isLast && focusInEnd) {
|
4412
|
-
flatList.push({
|
4413
|
-
element: elements[i],
|
4414
|
-
offset: false
|
4415
|
-
});
|
4416
|
-
} else if (anchorInStart && isFirst && !hasFocus) {
|
4417
|
-
flatList.push({
|
4418
|
-
element: elements[i],
|
4419
|
-
offset: false
|
4420
|
-
});
|
4421
|
-
}
|
4422
|
-
} else if (this.range.focus.element.isEqual(elements[i])) {
|
4423
|
-
if (focusInEnd) {
|
4424
|
-
flatList.push({
|
4425
|
-
element: this.range.focus.element,
|
4426
|
-
offset: false
|
4427
|
-
});
|
4428
|
-
} else if (this.range.focus.offset > 0) {
|
4429
|
-
flatList.push({
|
4430
|
-
element: this.range.focus.element,
|
4431
|
-
offset: [0, this.range.focus.offset]
|
4432
|
-
});
|
4433
|
-
}
|
4434
|
-
} else if (elements[i].isContains(this.range.focus.element)) {
|
4435
|
-
const isLast = this.range.focus.element.isLast(elements[i]);
|
4436
|
-
if (isLast && focusInEnd) {
|
4437
|
-
flatList.push({
|
4438
|
-
element: elements[i],
|
4439
|
-
offset: false
|
4440
|
-
});
|
4441
|
-
}
|
4442
|
-
} else {
|
4404
|
+
offset: [this.range.anchor.offset, this.range.anchor.element.textContent.length]
|
4405
|
+
});
|
4406
|
+
}
|
4407
|
+
} else if (elements[i].isContains(this.range.anchor.element)) {
|
4408
|
+
const isFirst = this.range.anchor.element.isFirst(elements[i]);
|
4409
|
+
const hasFocus = elements[i].isContains(this.range.focus.element);
|
4410
|
+
const isLast = this.range.focus.element.isLast(elements[i]);
|
4411
|
+
if (anchorInStart && isFirst && hasFocus && isLast && focusInEnd) {
|
4412
|
+
flatList.push({
|
4413
|
+
element: elements[i],
|
4414
|
+
offset: false
|
4415
|
+
});
|
4416
|
+
} else if (anchorInStart && isFirst && !hasFocus) {
|
4443
4417
|
flatList.push({
|
4444
4418
|
element: elements[i],
|
4445
4419
|
offset: false
|
4446
4420
|
});
|
4447
4421
|
}
|
4422
|
+
} else if (this.range.focus.element.isEqual(elements[i])) {
|
4423
|
+
if (focusInEnd) {
|
4424
|
+
flatList.push({
|
4425
|
+
element: this.range.focus.element,
|
4426
|
+
offset: false
|
4427
|
+
});
|
4428
|
+
} else if (this.range.focus.offset > 0) {
|
4429
|
+
flatList.push({
|
4430
|
+
element: this.range.focus.element,
|
4431
|
+
offset: [0, this.range.focus.offset]
|
4432
|
+
});
|
4433
|
+
}
|
4434
|
+
} else if (elements[i].isContains(this.range.focus.element)) {
|
4435
|
+
const isLast = this.range.focus.element.isLast(elements[i]);
|
4436
|
+
if (isLast && focusInEnd) {
|
4437
|
+
flatList.push({
|
4438
|
+
element: elements[i],
|
4439
|
+
offset: false
|
4440
|
+
});
|
4441
|
+
}
|
4442
|
+
} else {
|
4443
|
+
flatList.push({
|
4444
|
+
element: elements[i],
|
4445
|
+
offset: false
|
4446
|
+
});
|
4448
4447
|
}
|
4449
4448
|
}
|
4450
4449
|
return flatList;
|
@@ -4681,7 +4680,7 @@ class AlexEditor {
|
|
4681
4680
|
event$1.off(this.$el, "beforeinput.alex_editor compositionstart.alex_editor compositionupdate.alex_editor compositionend.alex_editor keydown.alex_editor cut.alex_editor paste.alex_editor copy.alex_editor dragstart.alex_editor drop.alex_editor focus.alex_editor blur.alex_editor");
|
4682
4681
|
}
|
4683
4682
|
}
|
4684
|
-
const version$2 = "1.4.
|
4683
|
+
const version$2 = "1.4.14";
|
4685
4684
|
console.log(`%c alex-editor %c v${version$2} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
|
4686
4685
|
const number = {
|
4687
4686
|
/**
|
@@ -42550,7 +42549,7 @@ const attachment = (options) => {
|
|
42550
42549
|
const install = (app) => {
|
42551
42550
|
app.component(Editify.name, Editify);
|
42552
42551
|
};
|
42553
|
-
const version = "0.1.
|
42552
|
+
const version = "0.1.49";
|
42554
42553
|
console.log(`%c vue-editify %c v${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
|
42555
42554
|
export {
|
42556
42555
|
AlexElement,
|