@adminforth/markdown 1.9.1 → 1.10.0
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/MarkdownEditor.vue +47 -2
- package/dist/custom/MarkdownEditor.vue +47 -2
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -12,5 +12,5 @@ custom/tsconfig.json
|
|
|
12
12
|
custom/utils/
|
|
13
13
|
custom/utils/monacoMarkdownToggle.ts
|
|
14
14
|
|
|
15
|
-
sent
|
|
16
|
-
total size is
|
|
15
|
+
sent 38,446 bytes received 146 bytes 77,184.00 bytes/sec
|
|
16
|
+
total size is 37,901 speedup is 0.98
|
|
@@ -447,6 +447,50 @@ async function uploadFileAndGetMarkdownTag(file: File): Promise<string | undefin
|
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
+
function getSelectedPlainText(): string {
|
|
451
|
+
if (!editor || !model) return '';
|
|
452
|
+
|
|
453
|
+
const sels = editor.getSelections() || [];
|
|
454
|
+
if (!sels.length) return '';
|
|
455
|
+
return sels
|
|
456
|
+
.map((sel) => model!.getValueInRange(sel))
|
|
457
|
+
.join('\n');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const onEditorCopy = (e: ClipboardEvent) => {
|
|
461
|
+
if (!editor || !model) return;
|
|
462
|
+
if (!e.clipboardData) return;
|
|
463
|
+
|
|
464
|
+
if (!(editor.hasTextFocus?.() || isFocused.value)) return;
|
|
465
|
+
|
|
466
|
+
const text = getSelectedPlainText();
|
|
467
|
+
if (!text) return;
|
|
468
|
+
|
|
469
|
+
e.clipboardData.setData('text/plain', text);
|
|
470
|
+
e.clipboardData.setData('text/html', '');
|
|
471
|
+
e.preventDefault();
|
|
472
|
+
e.stopPropagation();
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const onEditorCut = (e: ClipboardEvent) => {
|
|
476
|
+
if (!editor || !model) return;
|
|
477
|
+
if (!e.clipboardData) return;
|
|
478
|
+
if (!(editor.hasTextFocus?.() || isFocused.value)) return;
|
|
479
|
+
|
|
480
|
+
const text = getSelectedPlainText();
|
|
481
|
+
if (!text) return;
|
|
482
|
+
|
|
483
|
+
e.clipboardData.setData('text/plain', text);
|
|
484
|
+
e.clipboardData.setData('text/html', '');
|
|
485
|
+
e.preventDefault();
|
|
486
|
+
e.stopPropagation();
|
|
487
|
+
|
|
488
|
+
const sels = editor.getSelections() || [];
|
|
489
|
+
editor.executeEdits(
|
|
490
|
+
'cut',
|
|
491
|
+
sels.map((range) => ({ range, text: '' })),
|
|
492
|
+
);
|
|
493
|
+
};
|
|
450
494
|
|
|
451
495
|
onMounted(async () => {
|
|
452
496
|
if (!editorContainer.value) return;
|
|
@@ -577,7 +621,8 @@ onMounted(async () => {
|
|
|
577
621
|
insertAtCursor(`${markdownTags.join('\n\n')}\n`);
|
|
578
622
|
}
|
|
579
623
|
};
|
|
580
|
-
|
|
624
|
+
domNode.addEventListener('copy', onEditorCopy, true);
|
|
625
|
+
domNode.addEventListener('cut', onEditorCut, true);
|
|
581
626
|
domNode.addEventListener('dragover', onDragOver, true);
|
|
582
627
|
domNode.addEventListener('drop', onDrop, true);
|
|
583
628
|
removeDragOverListener = () => domNode.removeEventListener('dragover', onDragOver, true);
|
|
@@ -710,7 +755,7 @@ async function uploadFileToS3(file: File): Promise<string | undefined> {
|
|
|
710
755
|
return;
|
|
711
756
|
}
|
|
712
757
|
|
|
713
|
-
const originalFilename = file.name.split('.').slice(0, -1).join('.')
|
|
758
|
+
const originalFilename = file.name.split('.').slice(0, -1).join('.') + `_${Date.now()}`;
|
|
714
759
|
const originalExtension = file.name.split('.').pop();
|
|
715
760
|
|
|
716
761
|
const { uploadUrl, tagline, previewUrl, error } = await callAdminForthApi({
|
|
@@ -447,6 +447,50 @@ async function uploadFileAndGetMarkdownTag(file: File): Promise<string | undefin
|
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
+
function getSelectedPlainText(): string {
|
|
451
|
+
if (!editor || !model) return '';
|
|
452
|
+
|
|
453
|
+
const sels = editor.getSelections() || [];
|
|
454
|
+
if (!sels.length) return '';
|
|
455
|
+
return sels
|
|
456
|
+
.map((sel) => model!.getValueInRange(sel))
|
|
457
|
+
.join('\n');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const onEditorCopy = (e: ClipboardEvent) => {
|
|
461
|
+
if (!editor || !model) return;
|
|
462
|
+
if (!e.clipboardData) return;
|
|
463
|
+
|
|
464
|
+
if (!(editor.hasTextFocus?.() || isFocused.value)) return;
|
|
465
|
+
|
|
466
|
+
const text = getSelectedPlainText();
|
|
467
|
+
if (!text) return;
|
|
468
|
+
|
|
469
|
+
e.clipboardData.setData('text/plain', text);
|
|
470
|
+
e.clipboardData.setData('text/html', '');
|
|
471
|
+
e.preventDefault();
|
|
472
|
+
e.stopPropagation();
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const onEditorCut = (e: ClipboardEvent) => {
|
|
476
|
+
if (!editor || !model) return;
|
|
477
|
+
if (!e.clipboardData) return;
|
|
478
|
+
if (!(editor.hasTextFocus?.() || isFocused.value)) return;
|
|
479
|
+
|
|
480
|
+
const text = getSelectedPlainText();
|
|
481
|
+
if (!text) return;
|
|
482
|
+
|
|
483
|
+
e.clipboardData.setData('text/plain', text);
|
|
484
|
+
e.clipboardData.setData('text/html', '');
|
|
485
|
+
e.preventDefault();
|
|
486
|
+
e.stopPropagation();
|
|
487
|
+
|
|
488
|
+
const sels = editor.getSelections() || [];
|
|
489
|
+
editor.executeEdits(
|
|
490
|
+
'cut',
|
|
491
|
+
sels.map((range) => ({ range, text: '' })),
|
|
492
|
+
);
|
|
493
|
+
};
|
|
450
494
|
|
|
451
495
|
onMounted(async () => {
|
|
452
496
|
if (!editorContainer.value) return;
|
|
@@ -577,7 +621,8 @@ onMounted(async () => {
|
|
|
577
621
|
insertAtCursor(`${markdownTags.join('\n\n')}\n`);
|
|
578
622
|
}
|
|
579
623
|
};
|
|
580
|
-
|
|
624
|
+
domNode.addEventListener('copy', onEditorCopy, true);
|
|
625
|
+
domNode.addEventListener('cut', onEditorCut, true);
|
|
581
626
|
domNode.addEventListener('dragover', onDragOver, true);
|
|
582
627
|
domNode.addEventListener('drop', onDrop, true);
|
|
583
628
|
removeDragOverListener = () => domNode.removeEventListener('dragover', onDragOver, true);
|
|
@@ -710,7 +755,7 @@ async function uploadFileToS3(file: File): Promise<string | undefined> {
|
|
|
710
755
|
return;
|
|
711
756
|
}
|
|
712
757
|
|
|
713
|
-
const originalFilename = file.name.split('.').slice(0, -1).join('.')
|
|
758
|
+
const originalFilename = file.name.split('.').slice(0, -1).join('.') + `_${Date.now()}`;
|
|
714
759
|
const originalExtension = file.name.split('.').pop();
|
|
715
760
|
|
|
716
761
|
const { uploadUrl, tagline, previewUrl, error } = await callAdminForthApi({
|