@eclipse-docks/extension-md-editor 0.7.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.
- package/dist/i18n.de-B-XSgGEO.js +11 -0
- package/dist/i18n.de-B-XSgGEO.js.map +1 -0
- package/dist/i18n.en-C1spZCa1.js +11 -0
- package/dist/i18n.en-C1spZCa1.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/md-editor-extension-8oqW93mK.js +59 -0
- package/dist/md-editor-extension-8oqW93mK.js.map +1 -0
- package/dist/md-editor-extension.d.ts +11 -0
- package/dist/md-editor-extension.d.ts.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/i18n.de.json
|
|
2
|
+
var EXT_MDEDITOR_NAME = "Markdown-Editor";
|
|
3
|
+
var EXT_MDEDITOR_DESC = "Anzeigen und Rendern von Markdown (.md) Dateien";
|
|
4
|
+
var i18n_de_default = {
|
|
5
|
+
EXT_MDEDITOR_NAME,
|
|
6
|
+
EXT_MDEDITOR_DESC
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EXT_MDEDITOR_DESC, EXT_MDEDITOR_NAME, i18n_de_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=i18n.de-B-XSgGEO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.de-B-XSgGEO.js","names":[],"sources":["../src/i18n.de.json"],"sourcesContent":["{\n \"EXT_MDEDITOR_NAME\": \"Markdown-Editor\",\n \"EXT_MDEDITOR_DESC\": \"Anzeigen und Rendern von Markdown (.md) Dateien\"\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/i18n.en.json
|
|
2
|
+
var EXT_MDEDITOR_NAME = "Markdown Editor";
|
|
3
|
+
var EXT_MDEDITOR_DESC = "View and render Markdown (.md) files";
|
|
4
|
+
var i18n_en_default = {
|
|
5
|
+
EXT_MDEDITOR_NAME,
|
|
6
|
+
EXT_MDEDITOR_DESC
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EXT_MDEDITOR_DESC, EXT_MDEDITOR_NAME, i18n_en_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=i18n.en-C1spZCa1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.en-C1spZCa1.js","names":[],"sources":["../src/i18n.en.json"],"sourcesContent":["{\n \"EXT_MDEDITOR_NAME\": \"Markdown Editor\",\n \"EXT_MDEDITOR_DESC\": \"View and render Markdown (.md) files\"\n}\n"],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { extensionRegistry, i18n } from "@eclipse-docks/core";
|
|
2
|
+
import pkg from "../package.json";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
var t = await i18n(/* @__PURE__ */ Object.assign({
|
|
5
|
+
"./i18n.de.json": () => import("./i18n.de-B-XSgGEO.js"),
|
|
6
|
+
"./i18n.en.json": () => import("./i18n.en-C1spZCa1.js")
|
|
7
|
+
}), true);
|
|
8
|
+
extensionRegistry.registerExtension({
|
|
9
|
+
id: pkg.name,
|
|
10
|
+
name: t.EXT_MDEDITOR_NAME,
|
|
11
|
+
description: t.EXT_MDEDITOR_DESC,
|
|
12
|
+
loader: () => import("./md-editor-extension-8oqW93mK.js"),
|
|
13
|
+
icon: "book"
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry, i18n } from '@eclipse-docks/core';\nimport pkg from '../package.json';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_MDEDITOR_NAME,\n description: t.EXT_MDEDITOR_DESC,\n loader: () => import(\"./md-editor-extension\"),\n icon: \"book\",\n \n \n});\n"],"mappings":";;;AAGA,IAAM,IAAI,MAAM,KAAK,uBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,CAAgC,EAAE,KAAK;AAE5D,kBAAkB,kBAAkB;CAClC,IAAI,IAAI;CACR,MAAM,EAAE;CACR,aAAa,EAAE;CACf,cAAc,OAAO;CACrB,MAAM;CAGP,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DocksPart, File, editorRegistry } from "@eclipse-docks/core";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import { html } from "lit";
|
|
4
|
+
import { marked } from "marked";
|
|
5
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
6
|
+
import _decorate from "@oxc-project/runtime/helpers/decorate";
|
|
7
|
+
//#region src/md-editor-extension.ts
|
|
8
|
+
editorRegistry.registerEditorInputHandler({
|
|
9
|
+
editorId: "system.md-editor",
|
|
10
|
+
label: "Markdown",
|
|
11
|
+
icon: "book",
|
|
12
|
+
canHandle: (input) => input instanceof File && input.getName().toLowerCase().endsWith(".md"),
|
|
13
|
+
handle: async (input) => {
|
|
14
|
+
const editorInput = {
|
|
15
|
+
title: input.getWorkspacePath(),
|
|
16
|
+
data: input,
|
|
17
|
+
key: input.getWorkspacePath(),
|
|
18
|
+
icon: "book",
|
|
19
|
+
state: {}
|
|
20
|
+
};
|
|
21
|
+
editorInput.component = (id) => html`
|
|
22
|
+
<docks-md-editor id="${id}" .input=${editorInput}></docks-md-editor>`;
|
|
23
|
+
return editorInput;
|
|
24
|
+
},
|
|
25
|
+
ranking: 1e3
|
|
26
|
+
});
|
|
27
|
+
var DocksMDEditor = class DocksMDEditor extends DocksPart {
|
|
28
|
+
doClose() {
|
|
29
|
+
this.input = void 0;
|
|
30
|
+
this.mdContents = void 0;
|
|
31
|
+
}
|
|
32
|
+
doBeforeUI() {
|
|
33
|
+
this.loadContent();
|
|
34
|
+
}
|
|
35
|
+
async loadContent() {
|
|
36
|
+
const data = this.input.data;
|
|
37
|
+
if (data instanceof File) {
|
|
38
|
+
const contents = await data.getContents();
|
|
39
|
+
this.updateContents(contents);
|
|
40
|
+
} else if (typeof data === "string" && data.startsWith("http")) {
|
|
41
|
+
const text = await (await fetch(data)).text();
|
|
42
|
+
this.updateContents(text);
|
|
43
|
+
} else if (typeof data === "string") this.updateContents(data);
|
|
44
|
+
}
|
|
45
|
+
renderContent() {
|
|
46
|
+
return html`
|
|
47
|
+
<div style="padding: 10px;">${unsafeHTML(this.mdContents)}</div>`;
|
|
48
|
+
}
|
|
49
|
+
updateContents(text) {
|
|
50
|
+
this.mdContents = marked.parse(text);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
_decorate([property({ attribute: false })], DocksMDEditor.prototype, "input", void 0);
|
|
54
|
+
_decorate([state()], DocksMDEditor.prototype, "mdContents", void 0);
|
|
55
|
+
DocksMDEditor = _decorate([customElement("docks-md-editor")], DocksMDEditor);
|
|
56
|
+
//#endregion
|
|
57
|
+
export { DocksMDEditor };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=md-editor-extension-8oqW93mK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocksPart, EditorInput } from '@eclipse-docks/core';
|
|
2
|
+
export declare class DocksMDEditor extends DocksPart {
|
|
3
|
+
input?: EditorInput;
|
|
4
|
+
private mdContents?;
|
|
5
|
+
protected doClose(): void;
|
|
6
|
+
protected doBeforeUI(): void;
|
|
7
|
+
private loadContent;
|
|
8
|
+
protected renderContent(): import('lit-html').TemplateResult<1>;
|
|
9
|
+
private updateContents;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=md-editor-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-editor-extension.d.ts","sourceRoot":"","sources":["../src/md-editor-extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAG9C,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
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eclipse-docks/extension-md-editor",
|
|
3
|
+
"version": "0.7.68",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@eclipse-docks/core": "*",
|
|
14
|
+
"marked": "^12.0.0 || ^16.4.1"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^6.0.0",
|
|
18
|
+
"vite": "^8.0.0",
|
|
19
|
+
"vite-plugin-dts": "^4.5.4"
|
|
20
|
+
},
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/eclipse-docks/core"
|
|
32
|
+
}
|
|
33
|
+
}
|