@limetech/lime-elements 37.19.1 → 37.21.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/lime-elements.cjs.js +1 -1
  3. package/dist/cjs/limel-markdown.cjs.entry.js +3 -1
  4. package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
  5. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +16080 -0
  6. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -0
  7. package/dist/cjs/limel-text-editor.cjs.entry.js +13 -16048
  8. package/dist/cjs/limel-text-editor.cjs.entry.js.map +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -0
  11. package/dist/collection/components/markdown/allowed-css-properties.js +2 -0
  12. package/dist/collection/components/markdown/allowed-css-properties.js.map +1 -1
  13. package/dist/collection/components/markdown/markdown-parser.js +1 -1
  14. package/dist/collection/components/markdown/markdown-parser.js.map +1 -1
  15. package/dist/collection/components/text-editor/prosemirror-adapter.css +699 -0
  16. package/dist/collection/components/text-editor/prosemirror-adapter.js +122 -0
  17. package/dist/collection/components/text-editor/prosemirror-adapter.js.map +1 -0
  18. package/dist/collection/components/text-editor/text-editor.css +0 -699
  19. package/dist/collection/components/text-editor/text-editor.js +133 -45
  20. package/dist/collection/components/text-editor/text-editor.js.map +1 -1
  21. package/dist/esm/lime-elements.js +1 -1
  22. package/dist/esm/limel-markdown.entry.js +3 -1
  23. package/dist/esm/limel-markdown.entry.js.map +1 -1
  24. package/dist/esm/limel-prosemirror-adapter.entry.js +16076 -0
  25. package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -0
  26. package/dist/esm/limel-text-editor.entry.js +14 -16049
  27. package/dist/esm/limel-text-editor.entry.js.map +1 -1
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/lime-elements/lime-elements.esm.js +1 -1
  30. package/dist/lime-elements/lime-elements.esm.js.map +1 -1
  31. package/dist/lime-elements/{p-10edf8b8.entry.js → p-0f45a6cc.entry.js} +2 -2
  32. package/dist/lime-elements/p-0f45a6cc.entry.js.map +1 -0
  33. package/dist/lime-elements/p-210c09a6.entry.js +2 -0
  34. package/dist/lime-elements/p-210c09a6.entry.js.map +1 -0
  35. package/dist/lime-elements/{p-ad6b52f8.entry.js → p-a8b9ae53.entry.js} +2 -2
  36. package/dist/lime-elements/{p-ad6b52f8.entry.js.map → p-a8b9ae53.entry.js.map} +1 -1
  37. package/dist/types/components/text-editor/prosemirror-adapter.d.ts +32 -0
  38. package/dist/types/components/text-editor/text-editor.d.ts +52 -13
  39. package/dist/types/components.d.ts +137 -24
  40. package/package.json +1 -1
  41. package/dist/lime-elements/p-10edf8b8.entry.js.map +0 -1
