@pod-os/elements 0.30.2-rc.a4eda69.0 → 0.30.2-rc.ca6f577.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.
- package/dist/cjs/pos-markdown-document.cjs.entry.js +4674 -5752
- package/dist/cjs/pos-markdown-document.cjs.entry.js.map +1 -1
- package/dist/collection/components/pos-markdown-document/pos-markdown-document.js +5 -15
- package/dist/collection/components/pos-markdown-document/pos-markdown-document.js.map +1 -1
- package/dist/components/pos-markdown-document2.js +4674 -5752
- package/dist/components/pos-markdown-document2.js.map +1 -1
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/p-581ed3ee.entry.js +3 -0
- package/dist/elements/p-581ed3ee.entry.js.map +1 -0
- package/dist/esm/pos-markdown-document.entry.js +4674 -5752
- package/dist/esm/pos-markdown-document.entry.js.map +1 -1
- package/dist/types/components/pos-markdown-document/pos-markdown-document.d.ts +2 -2
- package/package.json +6 -6
- package/dist/elements/p-b479ffbe.entry.js +0 -3
- package/dist/elements/p-b479ffbe.entry.js.map +0 -1
|
@@ -47,19 +47,19 @@ export class PosMarkdownDocument {
|
|
|
47
47
|
/**
|
|
48
48
|
* Switch to editing mode
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
startEditing() {
|
|
51
51
|
this.editor.startEditing();
|
|
52
52
|
this.isEditing = true;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Switch to view mode
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
stopEditing() {
|
|
58
58
|
this.editor.stopEditing();
|
|
59
59
|
this.isEditing = false;
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
|
-
return (h("article", { key: '
|
|
62
|
+
return (h("article", { key: '21cbe982b1ead2ba403706407e05d97903e0073b' }, this.editable ? (h("header", null, this.isEditing ? this.getStatus() : null, this.isEditing ? (h("button", { onClick: () => this.stopEditing() }, h("sl-icon", { name: "eye" }), "View")) : (h("button", { onClick: () => this.startEditing() }, h("sl-icon", { name: "pencil-square" }), "Edit")))) : null, h("div", { key: '22f18aeef51e66cee8e7300fd82def756d8ae522', class: "content", ref: el => (this.editorEl = el) })));
|
|
63
63
|
}
|
|
64
64
|
getStatus() {
|
|
65
65
|
if (this.isModified) {
|
|
@@ -185,12 +185,7 @@ export class PosMarkdownDocument {
|
|
|
185
185
|
"complexType": {
|
|
186
186
|
"signature": "() => Promise<void>",
|
|
187
187
|
"parameters": [],
|
|
188
|
-
"references": {
|
|
189
|
-
"Promise": {
|
|
190
|
-
"location": "global",
|
|
191
|
-
"id": "global::Promise"
|
|
192
|
-
}
|
|
193
|
-
},
|
|
188
|
+
"references": {},
|
|
194
189
|
"return": "Promise<void>"
|
|
195
190
|
},
|
|
196
191
|
"docs": {
|
|
@@ -202,12 +197,7 @@ export class PosMarkdownDocument {
|
|
|
202
197
|
"complexType": {
|
|
203
198
|
"signature": "() => Promise<void>",
|
|
204
199
|
"parameters": [],
|
|
205
|
-
"references": {
|
|
206
|
-
"Promise": {
|
|
207
|
-
"location": "global",
|
|
208
|
-
"id": "global::Promise"
|
|
209
|
-
}
|
|
210
|
-
},
|
|
200
|
+
"references": {},
|
|
211
201
|
"return": "Promise<void>"
|
|
212
202
|
},
|
|
213
203
|
"docs": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pos-markdown-document.js","sourceRoot":"","sources":["../../../../src/components/pos-markdown-document/pos-markdown-document.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAEvF,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC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CAAC,IAAI;gBACf,UAAU,EAAE,QAAQ;aACrB,CAAC,CAAC;QACL,CAAC,CAAC,CACH;aACA,SAAS,EAAE,CAAC;IACjB,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IAEH,
|
|
1
|
+
{"version":3,"file":"pos-markdown-document.js","sourceRoot":"","sources":["../../../../src/components/pos-markdown-document/pos-markdown-document.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAEvF,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYhD,MAAM,OAAO,mBAAmB;IALhC;QAYE;;WAEG;QAEH,iBAAY,GAAY,KAAK,CAAC;QAE9B;;WAEG;QAEH,aAAQ,GAAY,KAAK,CAAC;QAQlB,eAAU,GAAY,KAAK,CAAC;QAK5B,cAAS,GAAY,KAAK,CAAC;QAQlB,kBAAa,GAAG,IAAI,OAAO,EAAQ,CAAC;KAqFtD;IAnFC,KAAK,CAAC,iBAAiB;QACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,QA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I,EAAE,OAAO,EAAE;IACvC,OAAO,CACL,YACE,KAAK,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,CAAC,MAAM,CAAC,EAAE,IAAI;SACf,EACD,IAAI,EAAC,QAAQ,eACH,QAAQ,qBACF,gBAAgB;QAEhC,eAAS,IAAI,EAAE,IAAI,iBAAc,MAAM,GAAW;QAClD,YAAM,EAAE,EAAC,gBAAgB,IAAE,OAAO,CAAQ,CACrC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { SolidFile } from '@pod-os/core';\nimport { Component, h, Method, Prop, State, Event, EventEmitter } from '@stencil/core';\n\nimport { sanitize, SanitizedHtml } from './sanitize';\nimport { RichEditor } from './rich-editor';\n\nimport './shoelace';\nimport { map, Subject, takeUntil, tap } from 'rxjs';\nimport { html2markdown } from './html2markdown';\nimport { markdown2html } from './markdown2html';\n\ninterface ModifiedFile {\n file: SolidFile;\n newContent: string;\n}\n\n@Component({\n tag: 'pos-markdown-document',\n styleUrls: ['pos-markdown-document.css', '../../apps/styles/article-card.css'],\n shadow: true,\n})\nexport class PosMarkdownDocument {\n /**\n * The file to show / edit\n */\n @Prop()\n file: SolidFile;\n\n /**\n * Whether saving the latest changes failed\n */\n @Prop()\n savingFailed: boolean = false;\n\n /**\n * Whether the current user has the permission to edit the file\n */\n @Prop()\n editable: boolean = false;\n\n @State()\n private sanitizedHtml: SanitizedHtml;\n\n private editorEl: HTMLElement;\n\n @State()\n private isModified: boolean = false;\n\n private editor: RichEditor;\n\n @State()\n private isEditing: boolean = false;\n\n /**\n * Event emitted when the document has been modified\n */\n @Event({ eventName: 'pod-os:document-modified' })\n documentModified: EventEmitter<ModifiedFile>;\n\n private readonly disconnected$ = new Subject<void>();\n\n async componentWillLoad() {\n const markdown = await this.file.blob().text();\n const html = await markdown2html(markdown);\n this.sanitizedHtml = sanitize(html);\n }\n\n componentDidLoad() {\n this.editor = new RichEditor(this.editorEl, this.sanitizedHtml, this.file.url);\n this.editor.onUpdate(() => {\n this.isModified = this.editor.isModified();\n });\n this.editor\n .observeChanges()\n .pipe(\n takeUntil(this.disconnected$),\n map(changes => html2markdown(changes.content)),\n tap(markdown => {\n this.isModified = false;\n this.documentModified.emit({\n file: this.file,\n newContent: markdown,\n });\n }),\n )\n .subscribe();\n }\n\n disconnectedCallback() {\n this.disconnected$.next();\n this.disconnected$.unsubscribe();\n }\n\n /**\n * Switch to editing mode\n */\n @Method()\n startEditing() {\n this.editor.startEditing();\n this.isEditing = true;\n }\n\n /**\n * Switch to view mode\n */\n @Method()\n stopEditing() {\n this.editor.stopEditing();\n this.isEditing = false;\n }\n\n render() {\n return (\n <article>\n {this.editable ? (\n <header>\n {this.isEditing ? this.getStatus() : null}\n {this.isEditing ? (\n <button onClick={() => this.stopEditing()}>\n <sl-icon name=\"eye\"></sl-icon>\n View\n </button>\n ) : (\n <button onClick={() => this.startEditing()}>\n <sl-icon name=\"pencil-square\"></sl-icon>\n Edit\n </button>\n )}\n </header>\n ) : null}\n <div class=\"content\" ref={el => (this.editorEl = el)}></div>\n </article>\n );\n }\n\n private getStatus() {\n if (this.isModified) {\n return <Status status=\"pending\" message=\"pending changes\" icon=\"clock-history\"></Status>;\n }\n if (this.savingFailed) {\n return <Status status=\"error\" message=\"saving failed\" icon=\"x-octagon\"></Status>;\n }\n return <Status status=\"success\" message=\"all saved\" icon=\"check2-circle\"></Status>;\n }\n}\n\nfunction Status({ status, icon, message }) {\n return (\n <span\n class={{\n status: true,\n [status]: true,\n }}\n role=\"status\"\n aria-live=\"polite\"\n aria-labelledby=\"status-message\"\n >\n <sl-icon name={icon} aria-hidden=\"true\"></sl-icon>\n <span id=\"status-message\">{message}</span>\n </span>\n );\n}\n"]}
|