@radioactive-labs/plutonium 0.1.14 → 0.1.15
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/package.json +2 -1
- package/src/css/easymde.css +105 -28
- package/src/css/slim_select.css +6 -0
- package/src/dist/css/plutonium.css +1 -1
- package/src/dist/js/plutonium.js +3500 -263
- package/src/dist/js/plutonium.js.map +4 -4
- package/src/dist/js/plutonium.min.js +65 -6
- package/src/dist/js/plutonium.min.js.map +4 -4
- package/src/js/controllers/easymde_controller.js +21 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
import DOMPurify from 'dompurify';
|
|
3
|
+
import { marked } from 'marked';
|
|
2
4
|
|
|
3
5
|
// Connects to data-controller="easymde"
|
|
4
6
|
export default class extends Controller {
|
|
@@ -19,7 +21,25 @@ export default class extends Controller {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
#buildOptions() {
|
|
22
|
-
let options = {
|
|
24
|
+
let options = {
|
|
25
|
+
element: this.element,
|
|
26
|
+
promptURLs: true,
|
|
27
|
+
spellChecker: false,
|
|
28
|
+
// Override the default preview renderer
|
|
29
|
+
previewRender: (plainText) => {
|
|
30
|
+
// First sanitize the input to remove any undesired HTML
|
|
31
|
+
const cleanedText = DOMPurify.sanitize(plainText, {
|
|
32
|
+
ALLOWED_TAGS: ['strong', 'em', 'sub', 'sup', 'details', 'summary'],
|
|
33
|
+
ALLOWED_ATTR: []
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Then convert markdown to HTML
|
|
37
|
+
const cleanedHTML = marked(cleanedText);
|
|
38
|
+
|
|
39
|
+
// Finally, another pass, since marked does not sanitize html
|
|
40
|
+
return DOMPurify.sanitize(cleanedHTML, { USE_PROFILES: { html: true } })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
23
43
|
if (this.element.attributes.id.value) {
|
|
24
44
|
options.autosave = {
|
|
25
45
|
enabled: true,
|