@writergate/quill-image-uploader-nextjs 0.1.3 → 0.1.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@writergate/quill-image-uploader-nextjs",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/enlear/quill-image-uploader-nextjs.git"
@@ -32,54 +32,19 @@ class ImageUploader {
32
32
 
33
33
  this.quill.root.addEventListener("drop", this.handleDrop, false);
34
34
  this.quill.root.addEventListener("paste", this.handlePaste, false);
35
- this.quill.on('text-change', this.renderComments.bind(this));
36
35
  }
37
36
 
38
37
  addComment() {
39
38
  var range = this.quill.getSelection();
39
+ var selectedText = this.quill.getText(range.index, range.length);
40
40
 
41
41
  if (range && range.length > 0 && this.options.newComment) {
42
42
  range.top = this.quill.getBounds(range.index, range.length).top
43
- this.options.newComment(range, this.quill);
43
+ this.options.newComment(range, selectedText);
44
44
  }
45
45
  this.quill.theme.tooltip.hide();
46
46
  }
47
47
 
48
- calculateIndexChange(delta) {
49
- var index = delta.ops[0].retain || 0;
50
- const change = delta.changeLength();
51
- return { index: index, change: change };
52
- }
53
-
54
- adjustIndex(currentIndex, indexDelta) {
55
- if (indexDelta.change > 0 && currentIndex < indexDelta.index) {
56
- // comment index is before the modified text and modification didn't shift content before its starting point
57
- return currentIndex;
58
- } else if (indexDelta.change < 0 && currentIndex < (indexDelta.index + indexDelta.change)) {
59
- // code shifted before its starting point but the comment index is before the modified text
60
- return currentIndex;
61
- } else {
62
- return currentIndex + indexDelta.change;
63
- }
64
- }
65
-
66
- renderComments(delta, oldDelta, source) {
67
- if (Object.keys(this.options.comments(this.quill)).length !== 0) {
68
- var indexDelta = this.calculateIndexChange(delta);
69
- var commentObjs = {};
70
- for (const [key, value] of Object.entries((this.options.comments(this.quill)))) {
71
- var newIndex = this.adjustIndex(value.range.index, indexDelta);
72
- var length = value.range.length;
73
- if (newIndex > 0) {
74
- commentObjs[key] = { range: { index: newIndex, length: length, top: this.quill.getBounds(newIndex, length).top }, message: value.message };
75
- }
76
- }
77
- if (this.options.showComments) {
78
- this.options.showComments(commentObjs, this.quill);
79
- }
80
- }
81
- }
82
-
83
48
  fixHighlighter() {
84
49
  const range = this.quill.getSelection(true);
85
50
  const formats = this.quill.getFormat(range);