@limetech/lime-elements 37.17.2 → 37.18.0
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 +16 -0
- package/dist/cjs/limel-markdown.cjs.entry.js +2 -5
- package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-text-editor.cjs.entry.js +38 -1
- package/dist/cjs/limel-text-editor.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/collection/components/text-editor/menu/default-menu.js +35 -0
- package/dist/collection/components/text-editor/menu/default-menu.js.map +1 -0
- package/dist/collection/components/text-editor/text-editor.js +6 -1
- package/dist/collection/components/text-editor/text-editor.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/esm/limel-text-editor.entry.js +38 -1
- package/dist/esm/limel-text-editor.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-6a0eac83.entry.js → p-7968bfa0.entry.js} +2 -2
- package/dist/lime-elements/p-7968bfa0.entry.js.map +1 -0
- 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/dist/types/components/text-editor/menu/default-menu.d.ts +11 -0
- package/package.json +2 -2
- package/dist/lime-elements/p-6a0eac83.entry.js.map +0 -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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ehype 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"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Dropdown, MenuItem } from 'prosemirror-menu';
|
|
2
|
+
import { buildMenuItems } from 'prosemirror-example-setup';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the default menu for the text editor
|
|
5
|
+
* based on the default menu already in prosemirror-example-setup
|
|
6
|
+
* @param schema - the schema to use for the menu
|
|
7
|
+
*
|
|
8
|
+
* @returns the default menu for the text editor
|
|
9
|
+
*/
|
|
10
|
+
export const buildDefaultMenu = (schema) => {
|
|
11
|
+
const menuItems = buildMenuItems(schema);
|
|
12
|
+
const { inlineMenu, insertHorizontalRule } = menuItems;
|
|
13
|
+
const typeMenu = getNewMenu(menuItems.typeMenu);
|
|
14
|
+
const newHorizontalRule = new MenuItem(Object.assign(Object.assign({}, insertHorizontalRule.spec), { label: 'hr' }));
|
|
15
|
+
const historyButtons = menuItems.fullMenu[2];
|
|
16
|
+
const blockMenu = getBlockMenu(menuItems.blockMenu);
|
|
17
|
+
return [
|
|
18
|
+
inlineMenu[0],
|
|
19
|
+
[newHorizontalRule],
|
|
20
|
+
...typeMenu,
|
|
21
|
+
historyButtons,
|
|
22
|
+
blockMenu,
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
const getNewMenu = (typeMenu) => {
|
|
26
|
+
const headingDropdown = new Dropdown(typeMenu.content[2].content, {
|
|
27
|
+
label: 'H',
|
|
28
|
+
});
|
|
29
|
+
return [[typeMenu.content[0], typeMenu.content[1]], [headingDropdown]];
|
|
30
|
+
};
|
|
31
|
+
const getBlockMenu = (blockMenu) => {
|
|
32
|
+
// eslint-disable-next-line no-magic-numbers
|
|
33
|
+
return [...blockMenu[0].slice(0, 5)];
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=default-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-menu.js","sourceRoot":"","sources":["../../../../src/components/text-editor/menu/default-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAmB,EAAE;EAChE,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAQtC,CAAC;EACF,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC;EACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;EAChD,MAAM,iBAAiB,GAAG,IAAI,QAAQ,iCAC/B,oBAAoB,CAAC,IAAI,KAC5B,KAAK,EAAE,IAAI,IACb,CAAC;EACH,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;EAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;EAEpD,OAAO;IACH,UAAU,CAAC,CAAC,CAAC;IACb,CAAC,iBAAiB,CAAC;IACnB,GAAG,QAAQ;IACX,cAAc;IACd,SAAS;GACZ,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CACf,QAA+C,EAChC,EAAE;EACjB,MAAM,eAAe,GAAa,IAAI,QAAQ,CACzC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAyC,CAAC,OAAO,EACpE;IACI,KAAK,EAAE,GAAG;GACb,CACJ,CAAC;EAEF,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,SAA0B,EAAiB,EAAE;EAC/D,4CAA4C;EAC5C,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import { Schema } from 'prosemirror-model';\nimport { MenuElement, Dropdown, MenuItem } from 'prosemirror-menu';\nimport { buildMenuItems } from 'prosemirror-example-setup';\n\n/**\n * Creates the default menu for the text editor\n * based on the default menu already in prosemirror-example-setup\n * @param schema - the schema to use for the menu\n *\n * @returns the default menu for the text editor\n */\nexport const buildDefaultMenu = (schema: Schema): MenuElement[][] => {\n const menuItems = buildMenuItems(schema) as unknown as {\n blockMenu: MenuElement[][];\n fullMenu: MenuElement[][];\n inlineMenu: MenuElement[][];\n insertHorizontalRule: MenuItem;\n typeMenu: Dropdown & {\n content: MenuElement[];\n };\n };\n const { inlineMenu, insertHorizontalRule } = menuItems;\n const typeMenu = getNewMenu(menuItems.typeMenu);\n const newHorizontalRule = new MenuItem({\n ...insertHorizontalRule.spec,\n label: 'hr',\n });\n const historyButtons = menuItems.fullMenu[2];\n const blockMenu = getBlockMenu(menuItems.blockMenu);\n\n return [\n inlineMenu[0],\n [newHorizontalRule],\n ...typeMenu,\n historyButtons,\n blockMenu,\n ];\n};\n\nconst getNewMenu = (\n typeMenu: Dropdown & { content: MenuElement[] },\n): MenuElement[][] => {\n const headingDropdown: Dropdown = new Dropdown(\n (typeMenu.content[2] as Partial<{ content: MenuElement[] }>).content,\n {\n label: 'H',\n },\n );\n\n return [[typeMenu.content[0], typeMenu.content[1]], [headingDropdown]];\n};\n\nconst getBlockMenu = (blockMenu: MenuElement[][]): MenuElement[] => {\n // eslint-disable-next-line no-magic-numbers\n return [...blockMenu[0].slice(0, 5)];\n};\n"]}
|
|
@@ -5,6 +5,7 @@ import { Schema, DOMParser } from 'prosemirror-model';
|
|
|
5
5
|
import { schema } from 'prosemirror-schema-basic';
|
|
6
6
|
import { addListNodes } from 'prosemirror-schema-list';
|
|
7
7
|
import { exampleSetup } from 'prosemirror-example-setup';
|
|
8
|
+
import { buildDefaultMenu } from './menu/default-menu';
|
|
8
9
|
/**
|
|
9
10
|
* This editor offers a rich text editing experience with markdown support,
|
|
10
11
|
* in the sense that you can easily type markdown syntax and see the rendered
|
|
@@ -31,10 +32,14 @@ export class TextEditor {
|
|
|
31
32
|
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
|
|
32
33
|
marks: schema.spec.marks,
|
|
33
34
|
});
|
|
35
|
+
const menu = buildDefaultMenu(mySchema);
|
|
34
36
|
this.view = new EditorView(this.host.shadowRoot.querySelector('#editor'), {
|
|
35
37
|
state: EditorState.create({
|
|
36
38
|
doc: DOMParser.fromSchema(mySchema).parse(this.host.shadowRoot.querySelector('#editor')),
|
|
37
|
-
plugins: exampleSetup({
|
|
39
|
+
plugins: exampleSetup({
|
|
40
|
+
schema: mySchema,
|
|
41
|
+
menuContent: menu,
|
|
42
|
+
}),
|
|
38
43
|
}),
|
|
39
44
|
dispatchTransaction: (transaction) => {
|
|
40
45
|
const newState = this.view.state.apply(transaction);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-editor.js","sourceRoot":"","sources":["../../../src/components/text-editor/text-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,KAAK,EACL,CAAC,GACJ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,UAAU;;;;EAaZ,iBAAiB,KAAI,CAAC;EAEtB,MAAM;IACT,OAAO,WAAK,EAAE,EAAC,QAAQ,GAAG,CAAC;EAC/B,CAAC;EAEM,gBAAgB;IACnB,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC;MACxB,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,CAAC;MACnE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAA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C,IAAI,CAAC,KAAK;KAC3B,CAAC,CAAC;IAEH,MAAM,IAAI,GAAoB,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEzD,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CACtB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAC7C;MACI,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC;QACtB,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,CACrC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAChD;QACD,OAAO,EAAE,YAAY,CAAC;UAClB,MAAM,EAAE,QAAQ;UAChB,WAAW,EAAE,IAAoB;SACpC,CAAC;OACL,CAAC;MACF,mBAAmB,EAAE,CAAC,WAAW,EAAE,EAAE;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAEhC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;MACxD,CAAC;KACJ,CACJ,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n State,\n h,\n} from '@stencil/core';\nimport { EditorState } from 'prosemirror-state';\nimport { EditorView } from 'prosemirror-view';\nimport { Schema, DOMParser } from 'prosemirror-model';\nimport { schema } from 'prosemirror-schema-basic';\nimport { addListNodes } from 'prosemirror-schema-list';\nimport { exampleSetup } from 'prosemirror-example-setup';\nimport { MenuElement, MenuItem } from 'prosemirror-menu';\nimport { buildDefaultMenu } from './menu/default-menu';\n\n/**\n * This editor offers a rich text editing experience with markdown support,\n * in the sense that you can easily type markdown syntax and see the rendered\n * result as rich text in real-time. For instance, you can type `# Hello, world!`\n * and see it directly turning to a heading 1 (an `<h1>` HTML element).\n *\n * Naturally, you can use standard keyboard hotkeys such as <kbd>Ctrl</kbd> + <kbd>B</kbd>\n * to toggle bold text, <kbd>Ctrl</kbd> + <kbd>I</kbd> to toggle italic text, and so on.\n *\n * @exampleComponent limel-example-text-editor-basic\n * @beta\n * @private\n */\n@Component({\n tag: 'limel-text-editor',\n shadow: true,\n styleUrl: 'text-editor.scss',\n})\nexport class TextEditor {\n @Element()\n private host: HTMLLimelTextEditorElement;\n\n @State()\n private view: EditorView;\n\n /**\n * Dispatched when a change is made to the editor\n */\n @Event()\n private change: EventEmitter<{ html: string }>;\n\n public componentWillLoad() {}\n\n public render() {\n return <div id=\"editor\" />;\n }\n\n public componentDidLoad() {\n const mySchema = new Schema({\n nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),\n marks: schema.spec.marks,\n });\n\n const menu: MenuElement[][] = buildDefaultMenu(mySchema);\n\n this.view = new EditorView(\n this.host.shadowRoot.querySelector('#editor'),\n {\n state: EditorState.create({\n doc: DOMParser.fromSchema(mySchema).parse(\n this.host.shadowRoot.querySelector('#editor'),\n ),\n plugins: exampleSetup({\n schema: mySchema,\n menuContent: menu as MenuItem[][],\n }),\n }),\n dispatchTransaction: (transaction) => {\n const newState = this.view.state.apply(transaction);\n this.view.updateState(newState);\n\n this.change.emit({ html: this.view.dom.innerHTML });\n },\n },\n );\n }\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
|