@eclipse-docks/extension-md-editor 0.7.125 → 0.7.126
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/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ extensionRegistry.registerExtension({
|
|
|
9
9
|
id: pkg.name,
|
|
10
10
|
name: t.EXT_MDEDITOR_NAME,
|
|
11
11
|
description: t.EXT_MDEDITOR_DESC,
|
|
12
|
-
loader: () => import("./md-editor-extension-
|
|
12
|
+
loader: () => import("./md-editor-extension-Djr2cuH1.js"),
|
|
13
13
|
icon: "book"
|
|
14
14
|
});
|
|
15
15
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DocksPart, File, editorRegistry } from "@eclipse-docks/core";
|
|
1
|
+
import { DocksPart, File, editorRegistry, parseMarkdownHtml } from "@eclipse-docks/core";
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import { html } from "lit";
|
|
4
|
-
import { marked } from "marked";
|
|
5
4
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
6
5
|
import _decorate from "@oxc-project/runtime/helpers/decorate";
|
|
7
6
|
//#region src/md-editor-extension.ts
|
|
@@ -47,7 +46,7 @@ var DocksMDEditor = class DocksMDEditor extends DocksPart {
|
|
|
47
46
|
<div style="padding: 10px;">${unsafeHTML(this.mdContents)}</div>`;
|
|
48
47
|
}
|
|
49
48
|
updateContents(text) {
|
|
50
|
-
this.mdContents =
|
|
49
|
+
this.mdContents = parseMarkdownHtml(text);
|
|
51
50
|
}
|
|
52
51
|
};
|
|
53
52
|
_decorate([property({ attribute: false })], DocksMDEditor.prototype, "input", void 0);
|
|
@@ -56,4 +55,4 @@ DocksMDEditor = _decorate([customElement("docks-md-editor")], DocksMDEditor);
|
|
|
56
55
|
//#endregion
|
|
57
56
|
export { DocksMDEditor };
|
|
58
57
|
|
|
59
|
-
//# sourceMappingURL=md-editor-extension-
|
|
58
|
+
//# sourceMappingURL=md-editor-extension-Djr2cuH1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-editor-extension-Djr2cuH1.js","names":[],"sources":["../src/md-editor-extension.ts"],"sourcesContent":["import {customElement, property, state} from \"lit/decorators.js\";\nimport {DocksPart, parseMarkdownHtml} from \"@eclipse-docks/core\";\nimport {html} from \"lit\";\nimport {EditorInput, editorRegistry} from \"@eclipse-docks/core\";\nimport {unsafeHTML} from \"lit/directives/unsafe-html.js\";\nimport {File} from \"@eclipse-docks/core\";\n\neditorRegistry.registerEditorInputHandler({\n editorId: \"system.md-editor\",\n label: \"Markdown\",\n icon: \"book\",\n canHandle: input => input instanceof File && input.getName().toLowerCase().endsWith(\".md\"),\n handle: async (input: File) => {\n const editorInput = {\n title: input.getWorkspacePath(),\n data: input,\n key: input.getWorkspacePath(),\n icon: \"book\",\n state: {},\n } as EditorInput\n editorInput.component = (id: string) => html`\n <docks-md-editor id=\"${id}\" .input=${editorInput}></docks-md-editor>`\n return editorInput;\n },\n ranking: 1000\n})\n\n@customElement('docks-md-editor')\nexport class DocksMDEditor extends DocksPart {\n @property({attribute: false})\n public input?: EditorInput\n @state()\n private mdContents?: string\n\n protected doClose() {\n this.input = undefined\n this.mdContents = undefined\n }\n\n protected doBeforeUI() {\n // Start loading content asynchronously\n this.loadContent();\n }\n\n private async loadContent() {\n const data = this.input!.data\n \n if (data instanceof File) {\n const contents = await data.getContents()\n this.updateContents(contents)\n } else if (typeof data === 'string' && data.startsWith(\"http\")) {\n const response = await fetch(data)\n const text = await response.text()\n this.updateContents(text)\n } else if (typeof data === 'string') {\n this.updateContents(data)\n }\n }\n\n protected renderContent() {\n return html`\n <div style=\"padding: 10px;\">${unsafeHTML(this.mdContents)}</div>`\n }\n\n private updateContents(text: string) {\n this.mdContents = parseMarkdownHtml(text)\n }\n}\n"],"mappings":";;;;;;AAOA,eAAe,2BAA2B;CACtC,UAAU;CACV,OAAO;CACP,MAAM;CACN,YAAW,UAAS,iBAAiB,QAAQ,MAAM,SAAS,CAAC,aAAa,CAAC,SAAS,MAAM;CAC1F,QAAQ,OAAO,UAAgB;EAC3B,MAAM,cAAc;GAChB,OAAO,MAAM,kBAAkB;GAC/B,MAAM;GACN,KAAK,MAAM,kBAAkB;GAC7B,MAAM;GACN,OAAO,EAAE;GACZ;AACD,cAAY,aAAa,OAAe,IAAI;mCACjB,GAAG,WAAW,YAAY;AACrD,SAAO;;CAEX,SAAS;CACZ,CAAC;AAGK,IAAA,gBAAA,MAAM,sBAAsB,UAAU;CAMzC,UAAoB;AAChB,OAAK,QAAQ,KAAA;AACb,OAAK,aAAa,KAAA;;CAGtB,aAAuB;AAEnB,OAAK,aAAa;;CAGtB,MAAc,cAAc;EACxB,MAAM,OAAO,KAAK,MAAO;AAEzB,MAAI,gBAAgB,MAAM;GACtB,MAAM,WAAW,MAAM,KAAK,aAAa;AACzC,QAAK,eAAe,SAAS;aACtB,OAAO,SAAS,YAAY,KAAK,WAAW,OAAO,EAAE;GAE5D,MAAM,OAAO,OADI,MAAM,MAAM,KAAK,EACN,MAAM;AAClC,QAAK,eAAe,KAAK;aAClB,OAAO,SAAS,SACvB,MAAK,eAAe,KAAK;;CAIjC,gBAA0B;AACtB,SAAO,IAAI;0CACuB,WAAW,KAAK,WAAW,CAAC;;CAGlE,eAAuB,MAAc;AACjC,OAAK,aAAa,kBAAkB,KAAK;;;WApC5C,SAAS,EAAC,WAAW,OAAM,CAAC,CAAA,EAAA,cAAA,WAAA,SAAA,KAAA,EAAA;WAE5B,OAAO,CAAA,EAAA,cAAA,WAAA,cAAA,KAAA,EAAA;2BAJX,cAAc,kBAAkB,CAAA,EAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-editor-extension.d.ts","sourceRoot":"","sources":["../src/md-editor-extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"md-editor-extension.d.ts","sourceRoot":"","sources":["../src/md-editor-extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAC,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AAwBhE,qBACa,aAAc,SAAQ,SAAS;IAEjC,KAAK,CAAC,EAAE,WAAW,CAAA;IAE1B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAE3B,SAAS,CAAC,OAAO;IAKjB,SAAS,CAAC,UAAU;YAKN,WAAW;IAezB,SAAS,CAAC,aAAa;IAKvB,OAAO,CAAC,cAAc;CAGzB"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"md-editor-extension-8oqW93mK.js","names":[],"sources":["../src/md-editor-extension.ts"],"sourcesContent":["import {customElement, property, state} from \"lit/decorators.js\";\nimport {DocksPart} from \"@eclipse-docks/core\";\nimport {html} from \"lit\";\nimport {marked} from \"marked\";\nimport {EditorInput, editorRegistry} from \"@eclipse-docks/core\";\nimport {unsafeHTML} from \"lit/directives/unsafe-html.js\";\nimport {File} from \"@eclipse-docks/core\";\n\neditorRegistry.registerEditorInputHandler({\n editorId: \"system.md-editor\",\n label: \"Markdown\",\n icon: \"book\",\n canHandle: input => input instanceof File && input.getName().toLowerCase().endsWith(\".md\"),\n handle: async (input: File) => {\n const editorInput = {\n title: input.getWorkspacePath(),\n data: input,\n key: input.getWorkspacePath(),\n icon: \"book\",\n state: {},\n } as EditorInput\n editorInput.component = (id: string) => html`\n <docks-md-editor id=\"${id}\" .input=${editorInput}></docks-md-editor>`\n return editorInput;\n },\n ranking: 1000\n})\n\n@customElement('docks-md-editor')\nexport class DocksMDEditor extends DocksPart {\n @property({attribute: false})\n public input?: EditorInput\n @state()\n private mdContents?: string\n\n protected doClose() {\n this.input = undefined\n this.mdContents = undefined\n }\n\n protected doBeforeUI() {\n // Start loading content asynchronously\n this.loadContent();\n }\n\n private async loadContent() {\n const data = this.input!.data\n \n if (data instanceof File) {\n const contents = await data.getContents()\n this.updateContents(contents)\n } else if (typeof data === 'string' && data.startsWith(\"http\")) {\n const response = await fetch(data)\n const text = await response.text()\n this.updateContents(text)\n } else if (typeof data === 'string') {\n this.updateContents(data)\n }\n }\n\n protected renderContent() {\n return html`\n <div style=\"padding: 10px;\">${unsafeHTML(this.mdContents)}</div>`\n }\n\n private updateContents(text: string) {\n this.mdContents = marked.parse(text) as string\n }\n}\n"],"mappings":";;;;;;;AAQA,eAAe,2BAA2B;CACtC,UAAU;CACV,OAAO;CACP,MAAM;CACN,YAAW,UAAS,iBAAiB,QAAQ,MAAM,SAAS,CAAC,aAAa,CAAC,SAAS,MAAM;CAC1F,QAAQ,OAAO,UAAgB;EAC3B,MAAM,cAAc;GAChB,OAAO,MAAM,kBAAkB;GAC/B,MAAM;GACN,KAAK,MAAM,kBAAkB;GAC7B,MAAM;GACN,OAAO,EAAE;GACZ;AACD,cAAY,aAAa,OAAe,IAAI;mCACjB,GAAG,WAAW,YAAY;AACrD,SAAO;;CAEX,SAAS;CACZ,CAAC;AAGK,IAAA,gBAAA,MAAM,sBAAsB,UAAU;CAMzC,UAAoB;AAChB,OAAK,QAAQ,KAAA;AACb,OAAK,aAAa,KAAA;;CAGtB,aAAuB;AAEnB,OAAK,aAAa;;CAGtB,MAAc,cAAc;EACxB,MAAM,OAAO,KAAK,MAAO;AAEzB,MAAI,gBAAgB,MAAM;GACtB,MAAM,WAAW,MAAM,KAAK,aAAa;AACzC,QAAK,eAAe,SAAS;aACtB,OAAO,SAAS,YAAY,KAAK,WAAW,OAAO,EAAE;GAE5D,MAAM,OAAO,OADI,MAAM,MAAM,KAAK,EACN,MAAM;AAClC,QAAK,eAAe,KAAK;aAClB,OAAO,SAAS,SACvB,MAAK,eAAe,KAAK;;CAIjC,gBAA0B;AACtB,SAAO,IAAI;0CACuB,WAAW,KAAK,WAAW,CAAC;;CAGlE,eAAuB,MAAc;AACjC,OAAK,aAAa,OAAO,MAAM,KAAK;;;WApCvC,SAAS,EAAC,WAAW,OAAM,CAAC,CAAA,EAAA,cAAA,WAAA,SAAA,KAAA,EAAA;WAE5B,OAAO,CAAA,EAAA,cAAA,WAAA,cAAA,KAAA,EAAA;2BAJX,cAAc,kBAAkB,CAAA,EAAA,cAAA"}
|