@limetech/lime-elements 37.26.2 → 37.26.4

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 (28) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +36 -27
  3. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
  4. package/dist/cjs/limel-text-editor.cjs.entry.js +6 -3
  5. package/dist/cjs/limel-text-editor.cjs.entry.js.map +1 -1
  6. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.css +59 -268
  7. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +35 -26
  8. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
  9. package/dist/collection/components/text-editor/text-editor.css +98 -130
  10. package/dist/collection/components/text-editor/text-editor.js +6 -2
  11. package/dist/collection/components/text-editor/text-editor.js.map +1 -1
  12. package/dist/esm/limel-prosemirror-adapter.entry.js +36 -27
  13. package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
  14. package/dist/esm/limel-text-editor.entry.js +6 -3
  15. package/dist/esm/limel-text-editor.entry.js.map +1 -1
  16. package/dist/lime-elements/lime-elements.esm.js +1 -1
  17. package/dist/lime-elements/p-48d4564a.entry.js +2 -0
  18. package/dist/lime-elements/p-48d4564a.entry.js.map +1 -0
  19. package/dist/lime-elements/p-71cd8be1.entry.js +2 -0
  20. package/dist/lime-elements/p-71cd8be1.entry.js.map +1 -0
  21. package/dist/types/components/text-editor/prosemirror-adapter/prosemirror-adapter.d.ts +2 -1
  22. package/dist/types/components/text-editor/text-editor.d.ts +2 -1
  23. package/dist/types/components.d.ts +4 -0
  24. package/package.json +1 -1
  25. package/dist/lime-elements/p-6ebde4a2.entry.js +0 -2
  26. package/dist/lime-elements/p-6ebde4a2.entry.js.map +0 -1
  27. package/dist/lime-elements/p-db7ce0f8.entry.js +0 -2
  28. package/dist/lime-elements/p-db7ce0f8.entry.js.map +0 -1
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d1052409.js');
6
6
 
7
- const textEditorCss = "@charset \"UTF-8\";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}.lime-empty-value-for-readonly{z-index:1;position:absolute;top:0.875rem;left:1rem}.lime-looks-like-input-value{line-height:1.75rem;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;color:rgba(var(--contrast-1400), 1);font-size:0.875rem;font-weight:400;letter-spacing:0.009375em}.mdc-text-field--disabled .lime-looks-like-input-value{cursor:not-allowed;opacity:0.4}:host(limel-text-editor){display:flex;flex-direction:column;width:100%;position:relative}fieldset{min-width:0;min-height:0}:host(limel-text-editor[readonly]) fieldset{padding-block-start:0.75rem}:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}fieldset{box-sizing:border-box;transition:border-color 0.2s ease, background-color 0.2s ease;border:1px solid;border-radius:0.25rem;margin-inline-start:0;margin-inline-end:0;padding-block-start:0;padding-inline-start:0.75rem;padding-inline-end:0.75rem;padding-block-end:0.75rem}fieldset:not([disabled]){border-color:rgba(var(--contrast-700), 0.65);background-color:rgba(var(--contrast-200), 0.5)}fieldset:not([disabled]):hover{border-color:rgba(var(--contrast-700), 1);background-color:rgba(var(--contrast-200), 1)}fieldset:not([disabled]):focus-within{border-color:var(--mdc-theme-primary)}fieldset[disabled]{border-color:transparent}fieldset:has(legend){margin-top:calc((-0.75rem / 2) + (1px / 2))}legend{box-sizing:border-box;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:100%;color:rgba(var(--contrast-1200), 1);font-size:0.65rem;letter-spacing:var(--mdc-typography-subtitle1-letter-spacing, 0.009375em);padding-inline-start:0.25rem;padding-inline-end:0.25rem}";
7
+ const textEditorCss = "@charset \"UTF-8\";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}.lime-empty-value-for-readonly{z-index:1;position:absolute;top:0.875rem;left:1rem}.lime-looks-like-input-value{line-height:1.75rem;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;color:rgba(var(--contrast-1400), 1);font-size:0.875rem;font-weight:400;letter-spacing:0.009375em}.mdc-text-field--disabled .lime-looks-like-input-value{cursor:not-allowed;opacity:0.4}*{box-sizing:border-box}:host(limel-text-editor){--limel-text-editor-padding:0.75rem;position:relative;isolation:isolate;display:flex;flex-direction:column;width:100%;min-width:5rem;min-height:4rem;height:100%;max-height:100%}:host(limel-text-editor:not([readonly])){--limel-text-editor-outline-color:rgba(var(--contrast-700), 0.65);--limel-text-editor-background-color:rgba(var(--contrast-200), 0.5);--limel-text-editor-label-color:rgba(var(--contrast-1200), 1)}:host(limel-text-editor[readonly]){--limel-text-editor-outline-color:transparent;min-height:2.5rem}:host(limel-text-editor[readonly]) limel-markdown{display:block;padding:var(--limel-text-editor-padding)}.notched-outline{position:absolute;inset:0;display:flex;background-color:var(--limel-text-editor-background-color)}.leading-outline,.notch,.trailing-outline{border-width:1px;border-style:solid;border-color:var(--limel-text-editor-outline-color)}.leading-outline{flex-shrink:0;width:0.75rem;border-right-width:0;border-top-left-radius:0.25rem;border-bottom-left-radius:0.25rem}.notch{flex-shrink:0;position:relative;z-index:2;border-top-width:0;border-right-width:0;border-left-width:0;max-width:calc(100% - 1.5rem)}.trailing-outline{flex-grow:1;border-left-width:0;border-top-right-radius:0.25rem;border-bottom-right-radius:0.25rem}label{transform:translateY(-50%);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:block;padding:0 0.25rem;color:var(--limel-text-editor-label-color);font-size:0.65rem;letter-spacing:var(--mdc-typography-subtitle1-letter-spacing, 0.009375em)}limel-prosemirror-adapter{flex-grow:1;min-width:0;min-height:0;height:100%;overflow:hidden auto}";
8
8
 
