@limetech/lime-elements 37.17.2 → 37.17.3
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/CHANGELOG.md +8 -0
- package/dist/cjs/limel-markdown.cjs.entry.js +2 -5
- package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
- package/dist/collection/components/markdown/markdown-parser.js +4 -6
- package/dist/collection/components/markdown/markdown-parser.js.map +1 -1
- package/dist/esm/limel-markdown.entry.js +2 -5
- package/dist/esm/limel-markdown.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-6f03ee09.entry.js → p-ad6b52f8.entry.js} +2 -2
- package/dist/lime-elements/{p-6f03ee09.entry.js.map → p-ad6b52f8.entry.js.map} +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import remarkParse from 'remark-parse';
|
|
|
3
3
|
import remarkRehype from 'remark-rehype';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
5
5
|
import rehypeExternalLinks from 'rehype-external-links';
|
|
6
|
-
import rehypeSanitize from 'rehype-sanitize';
|
|
6
|
+
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
|
7
7
|
import rehypeStringify from 'rehype-stringify';
|
|
8
8
|
import rehypeRaw from 'rehype-raw';
|
|
9
9
|
import { visit } from 'unist-util-visit';
|
|
@@ -32,12 +32,10 @@ export async function markdownToHTML(text, options) {
|
|
|
32
32
|
.use(remarkRehype, { allowDangerousHtml: true })
|
|
33
33
|
.use(rehypeExternalLinks, { target: '_blank' })
|
|
34
34
|
.use(rehypeRaw)
|
|
35
|
-
.use(rehypeSanitize, {
|
|
35
|
+
.use(rehypeSanitize, Object.assign(Object.assign({}, defaultSchema), {
|
|
36
36
|
// Allow the `style` attribute on all elements
|
|
37
|
-
attributes: {
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
})
|
|
37
|
+
attributes: Object.assign(Object.assign({}, defaultSchema.attributes), { '*': ['style'] })
|
|
38
|
+
}))
|
|
41
39
|
.use(() => {
|
|
42
40
|
return (tree) => {
|
|
43
41
|
// Run the sanitizeStyle function on all elements, to sanitize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-parser.js","sourceRoot":"","sources":["../../../src/components/markdown/markdown-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,cAAc,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown-parser.js","sourceRoot":"","sources":["../../../src/components/markdown/markdown-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,cAAc,EAAE,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,IAAY,EACZ,OAA+B;EAE/B,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,EAAE;IAC9B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;GAC5C;EAED,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE;KACvB,GAAG,CAAC,WAAW,CAAC;KAChB,GAAG,CAAC,SAAS,CAAC;KACd,GAAG,CAAC,YAAY,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;KAC/C,GAAG,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;KAC9C,GAAG,CAAC,SAAS,CAAC;KACd,GAAG,CAAC,cAAc,kCACZ,aAAa;IAChB,8CAA8C;IAC9C,UAAU,kCACH,aAAa,CAAC,UAAU,KAC3B,GAAG,EAAE,CAAC,OAAO,CAAC,OAEpB;KACD,GAAG,CAAC,GAAG,EAAE;IACN,OAAO,CAAC,IAAS,EAAE,EAAE;MACjB,8DAA8D;MAC9D,uDAAuD;MACvD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC1C,CAAC,CAAC;EACN,CAAC,CAAC;KACD,GAAG,CAAC,eAAe,CAAC;KACpB,OAAO,CAAC,IAAI,CAAC,CAAC;EAEnB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport remarkGfm from 'remark-gfm';\nimport rehypeExternalLinks from 'rehype-external-links';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeRaw from 'rehype-raw';\nimport { visit } from 'unist-util-visit';\nimport { sanitizeStyle } from './sanitize-style';\n\n/**\n * Takes a string as input and returns a new string\n * where the text has been converted to HTML.\n *\n * If the text is formatted with .md markdown, it will\n * be transformed to HTML.\n *\n * If the text already is in HTML it will be sanitized and\n * \"dangerous\" tags such as <script> will be removed.\n *\n * @param text - The string to convert.\n * @param options - Options for the conversions.\n * @returns The resulting HTML.\n */\nexport async function markdownToHTML(\n text: string,\n options?: markdownToHTMLOptions,\n): Promise<string> {\n if (options?.forceHardLineBreaks) {\n text = text.replace(/([\\n\\r])/g, ' $1');\n }\n\n const file = await unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeExternalLinks, { target: '_blank' })\n .use(rehypeRaw)\n .use(rehypeSanitize, {\n ...defaultSchema,\n // Allow the `style` attribute on all elements\n attributes: {\n ...defaultSchema.attributes,\n '*': ['style'],\n },\n })\n .use(() => {\n return (tree: any) => {\n // Run the sanitizeStyle function on all elements, to sanitize\n // the value of the `style` attribute, if there is one.\n visit(tree, 'element', sanitizeStyle);\n };\n })\n .use(rehypeStringify)\n .process(text);\n\n return file.toString();\n}\n\n/**\n * Options for markdownToHTML.\n */\nexport interface markdownToHTMLOptions {\n /**\n * Set to `true` to convert all soft line breaks to hard line breaks.\n */\n forceHardLineBreaks?: boolean;\n}\n"]}
|
|
@@ -43694,12 +43694,9 @@ async function markdownToHTML(text, options) {
|
|
|
43694
43694
|
.use(remarkRehype, { allowDangerousHtml: true })
|
|
43695
43695
|
.use(rehypeExternalLinks, { target: '_blank' })
|
|
43696
43696
|
.use(rehypeRaw)
|
|
43697
|
-
.use(rehypeSanitize, {
|
|
43697
|
+
.use(rehypeSanitize, Object.assign(Object.assign({}, defaultSchema), {
|
|
43698
43698
|
// Allow the `style` attribute on all elements
|
|
43699
|
-
attributes: {
|
|
43700
|
-
'*': ['style'],
|
|
43701
|
-
},
|
|
43702
|
-
})
|
|
43699
|
+
attributes: Object.assign(Object.assign({}, defaultSchema.attributes), { '*': ['style'] }) }))
|
|
43703
43700
|
.use(() => {
|
|
43704
43701
|
return (tree) => {
|
|
43705
43702
|
// Run the sanitizeStyle function on all elements, to sanitize
|