@@ -0,0 +1,122 @@
1
+ import { h, } from '@stencil/core';
2
+ import { EditorState } from 'prosemirror-state';
3
+ import { EditorView } from 'prosemirror-view';
4
+ import { Schema, DOMParser } from 'prosemirror-model';
5
+ import { schema } from 'prosemirror-schema-basic';
6
+ import { addListNodes } from 'prosemirror-schema-list';
7
+ import { exampleSetup } from 'prosemirror-example-setup';
8
+ import { buildFullMenu } from './menu/full-menu';
9
+ import { getFilteredMenu } from './menu/menu-filter';
10
+ /**
11
+ * The ProseMirror adapter offers a rich text editing experience with markdown support,
12
+ * in the sense that you can easily type markdown syntax and see the rendered
13
+ * result as rich text in real-time. For instance, you can type `# Hello, world!`
14
+ * and see it directly turning to a heading 1 (an `<h1>` HTML element).
15
+ *
16
+ * Naturally, you can use standard keyboard hotkeys such as <kbd>Ctrl</kbd> + <kbd>B</kbd>
17
+ * to toggle bold text, <kbd>Ctrl</kbd> + <kbd>I</kbd> to toggle italic text, and so on.
18
+ *
19
+ * @exampleComponent limel-example-prosemirror-adapter-basic
20
+ * @beta
21
+ * @private
22
+ */
23
+ export class ProsemirrorAdapter {
24
+ constructor() {
25
+ this.getHTML = () => {
26
+ if (this.view.dom.textContent === '') {
27
+ return '';
28
+ }
29
+ else {
30
+ return this.view.dom.innerHTML;
31
+ }
32
+ };
33
+ this.value = undefined;
34
+ this.view = undefined;
35
+ }
36
+ componentWillLoad() { }
37
+ render() {
38
+ return h("div", { id: "editor" });
39
+ }
40
+ componentDidLoad() {
41
+ const mySchema = new Schema({
42
+ nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
43
+ marks: schema.spec.marks,
44
+ });
45
+ const menu = buildFullMenu(mySchema)
46
+ .map((items) => getFilteredMenu(items, undefined))
47
+ .filter((items) => items.length);
48
+ this.view = new EditorView(this.host.shadowRoot.querySelector('#editor'), {
49
+ state: EditorState.create({
50
+ doc: DOMParser.fromSchema(mySchema).parse(this.host.shadowRoot.querySelector('#editor')),
51
+ plugins: exampleSetup({
52
+ schema: mySchema,
53
+ menuContent: menu,
54
+ }),
55
+ }),
56
+ dispatchTransaction: (transaction) => {
57
+ const newState = this.view.state.apply(transaction);
58
+ this.view.updateState(newState);
59
+ this.change.emit({ html: this.getHTML() });
60
+ },
61
+ });
62
+ if (this.value) {
63
+ this.view.dom.innerHTML = this.value.html;
64
+ }
65
+ }
66
+ static get is() { return "limel-prosemirror-adapter"; }
67
+ static get encapsulation() { return "shadow"; }
68
+ static get originalStyleUrls() {
69
+ return {
70
+ "$": ["prosemirror-adapter.scss"]
71
+ };
72
+ }
73
+ static get styleUrls() {
74
+ return {
75
+ "$": ["prosemirror-adapter.css"]
76
+ };
77
+ }
78
+ static get properties() {
79
+ return {
80
+ "value": {
81
+ "type": "unknown",
82
+ "mutable": false,
83
+ "complexType": {
84
+ "original": "{ html: string }",
85
+ "resolved": "{ html: string; }",
86
+ "references": {}
87
+ },
88
+ "required": false,
89
+ "optional": false,
90
+ "docs": {
91
+ "tags": [],
92
+ "text": "The value of the editor"
93
+ }
94
+ }
95
+ };
96
+ }
97
+ static get states() {
98
+ return {
99
+ "view": {}
100
+ };
101
+ }
102
+ static get events() {
103
+ return [{
104
+ "method": "change",
105
+ "name": "change",
106
+ "bubbles": true,
107
+ "cancelable": true,
108
+ "composed": true,
109
+ "docs": {
110
+ "tags": [],
111
+ "text": "Dispatched when a change is made to the editor"
112
+ },
113
+ "complexType": {
114
+ "original": "{ html: string }",
115
+ "resolved": "{ html: string; }",
116
+ "references": {}
117
+ }
118
+ }];
119
+ }
120
+ static get elementRef() { return "host"; }
121
+ }
122
+ //# sourceMappingURL=prosemirror-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosemirror-adapter.js","sourceRoot":"","sources":["../../../src/components/text-editor/prosemirror-adapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,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,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,kBAAkB;;IA6DnB,YAAO,GAAG,GAAW,EAAE;MAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,EAAE;QAClC,OAAO,EAAE,CAAC;OACb;WAAM;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;OAClC;IACL,CAAC,CAAC;;;;EAhDK,iBAAiB,KAAI,CAAC;EAEtB,MAAM;IAC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AAI,IAAI,CAAC,KAAK,EAAE;MACZ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KAC7C;EACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n Prop,\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 { buildFullMenu } from './menu/full-menu';\nimport { getFilteredMenu } from './menu/menu-filter';\n\n/**\n * The ProseMirror adapter 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-prosemirror-adapter-basic\n * @beta\n * @private\n */\n@Component({\n tag: 'limel-prosemirror-adapter',\n shadow: true,\n styleUrl: 'prosemirror-adapter.scss',\n})\nexport class ProsemirrorAdapter {\n /**\n * The value of the editor\n */\n @Prop()\n public value: { html: string };\n\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[][] = buildFullMenu(mySchema)\n .map((items) => getFilteredMenu(items, undefined))\n .filter((items) => items.length);\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.getHTML() });\n },\n },\n );\n\n if (this.value) {\n this.view.dom.innerHTML = this.value.html;\n }\n }\n\n private getHTML = (): string => {\n if (this.view.dom.textContent === '') {\n return '';\n } else {\n return this.view.dom.innerHTML;\n }\n };\n}\n"]}