@adminforth/markdown 1.9.1 → 1.10.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 CHANGED
@@ -12,5 +12,5 @@ custom/tsconfig.json
12
12
  custom/utils/
13
13
  custom/utils/monacoMarkdownToggle.ts
14
14
 
15
- sent 37,202 bytes received 146 bytes 74,696.00 bytes/sec
16
- total size is 36,649 speedup is 0.98
15
+ sent 36,821 bytes received 146 bytes 73,934.00 bytes/sec
16
+ total size is 36,268 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({
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div v-html="purifiedHtml" class="mdwn"></div>
2
+ <div v-html="purifiedHtml" class="prose"></div>
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
@@ -20,91 +20,4 @@
20
20
  return DOMPurify.sanitize(html);
21
21
  });
22
22
  </script>
23
-
24
- <style lang="scss">
25
-
26
- .mdwn h1 {
27
- @apply text-2xl font-bold mt-2 mb-2;
28
- }
29
-
30
- .mdwn h2 {
31
- @apply text-xl font-bold mt-2 mb-2;
32
- }
33
-
34
- .mdwn h3 {
35
- @apply text-lg font-bold mt-2 mb-2;
36
- }
37
-
38
- .mdwn h4 {
39
- @apply text-base font-bold mt-2 mb-2;
40
- }
41
-
42
- .mdwn h5 {
43
- @apply text-sm font-bold mt-2 mb-2;
44
- }
45
-
46
- .mdwn h6 {
47
- @apply text-xs font-bold mt-2 mb-2;
48
- }
49
-
50
- .mdwn p {
51
- @apply mb-2 leading-relaxed;
52
- }
53
-
54
- .mdwn ul {
55
- @apply list-disc pl-5 mb-2;
56
- }
57
-
58
- .mdwn ol {
59
- @apply list-decimal pl-5 mb-2;
60
- }
61
-
62
- .mdwn li {
63
- @apply mb-1;
64
- }
65
-
66
- .mdwn blockquote {
67
- @apply border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 mb-2;
68
- }
69
-
70
- .mdwn code {
71
- @apply bg-gray-100 dark:bg-gray-800 text-red-600 dark:text-red-400 font-mono px-1 py-0.5 rounded;
72
- }
73
-
74
- .mdwn pre {
75
- @apply bg-gray-100 dark:bg-gray-900 text-sm font-mono p-4 rounded overflow-x-auto mb-2;
76
- }
77
- .mdwn pre code {
78
- @apply bg-transparent p-0 text-inherit;
79
- }
80
-
81
- .mdwn table {
82
- @apply w-full border-collapse text-left text-sm mb-2;
83
- }
84
-
85
- .mdwn thead {
86
- @apply bg-gray-100 dark:bg-gray-700;
87
- }
88
-
89
- .mdwn th,
90
- .mdwn td {
91
- @apply border border-gray-300 dark:border-gray-700 px-4 py-2;
92
- }
93
-
94
- .mdwn th {
95
- @apply font-semibold;
96
- }
97
-
98
- .mdwn hr {
99
- @apply border-t border-gray-300 dark:border-gray-700 my-6;
100
- }
101
-
102
- .mdwn img {
103
- @apply max-w-full h-auto rounded;
104
- }
105
-
106
- .mdwn a {
107
- @apply text-blue-600 hover:underline dark:text-blue-400;
108
- }
109
-
110
- </style>
23
+
@@ -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({
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div v-html="purifiedHtml" class="mdwn"></div>
2
+ <div v-html="purifiedHtml" class="prose"></div>
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
@@ -20,91 +20,4 @@
20
20
  return DOMPurify.sanitize(html);
21
21
  });
22
22
  </script>
23
-
24
- <style lang="scss">
25
-
26
- .mdwn h1 {
27
- @apply text-2xl font-bold mt-2 mb-2;
28
- }
29
-
30
- .mdwn h2 {
31
- @apply text-xl font-bold mt-2 mb-2;
32
- }
33
-
34
- .mdwn h3 {
35
- @apply text-lg font-bold mt-2 mb-2;
36
- }
37
-
38
- .mdwn h4 {
39
- @apply text-base font-bold mt-2 mb-2;
40
- }
41
-
42
- .mdwn h5 {
43
- @apply text-sm font-bold mt-2 mb-2;
44
- }
45
-
46
- .mdwn h6 {
47
- @apply text-xs font-bold mt-2 mb-2;
48
- }
49
-
50
- .mdwn p {
51
- @apply mb-2 leading-relaxed;
52
- }
53
-
54
- .mdwn ul {
55
- @apply list-disc pl-5 mb-2;
56
- }
57
-
58
- .mdwn ol {
59
- @apply list-decimal pl-5 mb-2;
60
- }
61
-
62
- .mdwn li {
63
- @apply mb-1;
64
- }
65
-
66
- .mdwn blockquote {
67
- @apply border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 mb-2;
68
- }
69
-
70
- .mdwn code {
71
- @apply bg-gray-100 dark:bg-gray-800 text-red-600 dark:text-red-400 font-mono px-1 py-0.5 rounded;
72
- }
73
-
74
- .mdwn pre {
75
- @apply bg-gray-100 dark:bg-gray-900 text-sm font-mono p-4 rounded overflow-x-auto mb-2;
76
- }
77
- .mdwn pre code {
78
- @apply bg-transparent p-0 text-inherit;
79
- }
80
-
81
- .mdwn table {
82
- @apply w-full border-collapse text-left text-sm mb-2;
83
- }
84
-
85
- .mdwn thead {
86
- @apply bg-gray-100 dark:bg-gray-700;
87
- }
88
-
89
- .mdwn th,
90
- .mdwn td {
91
- @apply border border-gray-300 dark:border-gray-700 px-4 py-2;
92
- }
93
-
94
- .mdwn th {
95
- @apply font-semibold;
96
- }
97
-
98
- .mdwn hr {
99
- @apply border-t border-gray-300 dark:border-gray-700 my-6;
100
- }
101
-
102
- .mdwn img {
103
- @apply max-w-full h-auto rounded;
104
- }
105
-
106
- .mdwn a {
107
- @apply text-blue-600 hover:underline dark:text-blue-400;
108
- }
109
-
110
- </style>
23
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/markdown",
3
- "version": "1.9.1",
3
+ "version": "1.10.1",
4
4
  "description": "Markdown plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",