9
9
  const TextEditor = class {
10
10
  constructor(hostRef) {
@@ -23,7 +23,10 @@ const TextEditor = class {
23
23
  this.value = undefined;
24
24
  }
25
25
  render() {
26
- return (index.h("fieldset", { disabled: this.readonly || this.disabled }, this.renderLabel(), this.renderEditor()));
26
+ return [
27
+ index.h("span", { class: "notched-outline" }, index.h("span", { class: "leading-outline" }), this.renderLabel(), index.h("span", { class: "trailing-outline" })),
28
+ this.renderEditor(),
29
+ ];
27
30
  }
28
31
  renderEditor() {
29
32
  if (this.readonly && !this.value) {
@@ -38,7 +41,7 @@ const TextEditor = class {
38
41
  if (!this.label) {
39
42
  return;
40
43
  }
41
- return index.h("legend", null, this.label);
44
+ return (index.h("span", { class: "notch" }, index.h("label", null, this.label)));
42
45
  }
43
46
  };
44
47
  TextEditor.style = textEditorCss;
@@ -1 +1 @@
1
- {"file":"limel-text-editor.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,aAAa,GAAG,+0HAA+0H;;MCsBx1H,UAAU;;;;IAkGX,iBAAY,GAAG,MAAM,CAAC,KAA0B;MACpD,KAAK,CAAC,eAAe,EAAE,CAAC;MACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC;;;;;;;;;EAzCK,MAAM;IACT,QACIA,sBAAU,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAC7C,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,YAAY,EAAE,CACb,EACb;GACL;EAEO,YAAY;IAChB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MAC9B,QACIA,kBAAM,KAAK,EAAC,2DAA2D,aAEhE,EACT;KACL;IAED,IAAI,IAAI,CAAC,QAAQ,EAAE;MACf,OAAOA,4BAAgB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CAAC;KAChD;IAED,QACIA,uCACI,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,GACnB,EACJ;GACL;EAEO,WAAW;IACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MACb,OAAO;KACV;IAED,OAAOA,wBAAS,IAAI,CAAC,KAAK,CAAU,CAAC;GACxC;;;;;;","names":["h"],"sources":["./src/components/text-editor/text-editor.scss?tag=limel-text-editor&encapsulation=shadow","./src/components/text-editor/text-editor.tsx"],"sourcesContent":["@use '../../style/internal/shared_input-select-picker';\n\n@include shared_input-select-picker.lime-empty-value-for-readonly;\n@include shared_input-select-picker.lime-looks-like-input-value;\n\n:host(limel-text-editor) {\n display: flex;\n flex-direction: column;\n width: 100%;\n position: relative;\n}\n\nfieldset {\n min-width: 0;\n min-height: 0;\n\n :host(limel-text-editor[readonly]) & {\n padding-block-start: 0.75rem;\n }\n}\n\n@import '../../style/internal/fieldset.scss';\n","import { Component, Event, EventEmitter, Prop, h } from '@stencil/core';\nimport { FormComponent } from '../form/form.types';\n/**\n * A rich text editor that 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 * @exampleComponent limel-example-text-editor-as-form-component\n * @exampleComponent limel-example-text-editor-composite\n * @beta\n * @private\n */\n@Component({\n tag: 'limel-text-editor',\n shadow: true,\n styleUrl: 'text-editor.scss',\n})\nexport class TextEditor implements FormComponent<string> {\n /**\n * Set to `true` to disable the field.\n * Use `disabled` to indicate that the field can normally be interacted\n * with, but is currently disabled. This tells the user that if certain\n * requirements are met, the field may become enabled again.\n */\n @Prop({ reflect: true })\n public disabled?: boolean;\n\n /**\n * Set to `true` to make the component read-only.\n * Use `readonly` when the field is only there to present the data it holds,\n * and will not become possible for the current user to edit.\n * :::note\n * Consider that it might be better to use `limel-markdown`\n * instead of `limel-text-editor` when the goal is visualizing data.\n * :::\n */\n @Prop({ reflect: true })\n public readonly?: boolean;\n\n /**\n * Optional helper text to display below the input field when it has focus\n */\n @Prop({ reflect: true })\n public helperText?: string;\n\n /**\n * The placeholder text shown inside the input field,\n * when the field is empty.\n */\n @Prop({ reflect: true })\n public placeholder?: string;\n\n /**\n * The label of the editor\n */\n @Prop({ reflect: true })\n public label?: string;\n\n /**\n * Set to `true` to indicate that the current value of the editor is\n * invalid.\n */\n @Prop({ reflect: true })\n public invalid?: boolean;\n\n /**\n * Description of the text inside the editor as serialised HTML\n */\n @Prop({ reflect: true })\n public value: string;\n\n /**\n * Dispatched when a change is made to the editor\n */\n @Event()\n public change: EventEmitter<string>;\n\n public render() {\n return (\n <fieldset disabled={this.readonly || this.disabled}>\n {this.renderLabel()}\n {this.renderEditor()}\n </fieldset>\n );\n }\n\n private renderEditor() {\n if (this.readonly && !this.value) {\n return (\n <span class=\"lime-empty-value-for-readonly lime-looks-like-input-value\">\n –\n </span>\n );\n }\n\n if (this.readonly) {\n return <limel-markdown value={this.value} />;\n }\n\n return (\n <limel-prosemirror-adapter\n onChange={this.handleChange}\n value={this.value}\n />\n );\n }\n\n private renderLabel() {\n if (!this.label) {\n return;\n }\n\n return <legend>{this.label}</legend>;\n }\n\n private handleChange = () => (event: CustomEvent<string>) => {\n event.stopPropagation();\n this.change.emit(event.detail);\n };\n}\n"],"version":3}
1
+ {"file":"limel-text-editor.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,aAAa,GAAG,wpGAAwpG;;MCuBjqG,UAAU;;;;IAwGX,iBAAY,GAAG,MAAM,CAAC,KAA0B;MACpD,KAAK,CAAC,eAAe,EAAE,CAAC;MACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC;;;;;;;;;EA/CK,MAAM;IACT,OAAO;MACHA,kBAAM,KAAK,EAAC,iBAAiB,IACzBA,kBAAM,KAAK,EAAC,iBAAiB,GAAG,EAC/B,IAAI,CAAC,WAAW,EAAE,EACnBA,kBAAM,KAAK,EAAC,kBAAkB,GAAG,CAC9B;MACP,IAAI,CAAC,YAAY,EAAE;KACtB,CAAC;GACL;EAEO,YAAY;IAChB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MAC9B,QACIA,kBAAM,KAAK,EAAC,2DAA2D,aAEhE,EACT;KACL;IAED,IAAI,IAAI,CAAC,QAAQ,EAAE;MACf,OAAOA,4BAAgB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CAAC;KAChD;IAED,QACIA,uCACI,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,GACnB,EACJ;GACL;EAEO,WAAW;IACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MACb,OAAO;KACV;IAED,QACIA,kBAAM,KAAK,EAAC,OAAO,IACfA,uBAAQ,IAAI,CAAC,KAAK,CAAS,CACxB,EACT;GACL;;;;;;","names":["h"],"sources":["./src/components/text-editor/text-editor.scss?tag=limel-text-editor&encapsulation=shadow","./src/components/text-editor/text-editor.tsx"],"sourcesContent":["@use '../../style/internal/shared_input-select-picker';\n@use '../../../src/style/mixins.scss';\n\n@include shared_input-select-picker.lime-empty-value-for-readonly;\n@include shared_input-select-picker.lime-looks-like-input-value;\n\n* {\n box-sizing: border-box;\n}\n\n:host(limel-text-editor) {\n --limel-text-editor-padding: 0.75rem;\n position: relative;\n isolation: isolate;\n display: flex;\n flex-direction: column;\n\n width: 100%;\n min-width: 5rem;\n min-height: 4rem;\n height: 100%;\n max-height: 100%;\n}\n\n:host(limel-text-editor:not([readonly])) {\n --limel-text-editor-outline-color: #{shared_input-select-picker.$lime-text-field-outline-color};\n --limel-text-editor-background-color: #{shared_input-select-picker.$background-color-normal};\n --limel-text-editor-label-color: #{shared_input-select-picker.$label-color};\n}\n\n:host(limel-text-editor[readonly]) {\n --limel-text-editor-outline-color: transparent;\n min-height: shared_input-select-picker.$height-of-mdc-text-field;\n\n limel-markdown {\n display: block;\n padding: var(--limel-text-editor-padding);\n }\n}\n\n.notched-outline {\n position: absolute;\n inset: 0;\n\n display: flex;\n background-color: var(--limel-text-editor-background-color);\n}\n\n.leading-outline,\n.notch,\n.trailing-outline {\n border-width: 1px;\n border-style: solid;\n border-color: var(--limel-text-editor-outline-color);\n}\n\n.leading-outline {\n flex-shrink: 0;\n width: 0.75rem;\n border-right-width: 0;\n border-top-left-radius: 0.25rem;\n border-bottom-left-radius: 0.25rem;\n}\n\n.notch {\n flex-shrink: 0;\n\n position: relative;\n z-index: 2;\n\n border-top-width: 0;\n border-right-width: 0;\n border-left-width: 0;\n\n max-width: calc(100% - 1.5rem);\n}\n\n.trailing-outline {\n flex-grow: 1;\n border-left-width: 0;\n border-top-right-radius: 0.25rem;\n border-bottom-right-radius: 0.25rem;\n}\n\nlabel {\n transform: translateY(-50%);\n\n @include mixins.truncate-text;\n display: block;\n padding: 0 0.25rem;\n\n color: var(--limel-text-editor-label-color);\n font-size: 0.65rem; // `10.4px` similar to MDC's floating label\n letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em);\n}\n\nlimel-prosemirror-adapter {\n flex-grow: 1;\n\n min-width: 0;\n min-height: 0;\n height: 100%;\n overflow: hidden auto;\n}\n","import { Component, Event, EventEmitter, Prop, h } from '@stencil/core';\nimport { FormComponent } from '../form/form.types';\n/**\n * A rich text editor that 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 * @exampleComponent limel-example-text-editor-as-form-component\n * @exampleComponent limel-example-text-editor-composite\n * @exampleComponent limel-example-text-editor-height\n * @beta\n * @private\n */\n@Component({\n tag: 'limel-text-editor',\n shadow: true,\n styleUrl: 'text-editor.scss',\n})\nexport class TextEditor implements FormComponent<string> {\n /**\n * Set to `true` to disable the field.\n * Use `disabled` to indicate that the field can normally be interacted\n * with, but is currently disabled. This tells the user that if certain\n * requirements are met, the field may become enabled again.\n */\n @Prop({ reflect: true })\n public disabled?: boolean;\n\n /**\n * Set to `true` to make the component read-only.\n * Use `readonly` when the field is only there to present the data it holds,\n * and will not become possible for the current user to edit.\n * :::note\n * Consider that it might be better to use `limel-markdown`\n * instead of `limel-text-editor` when the goal is visualizing data.\n * :::\n */\n @Prop({ reflect: true })\n public readonly?: boolean;\n\n /**\n * Optional helper text to display below the input field when it has focus\n */\n @Prop({ reflect: true })\n public helperText?: string;\n\n /**\n * The placeholder text shown inside the input field,\n * when the field is empty.\n */\n @Prop({ reflect: true })\n public placeholder?: string;\n\n /**\n * The label of the editor\n */\n @Prop({ reflect: true })\n public label?: string;\n\n /**\n * Set to `true` to indicate that the current value of the editor is\n * invalid.\n */\n @Prop({ reflect: true })\n public invalid?: boolean;\n\n /**\n * Description of the text inside the editor as serialised HTML\n */\n @Prop({ reflect: true })\n public value: string;\n\n /**\n * Dispatched when a change is made to the editor\n */\n @Event()\n public change: EventEmitter<string>;\n\n public render() {\n return [\n <span class=\"notched-outline\">\n <span class=\"leading-outline\" />\n {this.renderLabel()}\n <span class=\"trailing-outline\" />\n </span>,\n this.renderEditor(),\n ];\n }\n\n private renderEditor() {\n if (this.readonly && !this.value) {\n return (\n <span class=\"lime-empty-value-for-readonly lime-looks-like-input-value\">\n –\n </span>\n );\n }\n\n if (this.readonly) {\n return <limel-markdown value={this.value} />;\n }\n\n return (\n <limel-prosemirror-adapter\n onChange={this.handleChange}\n value={this.value}\n />\n );\n }\n\n private renderLabel() {\n if (!this.label) {\n return;\n }\n\n return (\n <span class=\"notch\">\n <label>{this.label}</label>\n </span>\n );\n }\n\n private handleChange = () => (event: CustomEvent<string>) => {\n event.stopPropagation();\n this.change.emit(event.detail);\n };\n}\n"],"version":3}
@@ -1,132 +1,4 @@
1
1
  @charset "UTF-8";
2
- :host(limel-prosemirror-adapter) {
3
- isolation: isolate;
4
- display: block;
5
- }
6
-
7
- * {
8
- box-sizing: border-box;
9
- }
10
-
11
- .ProseMirror-menubar-wrapper {
12
- display: grid;
13
- grid-template-rows: auto 1fr;
14
- }
15
-
16
- .ProseMirror-textblock-dropdown {
17
- min-width: 3em;
18
- }
19
-
20
- .ProseMirror-tooltip .ProseMirror-menu {
21
- width: -webkit-fit-content;
22
- width: fit-content;
23
- white-space: pre;
24
- }
25
-
26
- .ProseMirror {
27
- position: relative;
28
- word-wrap: break-word;
29
- white-space: pre-wrap;
30
- white-space: break-spaces;
31
- -webkit-font-variant-ligatures: none;
32
- font-variant-ligatures: none;
33
- font-feature-settings: "liga" 0;
34
- padding-top: 0.75rem;
35
- }
36
- .ProseMirror [draggable][contenteditable=false] {
37
- user-select: text;
38
- }
39
- .ProseMirror:focus-visible {
40
- outline: none;
41
- }
42
-
43
- .ProseMirror-hideselection {
44
- caret-color: transparent;
45
- }
46
- .ProseMirror-hideselection *::selection {
47
- background: transparent;
48
- }
49
- .ProseMirror-hideselection *::-moz-selection {
50
- background: transparent;
51
- }
52
-
53
- .ProseMirror-selectednode {
54
- outline: 0.125rem solid rgb(var(--color-sky-light));
55
- }
56
-
57
- li.ProseMirror-selectednode {
58
- outline: none;
59
- }
60
- li.ProseMirror-selectednode:after {
61
- content: "";
62
- position: absolute;
63
- left: -2rem;
64
- right: -0.125rem;
65
- top: -0.125rem;
66
- bottom: -0.125rem;
67
- border: 0.125rem solid rgb(var(--color-sky-light));
68
- pointer-events: none;
69
- }
70
-
71
- img.ProseMirror-separator {
72
- display: inline !important;
73
- border: none !important;
74
- margin: 0 !important;
75
- }
76
-
77
- /**
78
- * Note! This file is exported to `dist/scss/` in the published
79
- * node module, for consumer projects to import.
80
- * That means this file cannot import from any file that isn't
81
- * also exported, keeping the same relative path.
82
- *
83
- * Or, just don't import anything, that works too.
84
- */
85
- /**
86
- * This can be used on a trigger element that opens a dropdown menu or a popover.
87
- */
88
- /**
89
- * This mixin will mask out the content that is close to
90
- * the edges of a scrollable area.
91
- * - If the scrollable content has `overflow-y`, use `vertically`
92
- * as an argument for `$direction`.
93
- - If the scrollable content has `overflow-x`, use `horizontally`
94
- * as an argument for `$direction`.
95
- *
96
- * For the visual effect to work smoothly, we need to make sure that
97
- * the size of the fade-out edge effect is the same as the
98
- * internal paddings of the scrollable area. Otherwise, content of a
99
- * scrollable area that does not have a padding will fade out before
100
- * any scrolling has been done.
101
- * This is why this mixin already adds paddings, which automatically
102
- * default to the size of the fade-out effect.
103
- * This size defaults to `1rem`, but to override the size use
104
- * `--limel-top-edge-fade-height` & `--limel-bottom-edge-fade-height`
105
- * when `vertically` argument is set, and use
106
- * `--limel-left-edge-fade-width` & `--limel-right-edge-fade-width`
107
- * when `horizontally` argument is set.
108
- * Of course you can also programmatically increase and decrease the
109
- * size of these variables for each edge, based on the amount of
110
- * scrolling that has been done by the user. In this case, make sure
111
- * to add a custom padding where the mixin is used, to override
112
- * the paddings that are automatically added by the mixin in the
113
- * compiled CSS code.
114
- */
115
- /**
116
- * This mixin will add an animated underline to the bottom of an `a` elements.
117
- * Note that you may need to add `all: unset;` –depending on your use case–
118
- * before using this mixin.
119
- */
120
- /**
121
- * This mixin creates a cross-browser font stack.
122
- * - `sans-serif` can be used for the UI of the components.
123
- * - `monospace` can be used for code.
124
- *
125
- * ⚠️ If we change the font stacks, we need to update
126
- * 1. the consumer documentation in `README.md`, and
127
- * 2. the CSS variables of `--kompendium-example-font-family`
128
- * in the `<style>` tag of `index.html`.
129
- */
130
2
  /*
131
3
  * This file is imported into every component!
132
4
  *
@@ -193,171 +65,90 @@ img.ProseMirror-separator {
193
65
  );
194
66
  }
195
67
 
196
- div#editor .ProseMirror-menubar {
197
- position: sticky !important;
198
- z-index: 1;
199
- top: 0;
200
- margin-left: -0.75rem;
201
- margin-right: -0.75rem;
202
- background-color: rgba(var(--contrast-200), 0.5);
203
- backdrop-filter: blur(0.25rem);
204
- -webkit-backdrop-filter: blur(0.25rem);
205
- }
206
- div#editor .ProseMirror-menubar[style*="position: fixed"] {
207
- box-shadow: 0 0.25rem 0.5rem -0.5rem rgb(var(--color-black), 0.8);
208
- }
209
- div#editor .ProseMirror-menubar-spacer {
210
- display: none;
68
+ :host(limel-prosemirror-adapter) {
69
+ display: block;
211
70
  }
212
71
 
213
- .ProseMirror-menubar {
214
- position: relative;
215
- z-index: 1;
216
- display: flex;
217
- flex-wrap: wrap;
218
- gap: 0.25rem;
219
- align-items: center;
220
- padding: 0.125rem;
221
- border-top-left-radius: 0.5rem;
222
- border-top-right-radius: 0.5rem;
72
+ * {
73
+ box-sizing: border-box;
223
74
  }
224
75
 
225
- .ProseMirror-menuitem {
226
- position: relative;
227
- flex-shrink: 0;
228
- display: flex;
229
- align-items: center;
230
- justify-content: center;
231
- white-space: nowrap;
232
- line-height: 1;
233
- height: 1.5rem;
234
- min-width: 1.5rem;
235
- border-radius: 0.25rem;
236
- color: rgb(var(--contrast-1100));
237
- font-size: 0.8125rem;
238
- }
239
- .ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)) {
240
- transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;
241
- cursor: pointer;
242
- color: var(--mdc-theme-on-surface);
243
- background-color: transparent;
244
- }
245
- .ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):hover {
246
- color: var(--mdc-theme-on-surface);
247
- background-color: var(--lime-elevated-surface-background-color);
248
- box-shadow: var(--button-shadow-hovered);
249
- }
250
- .ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):active {
251
- box-shadow: var(--button-shadow-pressed);
252
- transform: translate3d(0, 0.08rem, 0);
253
- }
254
- .ProseMirror-menuitem:has(.ProseMirror-menu-active) {
255
- box-shadow: var(--button-shadow-inset);
256
- color: var(--mdc-theme-primary);
257
- }
258
- .ProseMirror-menuitem:has(.ProseMirror-menu-active) svg {
259
- color: var(--mdc-theme-primary);
260
- }
261
- .ProseMirror-menuitem:has(.ProseMirror-menu-dropdown-menu) {
262
- box-shadow: var(--button-shadow-inset);
263
- }
264
- .ProseMirror-menuitem svg {
265
- fill: currentColor;
266
- height: 1rem;
267
- color: rgb(var(--contrast-1100));
76
+ .ProseMirror-menubar-wrapper {
77
+ display: grid;
78
+ grid-template-rows: auto 1fr;
268
79
  }
269
80
 
270
- .ProseMirror-menuseparator {
271
- border-radius: 1rem;
272
- background-color: rgb(var(--contrast-600));
273
- width: 0.125rem;
274
- height: 1rem;
81
+ .ProseMirror-textblock-dropdown {
82
+ min-width: 3em;
275
83
  }
276
84
 
277
- .ProseMirror-menu-dropdown {
278
- position: relative;
279
- display: flex;
280
- align-items: center;
281
- gap: 0.5rem;
282
- padding: 0 0.5rem;
283
- }
284
- .ProseMirror-menu-dropdown:after {
285
- content: "";
286
- border-left: 0.25rem solid transparent;
287
- border-right: 0.25rem solid transparent;
288
- border-top: 0.25rem solid currentColor;
85
+ .ProseMirror-tooltip .ProseMirror-menu {
86
+ width: -webkit-fit-content;
87
+ width: fit-content;
88
+ white-space: pre;
289
89
  }
290
90
 
291
- .ProseMirror-menu-dropdown-menu,
292
- .ProseMirror-menu-submenu {
293
- box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
91
+ limel-action-bar {
92
+ --action-bar-border-radius: 0.25rem;
93
+ position: sticky;
94
+ z-index: 1;
95
+ top: 1px;
96
+ background-color: rgba(var(--contrast-200), 0.5);
97
+ backdrop-filter: blur(0.5rem);
98
+ -webkit-backdrop-filter: blur(0.5rem);
99
+ margin: 0 1px;
100
+ width: calc(100% - 2px);
294
101
  }
295
102
 
296
- .ProseMirror-menu-dropdown-menu {
297
- position: absolute;
298
- top: 100%;
299
- background: rgb(var(--contrast-100));
300
- border-radius: 0.25rem;
301
- padding: 0.125rem;
103
+ .ProseMirror {
104
+ position: relative;
105
+ word-wrap: break-word;
106
+ white-space: pre-wrap;
107
+ white-space: break-spaces;
108
+ -webkit-font-variant-ligatures: none;
109
+ font-variant-ligatures: none;
110
+ font-feature-settings: "liga" 0;
111
+ padding: var(--limel-text-editor-padding);
302
112
  }
303
-
304
- .ProseMirror-menu-submenu {
305
- position: absolute;
306
- background: rgb(var(--contrast-100));
307
- border-radius: 0.25rem;
308
- padding: 0.125rem;
309
- display: none;
310
- min-width: 4em;
311
- left: 100%;
312
- top: -0.75rem;
113
+ .ProseMirror [draggable][contenteditable=false] {
114
+ user-select: text;
115
+ }
116
+ .ProseMirror:focus-visible {
117
+ outline: none;
313
118
  }
314
119
 
315
- .ProseMirror-menu-dropdown-item {
316
- transition: background-color 0.2s ease;
317
- cursor: pointer;
318
- border-radius: 0.375rem;
319
- min-height: 2.5rem;
320
- display: flex;
321
- align-items: center;
322
- width: 100%;
120
+ .ProseMirror-hideselection {
121
+ caret-color: transparent;
323
122
  }
324
- .ProseMirror-menu-dropdown-item > div {
325
- padding: 0 1rem;
326
- width: 100%;
123
+ .ProseMirror-hideselection *::selection {
124
+ background: transparent;
327
125
  }
328
- .ProseMirror-menu-dropdown-item:not(:has(.ProseMirror-menu-disabled)):hover {
329
- background-color: rgb(var(--contrast-300));
126
+ .ProseMirror-hideselection *::-moz-selection {
127
+ background: transparent;
330
128
  }
331
129
 
332
- .ProseMirror-menu-submenu-wrap {
333
- position: relative;
334
- margin-right: -0.25rem;
335
- }
336
- .ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu {
337
- display: block;
130
+ .ProseMirror-selectednode {
131
+ outline: 0.125rem solid rgb(var(--color-sky-light));
338
132
  }
339
133
 
340
- .ProseMirror-menu-submenu-label {
341
- position: relative;
342
- display: flex;
343
- align-items: center;
344
- justify-content: space-between;
345
- gap: 0.5rem;
134
+ li.ProseMirror-selectednode {
135
+ outline: none;
346
136
  }
347
- .ProseMirror-menu-submenu-label:after {
137
+ li.ProseMirror-selectednode:after {
348
138
  content: "";
349
- border-top: 0.25rem solid transparent;
350
- border-bottom: 0.25rem solid transparent;
351
- border-left: 0.25rem solid currentColor;
352
- }
353
-
354
- .ProseMirror-menu-disabled {
355
- opacity: 0.3;
356
- cursor: default;
139
+ position: absolute;
140
+ left: -2rem;
141
+ right: -0.125rem;
142
+ top: -0.125rem;
143
+ bottom: -0.125rem;
144
+ border: 0.125rem solid rgb(var(--color-sky-light));
145
+ pointer-events: none;
357
146
  }
358
147
 
359
- .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
360
- display: block;
148
+ img.ProseMirror-separator {
149
+ display: inline !important;
150
+ border: none !important;
151
+ margin: 0 !important;
361
152
  }
362
153
 
363
154
  blockquote {
@@ -18,6 +18,31 @@ import { textEditorMenuItems } from './menu/menu-items';
18
18
  */
19
19
  export class ProsemirrorAdapter {
20
20
  constructor() {
21
+ this.initializeEditor = () => {
22
+ this.actionBarItems = textEditorMenuItems;
23
+ const mySchema = new Schema({
24
+ nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
25
+ marks: schema.spec.marks,
26
+ });
27
+ this.view = new EditorView(this.host.shadowRoot.querySelector('#editor'), {
28
+ state: EditorState.create({
29
+ doc: DOMParser.fromSchema(mySchema).parse(this.host.shadowRoot.querySelector('#editor')),
30
+ plugins: exampleSetup({
31
+ schema: mySchema,
32
+ menuBar: false,
33
+ }),
34
+ }),
35
+ dispatchTransaction: (transaction) => {
36
+ const newState = this.view.state.apply(transaction);
37
+ this.view.updateState(newState);
38
+ this.change.emit(this.getHTML());
39
+ },
40
+ });
41
+ this.menuCommandFactory = new MenuCommandFactory(mySchema);
42
+ if (this.value) {
43
+ this.view.dom.innerHTML = this.value;
44
+ }
45
+ };
21
46
  this.getHTML = () => {
22
47
  if (this.view.dom.textContent === '') {
23
48
  return '';
@@ -42,33 +67,17 @@ export class ProsemirrorAdapter {
42
67
  this.view = undefined;
43
68
  this.actionBarItems = [];
44
69
  }
45
- render() {
46
- return (h("div", null, h("limel-action-bar", { accessibleLabel: "Toolbar", actions: this.actionBarItems, layout: "fullWidth", onItemSelected: this.handleActionBarItem }), h("div", { id: "editor" })));
47
- }
48
70
  componentDidLoad() {
49
- this.actionBarItems = textEditorMenuItems;
50
- const mySchema = new Schema({
51
- nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
52
- marks: schema.spec.marks,
53
- });
54
- this.view = new EditorView(this.host.shadowRoot.querySelector('#editor'), {
55
- state: EditorState.create({
56
- doc: DOMParser.fromSchema(mySchema).parse(this.host.shadowRoot.querySelector('#editor')),
57
- plugins: exampleSetup({
58
- schema: mySchema,
59
- menuBar: false,
60
- }),
61
- }),
62
- dispatchTransaction: (transaction) => {
63
- const newState = this.view.state.apply(transaction);
64
- this.view.updateState(newState);
65
- this.change.emit(this.getHTML());
66
- },
67
- });
68
- this.menuCommandFactory = new MenuCommandFactory(mySchema);
69
- if (this.value) {
70
- this.view.dom.innerHTML = this.value;
71
- }
71
+ // Stencil complains loudly about triggering rerenders in
72
+ // componentDidLoad, but we have to, so we're using setTimeout to
73
+ // suppress the warning. /Ads
74
+ setTimeout(this.initializeEditor, 0);
75
+ }
76
+ render() {
77
+ return [
78
+ h("limel-action-bar", { accessibleLabel: "Toolbar", actions: this.actionBarItems, onItemSelected: this.handleActionBarItem }),
79
+ h("div", { id: "editor" }),
80
+ ];
72
81
  }
73
82
  executeCommand(command) {
74
83
  const { state } = this.view;
@@ -1 +1 @@
1
- {"version":3,"file":"prosemirror-adapter.js","sourceRoot":"","sources":["../../../../src/components/text-editor/prosemirror-adapter/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;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;GAQG;AAMH,MAAM,OAAO,kBAAkB;;IA0EnB,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;IAEM,wBAAmB,GAAG,CAAC,KAAiC,E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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 { ActionBarItem } from 'src/components/action-bar/action-bar.types';\nimport { ListSeparator } from 'src/components/list/list-item.types';\nimport { MenuCommandFactory } from './menu/menu-commands';\nimport { textEditorMenuItems } from './menu/menu-items';\n\n/**\n * The ProseMirror adapter offers a rich text editing experience with markdown support.\n * [Read more...](https://prosemirror.net/)\n *\n * @exampleComponent limel-example-prosemirror-adapter-basic\n * @exampleComponent limel-example-prosemirror-adapter-with-custom-menu\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, expected to be serialised HTML\n */\n @Prop()\n public value: string;\n\n @Element()\n private host: HTMLLimelTextEditorElement;\n\n @State()\n private view: EditorView;\n\n @State()\n private actionBarItems: Array<ActionBarItem | ListSeparator> = [];\n\n private menuCommandFactory: MenuCommandFactory;\n\n /**\n * Dispatched when a change is made to the editor\n */\n @Event()\n private change: EventEmitter<string>;\n\n public render() {\n return (\n <div>\n <limel-action-bar\n accessibleLabel=\"Toolbar\"\n actions={this.actionBarItems}\n layout=\"fullWidth\"\n onItemSelected={this.handleActionBarItem}\n />\n <div id=\"editor\" />\n </div>\n );\n }\n\n public componentDidLoad() {\n this.actionBarItems = textEditorMenuItems;\n\n const mySchema = new Schema({\n nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),\n marks: schema.spec.marks,\n });\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 menuBar: false,\n }),\n }),\n dispatchTransaction: (transaction) => {\n const newState = this.view.state.apply(transaction);\n this.view.updateState(newState);\n\n this.change.emit(this.getHTML());\n },\n },\n );\n\n this.menuCommandFactory = new MenuCommandFactory(mySchema);\n\n if (this.value) {\n this.view.dom.innerHTML = this.value;\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 private handleActionBarItem = (event: CustomEvent<ActionBarItem>) => {\n event.preventDefault();\n\n const { text } = event.detail;\n const mark = text.replace(/\\s/g, '').toLowerCase();\n try {\n const command = this.menuCommandFactory.createCommand(mark);\n this.executeCommand(command);\n } catch (error) {\n throw new Error(`Error executing command: ${error}`);\n }\n };\n\n private executeCommand(command) {\n const { state } = this.view;\n const selection = state.selection;\n\n let transaction = state.tr;\n\n if (!selection.empty) {\n transaction.setSelection(selection);\n }\n\n command(state, (tr) => {\n transaction = tr;\n });\n this.view.dispatch(transaction);\n\n this.view.focus();\n }\n}\n"]}
1
+ {"version":3,"file":"prosemirror-adapter.js","sourceRoot":"","sources":["../../../../src/components/text-editor/prosemirror-adapter/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;AAGzD,OAAO,EAAE,kBAAk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AAC,IAAI,CAAC;IAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAElC,IAAI,WAAW,GAAG,KAAK,CAAC,EAAE,CAAC;IAE3B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;MAClB,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;KACvC;IAED,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE;MAClB,WAAW,GAAG,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEhC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;EACtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","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 { ActionBarItem } from 'src/components/action-bar/action-bar.types';\nimport { ListSeparator } from 'src/components/list/list-item.types';\nimport { MenuCommandFactory } from './menu/menu-commands';\nimport { textEditorMenuItems } from './menu/menu-items';\n\n/**\n * The ProseMirror adapter offers a rich text editing experience with markdown support.\n * [Read more...](https://prosemirror.net/)\n *\n * @exampleComponent limel-example-prosemirror-adapter-basic\n * @exampleComponent limel-example-prosemirror-adapter-with-custom-menu\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, expected to be serialised HTML\n */\n @Prop()\n public value: string;\n\n @Element()\n private host: HTMLLimelTextEditorElement;\n\n @State()\n private view: EditorView;\n\n @State()\n private actionBarItems: Array<ActionBarItem | ListSeparator> = [];\n\n private menuCommandFactory: MenuCommandFactory;\n\n /**\n * Dispatched when a change is made to the editor\n */\n @Event()\n private change: EventEmitter<string>;\n\n public componentDidLoad() {\n // Stencil complains loudly about triggering rerenders in\n // componentDidLoad, but we have to, so we're using setTimeout to\n // suppress the warning. /Ads\n setTimeout(this.initializeEditor, 0);\n }\n\n public render() {\n return [\n <limel-action-bar\n accessibleLabel=\"Toolbar\"\n actions={this.actionBarItems}\n onItemSelected={this.handleActionBarItem}\n />,\n <div id=\"editor\" />,\n ];\n }\n\n private initializeEditor = () => {\n this.actionBarItems = textEditorMenuItems;\n\n const mySchema = new Schema({\n nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),\n marks: schema.spec.marks,\n });\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 menuBar: false,\n }),\n }),\n dispatchTransaction: (transaction) => {\n const newState = this.view.state.apply(transaction);\n this.view.updateState(newState);\n\n this.change.emit(this.getHTML());\n },\n },\n );\n\n this.menuCommandFactory = new MenuCommandFactory(mySchema);\n\n if (this.value) {\n this.view.dom.innerHTML = this.value;\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 private handleActionBarItem = (event: CustomEvent<ActionBarItem>) => {\n event.preventDefault();\n\n const { text } = event.detail;\n const mark = text.replace(/\\s/g, '').toLowerCase();\n try {\n const command = this.menuCommandFactory.createCommand(mark);\n this.executeCommand(command);\n } catch (error) {\n throw new Error(`Error executing command: ${error}`);\n }\n };\n\n private executeCommand(command) {\n const { state } = this.view;\n const selection = state.selection;\n\n let transaction = state.tr;\n\n if (!selection.empty) {\n transaction.setSelection(selection);\n }\n\n command(state, (tr) => {\n transaction = tr;\n });\n this.view.dispatch(transaction);\n\n this.view.focus();\n }\n}\n"]}