@adminforth/rich-editor 1.2.1 → 1.2.2

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
@@ -10,5 +10,5 @@ custom/package.json
10
10
  custom/quillEditor.vue
11
11
  custom/tsconfig.json
12
12
 
13
- sent 19,606 bytes received 115 bytes 39,442.00 bytes/sec
14
- total size is 19,183 speedup is 0.97
13
+ sent 20,973 bytes received 115 bytes 42,176.00 bytes/sec
14
+ total size is 20,550 speedup is 0.97
@@ -27,7 +27,6 @@ import AsyncQueue from './async-queue';
27
27
  import Quill from "quill";
28
28
  import "quill/dist/quill.snow.css";
29
29
 
30
-
31
30
  function dbg(title: string,...args: any[]) {
32
31
  // return; // comment for debug
33
32
  console.log(title, ...args.map(a =>JSON.stringify(a, null, 1)));
@@ -292,7 +291,16 @@ onMounted(() => {
292
291
  async function emitTextUpdate() {
293
292
  const editorHtml = quill.root.innerHTML;
294
293
  // remove completion from html
295
- const html = editorHtml.replace(/<span[^>]*completer[^>]*>.*?<\/span>/g, '');
294
+ let html = editorHtml.replace(/<span[^>]*completer[^>]*>.*?<\/span>/g, '');
295
+
296
+ // remove all style attributes
297
+ const parser = new DOMParser();
298
+ const doc = parser.parseFromString(html, 'text/html');
299
+ const elements = doc.querySelectorAll('*');
300
+ elements.forEach((el) => {
301
+ el.removeAttribute('style');
302
+ });
303
+ html = doc.body.innerHTML;
296
304
 
297
305
  if (lastText === html) {
298
306
  return;
@@ -527,8 +535,76 @@ function removeCompletionOnBlur() {
527
535
  font-style: italic;
528
536
  }
529
537
 
530
- .ql-editor p {
531
- margin-bottom: 0.5rem;
538
+ // basic typography
539
+ .ql-editor {
540
+ line-height: 1.5;
541
+
542
+ /* Headings */
543
+ h1, h2, h3, h4, h5, h6 {
544
+ margin-top: 0.5rem;
545
+ margin-bottom: 0.25rem;
546
+ }
547
+
548
+ /* Paragraphs */
549
+ p {
550
+ margin-bottom: 0.4rem;
551
+ }
552
+
553
+ /* Lists */
554
+ ul, ol {
555
+ margin-top: 0.4rem;
556
+ margin-bottom: 0.4rem;
557
+ padding-left: 1rem;
558
+ }
559
+
560
+ /* List items */
561
+ li {
562
+ margin-bottom: 0.2rem;
563
+ }
564
+
565
+ /* Horizontal rule */
566
+ hr {
567
+ margin: 0.8rem 0;
568
+ border: none;
569
+ border-top: 1px solid #ddd;
570
+ }
571
+
572
+ /* Blockquotes */
573
+ blockquote {
574
+ margin: 0.8rem 0;
575
+ padding-left: 0.8rem;
576
+ border-left: 2px solid #ccc;
577
+ }
578
+
579
+ /* Preformatted text */
580
+ pre {
581
+ margin: 0.8rem 0;
582
+ padding: 0.4rem;
583
+ background: #f8f9fa;
584
+ border-radius: 3px;
585
+ }
586
+
587
+ /* Tables */
588
+ table {
589
+ margin: 0.8rem 0;
590
+ border-collapse: collapse;
591
+ }
592
+
593
+ th, td {
594
+ padding: 0.3rem;
595
+ border: 1px solid #ddd;
596
+ }
597
+
598
+ thead th {
599
+ border-bottom: 1.5px solid #aaa;
600
+ }
601
+
602
+ /* Images */
603
+ img {
604
+ margin: 0.4rem 0;
605
+ max-width: 100%;
606
+ height: auto;
607
+ }
532
608
  }
533
609
 
534
610
  .ql-snow .ql-stroke {
@@ -27,7 +27,6 @@ import AsyncQueue from './async-queue';
27
27
  import Quill from "quill";
28
28
  import "quill/dist/quill.snow.css";
29
29
 
30
-
31
30
  function dbg(title: string,...args: any[]) {
32
31
  // return; // comment for debug
33
32
  console.log(title, ...args.map(a =>JSON.stringify(a, null, 1)));
@@ -292,7 +291,16 @@ onMounted(() => {
292
291
  async function emitTextUpdate() {
293
292
  const editorHtml = quill.root.innerHTML;
294
293
  // remove completion from html
295
- const html = editorHtml.replace(/<span[^>]*completer[^>]*>.*?<\/span>/g, '');
294
+ let html = editorHtml.replace(/<span[^>]*completer[^>]*>.*?<\/span>/g, '');
295
+
296
+ // remove all style attributes
297
+ const parser = new DOMParser();
298
+ const doc = parser.parseFromString(html, 'text/html');
299
+ const elements = doc.querySelectorAll('*');
300
+ elements.forEach((el) => {
301
+ el.removeAttribute('style');
302
+ });
303
+ html = doc.body.innerHTML;
296
304
 
297
305
  if (lastText === html) {
298
306
  return;
@@ -527,8 +535,76 @@ function removeCompletionOnBlur() {
527
535
  font-style: italic;
528
536
  }
529
537
 
530
- .ql-editor p {
531
- margin-bottom: 0.5rem;
538
+ // basic typography
539
+ .ql-editor {
540
+ line-height: 1.5;
541
+
542
+ /* Headings */
543
+ h1, h2, h3, h4, h5, h6 {
544
+ margin-top: 0.5rem;
545
+ margin-bottom: 0.25rem;
546
+ }
547
+
548
+ /* Paragraphs */
549
+ p {
550
+ margin-bottom: 0.4rem;
551
+ }
552
+
553
+ /* Lists */
554
+ ul, ol {
555
+ margin-top: 0.4rem;
556
+ margin-bottom: 0.4rem;
557
+ padding-left: 1rem;
558
+ }
559
+
560
+ /* List items */
561
+ li {
562
+ margin-bottom: 0.2rem;
563
+ }
564
+
565
+ /* Horizontal rule */
566
+ hr {
567
+ margin: 0.8rem 0;
568
+ border: none;
569
+ border-top: 1px solid #ddd;
570
+ }
571
+
572
+ /* Blockquotes */
573
+ blockquote {
574
+ margin: 0.8rem 0;
575
+ padding-left: 0.8rem;
576
+ border-left: 2px solid #ccc;
577
+ }
578
+
579
+ /* Preformatted text */
580
+ pre {
581
+ margin: 0.8rem 0;
582
+ padding: 0.4rem;
583
+ background: #f8f9fa;
584
+ border-radius: 3px;
585
+ }
586
+
587
+ /* Tables */
588
+ table {
589
+ margin: 0.8rem 0;
590
+ border-collapse: collapse;
591
+ }
592
+
593
+ th, td {
594
+ padding: 0.3rem;
595
+ border: 1px solid #ddd;
596
+ }
597
+
598
+ thead th {
599
+ border-bottom: 1.5px solid #aaa;
600
+ }
601
+
602
+ /* Images */
603
+ img {
604
+ margin: 0.4rem 0;
605
+ max-width: 100%;
606
+ height: auto;
607
+ }
532
608
  }
533
609
 
534
610
  .ql-snow .ql-stroke {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/rich-editor",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Rich editor plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",