@adminforth/rich-editor 1.0.5 → 1.0.6

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.
@@ -32,10 +32,11 @@ function dbg(title: string,...args: any[]) {
32
32
  console.log(title, ...args.map(a =>JSON.stringify(a, null, 1)));
33
33
  }
34
34
 
35
- const BlockEmbed = Quill.import('blots/block/embed');
35
+ // blots/embed: Represents inline embed elements, like images or videos that can be inserted into the text flow.
36
+ const Embed = Quill.import('blots/embed');
36
37
 
37
38
  // @ts-ignore
38
- class CompleteBlot extends BlockEmbed {
39
+ class CompleteBlot extends Embed {
39
40
  static blotName = 'complete';
40
41
  static tagName = 'span';
41
42
 
@@ -278,6 +279,8 @@ function approveCompletion(type: 'all' | 'word') {
278
279
 
279
280
  let shouldComplete = false;
280
281
  if (type === 'all') {
282
+ dbg(`👇 insert all at ${cursorPosition.index}, ${completion.value.join('')}`);
283
+ deleteCompleteEmbed();
281
284
  quill.insertText(cursorPosition.index, completion.value.join(''), 'silent');
282
285
  shouldComplete = true;
283
286
  } else {
@@ -306,7 +309,6 @@ async function startCompletion() {
306
309
  return;
307
310
  }
308
311
  completion.value = null;
309
- // return;
310
312
  deleteCompleteEmbed();
311
313
 
312
314
  if (tmt) {
@@ -336,12 +338,10 @@ async function startCompletion() {
336
338
  return;
337
339
  }
338
340
 
339
- // deleteCompleteEmbed();
340
- // insert on +1 to insert after \n
341
- quill.insertEmbed(cursorPosition.index + 1, 'complete', { text: completionAnswer.join('') }, 'silent');
341
+ quill.insertEmbed(cursorPosition.index, 'complete', { text: completionAnswer.join('') }, 'silent');
342
342
 
343
- dbg('👇 set pos', cursorPosition.index, cursorPosition.length)
344
- quill.setSelection(cursorPosition.index, cursorPosition.length, 'silent');
343
+ // dbg('👇 set pos', cursorPosition.index, cursorPosition.length)
344
+ // quill.setSelection(cursorPosition.index, cursorPosition.length, 'silent');
345
345
 
346
346
  completion.value = completionAnswer;
347
347
 
@@ -393,28 +393,13 @@ function removeCompletionOnBlur() {
393
393
  }
394
394
  }
395
395
 
396
- p:has(+ [completer]) br {
396
+
397
+ .ql-editor:not(:focus) [completer] {
397
398
  display: none;
398
399
  }
399
- p:has(+ [completer]) {
400
- // background: rgb(255 227 227); // debug
401
- display: inline;
402
- }
403
-
404
- .ql-editor:not(:focus) [completer] {
405
- display: none;
406
- }
407
400
 
408
401
  .ql-editor [completer] {
409
- // important to keep pointer-events non none for cursor position on completer click
410
-
411
- // text is not selectable
412
- user-select: none;
413
402
  color: gray;
414
-
415
- // if inline or inline used then user-select: none brakes triple click
416
- display: contents;
417
-
418
403
  font-style: italic;
419
404
  }
420
405
 
@@ -32,10 +32,11 @@ function dbg(title: string,...args: any[]) {
32
32
  console.log(title, ...args.map(a =>JSON.stringify(a, null, 1)));
33
33
  }
34
34
 
35
- const BlockEmbed = Quill.import('blots/block/embed');
35
+ // blots/embed: Represents inline embed elements, like images or videos that can be inserted into the text flow.
36
+ const Embed = Quill.import('blots/embed');
36
37
 
37
38
  // @ts-ignore
38
- class CompleteBlot extends BlockEmbed {
39
+ class CompleteBlot extends Embed {
39
40
  static blotName = 'complete';
40
41
  static tagName = 'span';
41
42
 
@@ -278,6 +279,8 @@ function approveCompletion(type: 'all' | 'word') {
278
279
 
279
280
  let shouldComplete = false;
280
281
  if (type === 'all') {
282
+ dbg(`👇 insert all at ${cursorPosition.index}, ${completion.value.join('')}`);
283
+ deleteCompleteEmbed();
281
284
  quill.insertText(cursorPosition.index, completion.value.join(''), 'silent');
282
285
  shouldComplete = true;
283
286
  } else {
@@ -306,7 +309,6 @@ async function startCompletion() {
306
309
  return;
307
310
  }
308
311
  completion.value = null;
309
- // return;
310
312
  deleteCompleteEmbed();
311
313
 
312
314
  if (tmt) {
@@ -336,12 +338,10 @@ async function startCompletion() {
336
338
  return;
337
339
  }
338
340
 
339
- // deleteCompleteEmbed();
340
- // insert on +1 to insert after \n
341
- quill.insertEmbed(cursorPosition.index + 1, 'complete', { text: completionAnswer.join('') }, 'silent');
341
+ quill.insertEmbed(cursorPosition.index, 'complete', { text: completionAnswer.join('') }, 'silent');
342
342
 
343
- dbg('👇 set pos', cursorPosition.index, cursorPosition.length)
344
- quill.setSelection(cursorPosition.index, cursorPosition.length, 'silent');
343
+ // dbg('👇 set pos', cursorPosition.index, cursorPosition.length)
344
+ // quill.setSelection(cursorPosition.index, cursorPosition.length, 'silent');
345
345
 
346
346
  completion.value = completionAnswer;
347
347
 
@@ -393,28 +393,13 @@ function removeCompletionOnBlur() {
393
393
  }
394
394
  }
395
395
 
396
- p:has(+ [completer]) br {
396
+
397
+ .ql-editor:not(:focus) [completer] {
397
398
  display: none;
398
399
  }
399
- p:has(+ [completer]) {
400
- // background: rgb(255 227 227); // debug
401
- display: inline;
402
- }
403
-
404
- .ql-editor:not(:focus) [completer] {
405
- display: none;
406
- }
407
400
 
408
401
  .ql-editor [completer] {
409
- // important to keep pointer-events non none for cursor position on completer click
410
-
411
- // text is not selectable
412
- user-select: none;
413
402
  color: gray;
414
-
415
- // if inline or inline used then user-select: none brakes triple click
416
- display: contents;
417
-
418
403
  font-style: italic;
419
404
  }
420
405
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/rich-editor",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",