@omegagrid/markdown 0.10.66 → 0.10.68
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.
|
@@ -15,6 +15,7 @@ export declare class MarkdownEditor extends LitElement implements Layout {
|
|
|
15
15
|
maxContentWidth: number;
|
|
16
16
|
contentAlignment: HorizontalPosition;
|
|
17
17
|
readOnly: boolean;
|
|
18
|
+
spellcheck: boolean;
|
|
18
19
|
container: HTMLDivElement;
|
|
19
20
|
slider: Slider;
|
|
20
21
|
onUpload: (file: File) => Promise<string>;
|
|
@@ -27,7 +28,7 @@ export declare class MarkdownEditor extends LitElement implements Layout {
|
|
|
27
28
|
updateWidth(): void;
|
|
28
29
|
_onChange: (markdown: string, prevMarkdown: string) => void;
|
|
29
30
|
firstUpdated(): void;
|
|
30
|
-
updated(): Promise<void>;
|
|
31
|
+
updated(changed: Map<PropertyKey, unknown>): Promise<void>;
|
|
31
32
|
updateSlider(): void;
|
|
32
33
|
disconnectedCallback(): void;
|
|
33
34
|
render: () => import("lit").TemplateResult<1>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownEditor.d.ts","sourceRoot":"","sources":["../../src/components/markdownEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,KAAK,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAEzD,qBAAa,iBAAkB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;gBAErB,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC;CAI5C;AAED,qBACa,cAAe,SAAQ,UAAW,YAAW,MAAM;;IAE/D,M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CADe;IACtC,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,EAKtB;IAGD,eAAe,SAAO;IAGtB,gBAAgB,EAAE,kBAAkB,CAAU;IAG9C,QAAQ,UAAS;IAGjB,UAAU,UAAS;IAGnB,SAAS,EAAE,cAAc,CAAC;IAG1B,MAAM,EAAE,MAAM,CAAC;IAKf,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAG1C,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAC,MAAM,CAAC;IAIzD,IAAI,WAAW,IAAiD,WAAW,CAAE;IAC7E,IAAI,MAAM,yBAA0B;;IAwBpC,gBAAgB,CAAC,QAAQ,EAAE,MAAM;IAOjC,iBAAiB;IAKjB,WAAW;IAKX,SAAS,GAAI,UAAU,MAAM,EAAE,cAAc,MAAM,UAGlD;IAED,YAAY;IAkBN,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC;IAqBhD,YAAY;IAUZ,oBAAoB;IAOpB,MAAM,wCAMJ;IAEF,MAAM;CAEN"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var _MarkdownEditor_content,_MarkdownEditor_mouseIn,_MarkdownEditor_editor,__decorate=this&&this.__decorate||function(t,e,r,o){var i,d=arguments.length,n=d<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,r,o);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(n=(d<3?i(n):d>3?i(e,r,n):i(e,r))||n);return d>3&&n&&Object.defineProperty(e,r,n),n},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(t,e,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(t):o?o.value:e.get(t)},__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(t,e,r,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,r):i?i.value=r:e.set(t,r),r};import{dom,events}from"@omegagrid/core";import{LitElement,html}from"lit";import{customElement,query,property}from"lit/decorators.js";import{style}from"./markdownEditor.style";import styles from"./styles";import{createEditor}from"../utils";export class MarkdownLinkEvent extends Event{constructor(t){super("markdown.link",{bubbles:!0,composed:!0,cancelable:!0}),Object.assign(this,t)}}let MarkdownEditor=class extends LitElement{get content(){return __classPrivateFieldGet(this,_MarkdownEditor_content,"f")}set content(t){__classPrivateFieldSet(this,_MarkdownEditor_content,t,"f"),__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")?.destroy(),__classPrivateFieldSet(this,_MarkdownEditor_editor,null,"f"),this.requestUpdate()}get milkdownElm(){return this.container.firstElementChild}get editor(){return __classPrivateFieldGet(this,_MarkdownEditor_editor,"f")}constructor(){super(),_MarkdownEditor_content.set(this,void 0),this.maxContentWidth=800,this.contentAlignment="left",this.readOnly=!1,_MarkdownEditor_mouseIn.set(this,!1),_MarkdownEditor_editor.set(this,void 0),this._onChange=(t,e)=>{__classPrivateFieldSet(this,_MarkdownEditor_content,t,"f"),this.dispatchEvent(new events.ChangeEvent({value:t,oldValue:e}))},this.render=()=>html`
|
|
1
|
+
var _MarkdownEditor_instances,_MarkdownEditor_content,_MarkdownEditor_mouseIn,_MarkdownEditor_editor,_MarkdownEditor_applySpellcheck,__decorate=this&&this.__decorate||function(t,e,r,o){var i,d=arguments.length,n=d<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,r,o);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(n=(d<3?i(n):d>3?i(e,r,n):i(e,r))||n);return d>3&&n&&Object.defineProperty(e,r,n),n},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(t,e,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(t):o?o.value:e.get(t)},__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(t,e,r,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,r):i?i.value=r:e.set(t,r),r};import{dom,events}from"@omegagrid/core";import{LitElement,html}from"lit";import{customElement,query,property}from"lit/decorators.js";import{style}from"./markdownEditor.style";import styles from"./styles";import{createEditor}from"../utils";export class MarkdownLinkEvent extends Event{constructor(t){super("markdown.link",{bubbles:!0,composed:!0,cancelable:!0}),Object.assign(this,t)}}let MarkdownEditor=class extends LitElement{get content(){return __classPrivateFieldGet(this,_MarkdownEditor_content,"f")}set content(t){__classPrivateFieldSet(this,_MarkdownEditor_content,t,"f"),__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")?.destroy(),__classPrivateFieldSet(this,_MarkdownEditor_editor,null,"f"),this.requestUpdate()}get milkdownElm(){return this.container.firstElementChild}get editor(){return __classPrivateFieldGet(this,_MarkdownEditor_editor,"f")}constructor(){super(),_MarkdownEditor_instances.add(this),_MarkdownEditor_content.set(this,void 0),this.maxContentWidth=800,this.contentAlignment="left",this.readOnly=!1,this.spellcheck=!1,_MarkdownEditor_mouseIn.set(this,!1),_MarkdownEditor_editor.set(this,void 0),this._onChange=(t,e)=>{__classPrivateFieldSet(this,_MarkdownEditor_content,t,"f"),this.dispatchEvent(new events.ChangeEvent({value:t,oldValue:e}))},this.render=()=>html`
|
|
2
2
|
<style>
|
|
3
3
|
.ProseMirror.editor { max-width: ${this.maxContentWidth}px; }
|
|
4
4
|
</style>
|
|
5
|
-
<div id="container" spellcheck="
|
|
5
|
+
<div id="container" spellcheck="${this.spellcheck}"></div>
|
|
6
6
|
<og-slider direction="vertical" hidden></og-slider>
|
|
7
|
-
`,dom.on(this,"click","a",((t,e)=>{if(!this.dispatchEvent(new MarkdownLinkEvent({href:e.getAttribute("href"),a:e,origEvent:t})))return void t.preventDefault();const r=e.getAttribute("href");r&&r.startsWith("#")&&(t.preventDefault(),this.scrollToSelector(r))}))}scrollToSelector(t){const e=this.milkdownElm.querySelector(t);e&&(this.milkdownElm.scrollTop=e.offsetTop,this.slider.updatePosition())}connectedCallback(){super.connectedCallback(),this.requestUpdate()}updateWidth(){const t=Math.min(this.maxContentWidth,this.clientWidth);this.milkdownElm.style.width=`${t}px`}firstUpdated(){this.slider.hide(),this.addEventListener("mouseenter",(()=>{__classPrivateFieldSet(this,_MarkdownEditor_mouseIn,!0,"f"),this.updateSlider()})),this.addEventListener("mouseleave",(()=>{__classPrivateFieldSet(this,_MarkdownEditor_mouseIn,!1,"f"),this.updateSlider()})),this.slider.addEventListener("slideEnd",(()=>{this.updateSlider()}))}async updated(){__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")||(__classPrivateFieldSet(this,_MarkdownEditor_editor,await createEditor({container:this.container,content:this.content,readOnly:this.readOnly,onUpload:this.onUpload,onChange:this._onChange,modifyImageUrl:this.modifyImageUrl}),"f"),this.slider.attachElement(this.milkdownElm))}updateSlider(){this.slider&&this.milkdownElm&&(this.milkdownElm.scrollHeight>this.milkdownElm.clientHeight&&(__classPrivateFieldGet(this,_MarkdownEditor_mouseIn,"f")||this.slider.sliding)?this.slider.show():this.slider.hide())}disconnectedCallback(){super.disconnectedCallback(),__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")?.destroy(),__classPrivateFieldSet(this,_MarkdownEditor_editor,null,"f"),dom.empty(this.container)}layout(){}};_MarkdownEditor_content=new WeakMap,_MarkdownEditor_mouseIn=new WeakMap,_MarkdownEditor_editor=new WeakMap,MarkdownEditor.styles=[style,...styles],__decorate([property({type:String})],MarkdownEditor.prototype,"content",null),__decorate([property({type:Number})],MarkdownEditor.prototype,"maxContentWidth",void 0),__decorate([property({type:String,reflect:!0})],MarkdownEditor.prototype,"contentAlignment",void 0),__decorate([property({type:Boolean,reflect:!0})],MarkdownEditor.prototype,"readOnly",void 0),__decorate([query("#container")],MarkdownEditor.prototype,"container",void 0),__decorate([query("og-slider")],MarkdownEditor.prototype,"slider",void 0),__decorate([property({type:Object})],MarkdownEditor.prototype,"onUpload",void 0),__decorate([property({type:Object})],MarkdownEditor.prototype,"modifyImageUrl",void 0),MarkdownEditor=__decorate([customElement("og-markdown-editor")],MarkdownEditor);export{MarkdownEditor};
|
|
7
|
+
`,dom.on(this,"click","a",((t,e)=>{if(!this.dispatchEvent(new MarkdownLinkEvent({href:e.getAttribute("href"),a:e,origEvent:t})))return void t.preventDefault();const r=e.getAttribute("href");r&&r.startsWith("#")&&(t.preventDefault(),this.scrollToSelector(r))}))}scrollToSelector(t){const e=this.milkdownElm.querySelector(t);e&&(this.milkdownElm.scrollTop=e.offsetTop,this.slider.updatePosition())}connectedCallback(){super.connectedCallback(),this.requestUpdate()}updateWidth(){const t=Math.min(this.maxContentWidth,this.clientWidth);this.milkdownElm.style.width=`${t}px`}firstUpdated(){this.slider.hide(),this.addEventListener("mouseenter",(()=>{__classPrivateFieldSet(this,_MarkdownEditor_mouseIn,!0,"f"),this.updateSlider()})),this.addEventListener("mouseleave",(()=>{__classPrivateFieldSet(this,_MarkdownEditor_mouseIn,!1,"f"),this.updateSlider()})),this.slider.addEventListener("slideEnd",(()=>{this.updateSlider()}))}async updated(t){t.has("spellcheck")&&__classPrivateFieldGet(this,_MarkdownEditor_instances,"m",_MarkdownEditor_applySpellcheck).call(this),__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")||(__classPrivateFieldSet(this,_MarkdownEditor_editor,await createEditor({container:this.container,content:this.content,readOnly:this.readOnly,onUpload:this.onUpload,onChange:this._onChange,modifyImageUrl:this.modifyImageUrl}),"f"),__classPrivateFieldGet(this,_MarkdownEditor_instances,"m",_MarkdownEditor_applySpellcheck).call(this),this.slider.attachElement(this.milkdownElm))}updateSlider(){this.slider&&this.milkdownElm&&(this.milkdownElm.scrollHeight>this.milkdownElm.clientHeight&&(__classPrivateFieldGet(this,_MarkdownEditor_mouseIn,"f")||this.slider.sliding)?this.slider.show():this.slider.hide())}disconnectedCallback(){super.disconnectedCallback(),__classPrivateFieldGet(this,_MarkdownEditor_editor,"f")?.destroy(),__classPrivateFieldSet(this,_MarkdownEditor_editor,null,"f"),dom.empty(this.container)}layout(){}};_MarkdownEditor_content=new WeakMap,_MarkdownEditor_mouseIn=new WeakMap,_MarkdownEditor_editor=new WeakMap,_MarkdownEditor_instances=new WeakSet,_MarkdownEditor_applySpellcheck=function(){this.milkdownElm?.setAttribute("spellcheck",String(this.spellcheck))},MarkdownEditor.styles=[style,...styles],__decorate([property({type:String})],MarkdownEditor.prototype,"content",null),__decorate([property({type:Number})],MarkdownEditor.prototype,"maxContentWidth",void 0),__decorate([property({type:String,reflect:!0})],MarkdownEditor.prototype,"contentAlignment",void 0),__decorate([property({type:Boolean,reflect:!0})],MarkdownEditor.prototype,"readOnly",void 0),__decorate([property({type:Boolean})],MarkdownEditor.prototype,"spellcheck",void 0),__decorate([query("#container")],MarkdownEditor.prototype,"container",void 0),__decorate([query("og-slider")],MarkdownEditor.prototype,"slider",void 0),__decorate([property({type:Object})],MarkdownEditor.prototype,"onUpload",void 0),__decorate([property({type:Object})],MarkdownEditor.prototype,"modifyImageUrl",void 0),MarkdownEditor=__decorate([customElement("og-markdown-editor")],MarkdownEditor);export{MarkdownEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownEditor.js","sourceRoot":"","sources":["../../src/components/markdownEditor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,GA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,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;wDACM;AAG9C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;gDACxB;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;kDACP;AAGnB;IADC,KAAK,CAAC,YAAY,CAAC;iDACM;AAG1B;IADC,KAAK,CAAC,WAAW,CAAC;8CACJ;AAKf;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;gDACiB;AAG1C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sDACgC;AAtC7C,cAAc;IAD1B,aAAa,CAAC,oBAAoB,CAAC;GACvB,cAAc,CA2J1B","sourcesContent":["import { dom, events, HorizontalPosition, Layout, Slider } from '@omegagrid/core';\nimport { LitElement, html } from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { style } from './markdownEditor.style';\nimport styles from './styles';\nimport { createEditor } from '../utils';\nimport type * as milkdown from '@omegagrid/milkdown-kit';\n\nexport class MarkdownLinkEvent extends Event {\n\treadonly href: string;\n\treadonly a: HTMLAnchorElement;\n\treadonly origEvent: PointerEvent;\n\n\tconstructor(args: Partial<MarkdownLinkEvent>) {\n\t\tsuper(`markdown.link`, {bubbles: true, composed: true, cancelable: true});\n\t\tObject.assign(this, args);\n\t}\n}\n\n@customElement('og-markdown-editor')\nexport class MarkdownEditor extends LitElement implements Layout {\n\n\tstatic styles = [style, ...styles];\n\n\t#content: string\n\t@property({type: String})\n\tget content() { return this.#content }\n\tset content(val: string) {\n\t\tthis.#content = val;\n\t\tthis.#editor?.destroy();\n\t\tthis.#editor = null;\n\t\tthis.requestUpdate();\n\t}\n\n\t@property({type: Number})\n\tmaxContentWidth = 800;\n\n\t@property({type: String, reflect: true})\n\tcontentAlignment: HorizontalPosition = 'left';\n\n\t@property({type: Boolean, reflect: true})\n\treadOnly = false;\n\n\t@property({type: Boolean})\n\tspellcheck = false;\n\n\t@query('#container')\n\tcontainer: HTMLDivElement;\n\n\t@query('og-slider')\n\tslider: Slider;\n\n\t#mouseIn = false;\n\n\t@property({type: Object})\n\tonUpload: (file: File) => Promise<string>;\n\n\t@property({type: Object})\n\tmodifyImageUrl: (file: string) => Promise<string>|string;\n\n\t#editor: milkdown.core.Editor;\n\n\tget milkdownElm () { return this.container.firstElementChild as HTMLElement }\n\tget editor() { return this.#editor }\n\n\tconstructor() {\n\t\tsuper();\n\t\tdom.on(this, 'click', 'a', (e: PointerEvent, a) => {\n\t\t\tconst canceled = !this.dispatchEvent(new MarkdownLinkEvent({\n\t\t\t\thref: a.getAttribute('href'), \n\t\t\t\ta: a as HTMLAnchorElement,\n\t\t\t\torigEvent: e\n\t\t\t}));\n\n\t\t\tif (canceled) {\n\t\t\t\te.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst href = a.getAttribute('href');\n\t\t\tif (href && href.startsWith('#')) {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.scrollToSelector(href);\n\t\t\t}\n\t\t});\n\t}\n\n\tscrollToSelector(selector: string) {\n\t\tconst elm = this.milkdownElm.querySelector(selector) as HTMLElement;\n\t\tif (!elm) return;\n\t\tthis.milkdownElm.scrollTop = elm.offsetTop;\n\t\tthis.slider.updatePosition();\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.requestUpdate();\n\t}\n\n\tupdateWidth() {\n\t\tconst width = Math.min(this.maxContentWidth, this.clientWidth);\n\t\tthis.milkdownElm.style.width = `${width}px`;\n\t}\n\n\t_onChange = (markdown: string, prevMarkdown: string) => {\n\t\tthis.#content = markdown;\n\t\tthis.dispatchEvent(new events.ChangeEvent({value: markdown, oldValue: prevMarkdown}));\n\t}\n\n\tfirstUpdated() {\n\t\tthis.slider.hide();\n\n\t\tthis.addEventListener('mouseenter', () => {\n\t\t\tthis.#mouseIn = true;\n\t\t\tthis.updateSlider();\n\t\t});\n\n\t\tthis.addEventListener('mouseleave', () => {\n\t\t\tthis.#mouseIn = false;\n\t\t\tthis.updateSlider();\n\t\t});\n\n\t\tthis.slider.addEventListener('slideEnd', () => {\n\t\t\tthis.updateSlider();\n\t\t});\n\t}\n\n\tasync updated(changed: Map<PropertyKey, unknown>) {\n\t\tif (changed.has('spellcheck')) this.#applySpellcheck();\n\t\tif (this.#editor) return;\n\t\tthis.#editor = await createEditor({\n\t\t\tcontainer: this.container,\n\t\t\tcontent: this.content,\n\t\t\treadOnly: this.readOnly,\n\t\t\tonUpload: this.onUpload,\n\t\t\tonChange: this._onChange,\n\t\t\tmodifyImageUrl: this.modifyImageUrl\n\t\t});\n\t\tthis.#applySpellcheck();\n\t\tthis.slider.attachElement(this.milkdownElm);\n\t}\n\n\t// The browser only re-checks spelling on the element it edits, so set the\n\t// attribute on the ProseMirror editable itself (not just the container).\n\t#applySpellcheck() {\n\t\tthis.milkdownElm?.setAttribute('spellcheck', String(this.spellcheck));\n\t}\n\n\tupdateSlider() {\n\t\tif (!this.slider || !this.milkdownElm) return;\n\t\tconst needsScroll = this.milkdownElm.scrollHeight > this.milkdownElm.clientHeight;\n\t\tif (needsScroll && (this.#mouseIn || this.slider.sliding)) {\n\t\t\tthis.slider.show();\n\t\t} else {\n\t\t\tthis.slider.hide();\n\t\t}\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback();\n\t\tthis.#editor?.destroy();\n\t\tthis.#editor = null;\n\t\tdom.empty(this.container);\n\t}\n\n\trender = () => html`\n\t\t<style>\n\t\t\t.ProseMirror.editor { max-width: ${this.maxContentWidth}px; }\n\t\t</style>\n\t\t<div id=\"container\" spellcheck=\"${this.spellcheck}\"></div>\n\t\t<og-slider direction=\"vertical\" hidden></og-slider>\n\t`;\n\n\tlayout() { }\n\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/markdown",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.68",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Markdown view webcomponent",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fortawesome/fontawesome-svg-core": "^7.0.1",
|
|
31
|
-
"@omegagrid/code": "^0.10.
|
|
32
|
-
"@omegagrid/core": "^0.10.
|
|
33
|
-
"@omegagrid/localize": "^0.10.
|
|
34
|
-
"@omegagrid/milkdown-kit": "^0.10.
|
|
35
|
-
"@omegagrid/tabs": "^0.10.
|
|
31
|
+
"@omegagrid/code": "^0.10.68",
|
|
32
|
+
"@omegagrid/core": "^0.10.68",
|
|
33
|
+
"@omegagrid/localize": "^0.10.68",
|
|
34
|
+
"@omegagrid/milkdown-kit": "^0.10.68",
|
|
35
|
+
"@omegagrid/tabs": "^0.10.68",
|
|
36
36
|
"lit": "^3.1.1",
|
|
37
37
|
"markdown-it": "^14.1.0",
|
|
38
38
|
"ts-debounce": "^4.0.0"
|