@fishawack/lab-velocity 0.3.6 → 0.3.8

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.
@@ -11,6 +11,7 @@
11
11
  import Quill from "quill";
12
12
  import input from "./input.js";
13
13
  import XInput from "./input.vue";
14
+ import sanitizeHtml from 'sanitize-html';
14
15
 
15
16
  export default {
16
17
  mixins: [input],
@@ -56,11 +57,28 @@ export default {
56
57
  : this.editor.root.innerHTML;
57
58
  },
58
59
  setValue() {
59
- this.editor.root.innerHTML =
60
+ const temp =
60
61
  this.simple && this.modelValue // Surround text in p tags to keep it grouped correctly on simple strings. Ignore if modelValue empty otherwise you'll end up with <p>null</p>
61
62
  ? `<p>${this.modelValue}</p>`
62
63
  : this.modelValue;
64
+ this.editor.root.innerHTML = this.formatCleaner(temp);
63
65
  },
66
+ // Function to remove p tags from inside li tags, breaks the wysiwyg
67
+ formatCleaner(unformmatted) {
68
+ const regex = new RegExp(/(\<li\>(?:\n)*(?:.*)(?:\n)*\<\/li\>)/gm);
69
+ if(regex.test(unformmatted)) {
70
+ let parser = document.createElement('div');
71
+ parser.innerHTML = unformmatted;
72
+ const lists = parser.getElementsByTagName('ul');
73
+ for(var x = 0; x < lists.length; x++) {
74
+ lists[x].innerHTML = sanitizeHtml(lists[x].innerHTML, {
75
+ allowedTags: [ 'b', 'i', 'em', 'strong', 'a','li' ]
76
+ });
77
+ }
78
+ return parser.innerHTML;
79
+ }
80
+ return unformmatted;
81
+ }
64
82
  },
65
83
 
66
84
  mounted() {
@@ -83,6 +101,7 @@ export default {
83
101
  this.simple ? undefined : { list: "ordered" },
84
102
  this.simple ? undefined : { list: "bullet" },
85
103
  "clean",
104
+ "link"
86
105
  ],
87
106
  ],
88
107
  },
package/index.js CHANGED
@@ -9,7 +9,7 @@ export { default as DatePicker } from "./form/DatePicker.vue";
9
9
  export { default as file } from "./form/file.vue";
10
10
  export { default as Select } from "./form/Select.vue";
11
11
  export { default as Switch } from "./form/Switch.vue";
12
- export { default as Wysiwyg } from "./form/wysiwyg.vue";
12
+ export { default as Wysiwyg } from "./form/Wysiwyg.vue";
13
13
 
14
14
  export { default as SideBar } from "./layout/sideBar.vue";
15
15
  export { default as Footer } from "./layout/Footer.vue";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-velocity",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "Avalere Health branded style system",
5
5
  "scripts": {
6
6
  "setup": "npm ci || npm i && npm run content",
@@ -41,7 +41,8 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "element-plus": "^2.7.8",
44
- "quill": "^2.0.2"
44
+ "quill": "^1.3.7",
45
+ "sanitize-html": "^2.13.1"
45
46
  },
46
47
  "files": [
47
48
  "*.scss",