@adminforth/rich-editor 2.0.0 → 2.0.1
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/build.log +2 -2
- package/custom/quillEditor.vue +34 -8
- package/dist/custom/quillEditor.vue +34 -8
- package/index.ts +0 -1
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -10,5 +10,5 @@ custom/package.json
|
|
|
10
10
|
custom/quillEditor.vue
|
|
11
11
|
custom/tsconfig.json
|
|
12
12
|
|
|
13
|
-
sent
|
|
14
|
-
total size is
|
|
13
|
+
sent 35,511 bytes received 115 bytes 71,252.00 bytes/sec
|
|
14
|
+
total size is 35,088 speedup is 0.98
|
package/custom/quillEditor.vue
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
v-if="wasQuillInitializedSuccessfully"
|
|
3
4
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
|
|
4
5
|
focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400
|
|
5
6
|
dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 whitespace-normal af-quill-editor"
|
|
@@ -15,6 +16,13 @@
|
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
</div>
|
|
19
|
+
<Textarea
|
|
20
|
+
v-else
|
|
21
|
+
:modelValue="currentValue"
|
|
22
|
+
@update:modelValue="emit('update:value', $event);"
|
|
23
|
+
placeholder="Enter some text..."
|
|
24
|
+
class="w-64"
|
|
25
|
+
/>
|
|
18
26
|
|
|
19
27
|
|
|
20
28
|
</template>
|
|
@@ -30,8 +38,10 @@ import Quill from "quill";
|
|
|
30
38
|
import "quill/dist/quill.snow.css";
|
|
31
39
|
import QuillTableBetter from 'quill-table-better-yaroslav8765';
|
|
32
40
|
import 'quill-table-better-yaroslav8765/dist/quill-table-better.css';
|
|
41
|
+
import { Textarea } from '@/afcl'
|
|
33
42
|
|
|
34
43
|
import { useI18n } from 'vue-i18n';
|
|
44
|
+
import { ok } from "assert";
|
|
35
45
|
|
|
36
46
|
const { t } = useI18n();
|
|
37
47
|
function dbg(title: string,...args: any[]) {
|
|
@@ -144,6 +154,7 @@ const editorFocused = ref(false);
|
|
|
144
154
|
let lastText: string | null = null;
|
|
145
155
|
|
|
146
156
|
const imageProgress = ref(0);
|
|
157
|
+
const wasQuillInitializedSuccessfully = ref(true);
|
|
147
158
|
|
|
148
159
|
const selectedSymbolsCount = ref(0);
|
|
149
160
|
|
|
@@ -303,18 +314,33 @@ const quillOptions = {
|
|
|
303
314
|
const html = props.record[props.column.name] || '';
|
|
304
315
|
const delta = quill.clipboard.convert({ html });
|
|
305
316
|
const [range] = quill.selection.getRange();
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
try {
|
|
318
|
+
quill.updateContents(delta, Quill.sources.USER);
|
|
319
|
+
quill.setSelection(
|
|
320
|
+
delta.length() - (range?.length || 0),
|
|
321
|
+
Quill.sources.SILENT
|
|
322
|
+
);
|
|
323
|
+
quill.scrollSelectionIntoView();
|
|
324
|
+
} catch (e) {
|
|
325
|
+
console.error('Error while setting initial quill content', e);
|
|
326
|
+
return {ok: false, error: "Invalid initial content"};
|
|
327
|
+
}
|
|
328
|
+
return {ok: true};
|
|
312
329
|
}
|
|
313
330
|
|
|
314
331
|
onMounted(() => {
|
|
315
332
|
currentValue.value = props.record[props.column.name] || '';
|
|
316
333
|
quill = new Quill(editor.value as HTMLElement, quillOptions);
|
|
317
|
-
initValue(quill);
|
|
334
|
+
const initResult = initValue(quill);
|
|
335
|
+
if (!initResult.ok) {
|
|
336
|
+
adminforth.alert({
|
|
337
|
+
message: `Error while initializing rich text editor: ${initResult.error}`,
|
|
338
|
+
variant: 'danger',
|
|
339
|
+
});
|
|
340
|
+
wasQuillInitializedSuccessfully.value = false;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
wasQuillInitializedSuccessfully.value = true;
|
|
318
344
|
lastText = quill.getText();
|
|
319
345
|
const linkButton = document.querySelector('.ql-link');
|
|
320
346
|
if (linkButton) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
v-if="wasQuillInitializedSuccessfully"
|
|
3
4
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
|
|
4
5
|
focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400
|
|
5
6
|
dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 whitespace-normal af-quill-editor"
|
|
@@ -15,6 +16,13 @@
|
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
</div>
|
|
19
|
+
<Textarea
|
|
20
|
+
v-else
|
|
21
|
+
:modelValue="currentValue"
|
|
22
|
+
@update:modelValue="emit('update:value', $event);"
|
|
23
|
+
placeholder="Enter some text..."
|
|
24
|
+
class="w-64"
|
|
25
|
+
/>
|
|
18
26
|
|
|
19
27
|
|
|
20
28
|
</template>
|
|
@@ -30,8 +38,10 @@ import Quill from "quill";
|
|
|
30
38
|
import "quill/dist/quill.snow.css";
|
|
31
39
|
import QuillTableBetter from 'quill-table-better-yaroslav8765';
|
|
32
40
|
import 'quill-table-better-yaroslav8765/dist/quill-table-better.css';
|
|
41
|
+
import { Textarea } from '@/afcl'
|
|
33
42
|
|
|
34
43
|
import { useI18n } from 'vue-i18n';
|
|
44
|
+
import { ok } from "assert";
|
|
35
45
|
|
|
36
46
|
const { t } = useI18n();
|
|
37
47
|
function dbg(title: string,...args: any[]) {
|
|
@@ -144,6 +154,7 @@ const editorFocused = ref(false);
|
|
|
144
154
|
let lastText: string | null = null;
|
|
145
155
|
|
|
146
156
|
const imageProgress = ref(0);
|
|
157
|
+
const wasQuillInitializedSuccessfully = ref(true);
|
|
147
158
|
|
|
148
159
|
const selectedSymbolsCount = ref(0);
|
|
149
160
|
|
|
@@ -303,18 +314,33 @@ const quillOptions = {
|
|
|
303
314
|
const html = props.record[props.column.name] || '';
|
|
304
315
|
const delta = quill.clipboard.convert({ html });
|
|
305
316
|
const [range] = quill.selection.getRange();
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
try {
|
|
318
|
+
quill.updateContents(delta, Quill.sources.USER);
|
|
319
|
+
quill.setSelection(
|
|
320
|
+
delta.length() - (range?.length || 0),
|
|
321
|
+
Quill.sources.SILENT
|
|
322
|
+
);
|
|
323
|
+
quill.scrollSelectionIntoView();
|
|
324
|
+
} catch (e) {
|
|
325
|
+
console.error('Error while setting initial quill content', e);
|
|
326
|
+
return {ok: false, error: "Invalid initial content"};
|
|
327
|
+
}
|
|
328
|
+
return {ok: true};
|
|
312
329
|
}
|
|
313
330
|
|
|
314
331
|
onMounted(() => {
|
|
315
332
|
currentValue.value = props.record[props.column.name] || '';
|
|
316
333
|
quill = new Quill(editor.value as HTMLElement, quillOptions);
|
|
317
|
-
initValue(quill);
|
|
334
|
+
const initResult = initValue(quill);
|
|
335
|
+
if (!initResult.ok) {
|
|
336
|
+
adminforth.alert({
|
|
337
|
+
message: `Error while initializing rich text editor: ${initResult.error}`,
|
|
338
|
+
variant: 'danger',
|
|
339
|
+
});
|
|
340
|
+
wasQuillInitializedSuccessfully.value = false;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
wasQuillInitializedSuccessfully.value = true;
|
|
318
344
|
lastText = quill.getText();
|
|
319
345
|
const linkButton = document.querySelector('.ql-link');
|
|
320
346
|
if (linkButton) {
|
package/index.ts
CHANGED
|
@@ -326,7 +326,6 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
326
326
|
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
|
|
327
327
|
const { content: respContent } = await this.options.completion.adapter.complete(content, [], this.options.completion?.expert?.maxTokens);
|
|
328
328
|
let suggestion = respContent
|
|
329
|
-
|
|
330
329
|
if (suggestion.startsWith(currentVal)) {
|
|
331
330
|
suggestion = suggestion.slice(currentVal.length);
|
|
332
331
|
}
|