@kedataindo/docflow-element 0.0.1
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/DocsEditorElement.d.ts +14 -0
- package/dist/DocsEditorElement.d.ts.map +1 -0
- package/dist/index.cjs +114 -0
- package/dist/index.css +2843 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/package.json +45 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DocsEditorPlugin } from '@kedata-indonesia/docflow-core';
|
|
2
|
+
export declare class DocsEditorElement extends HTMLElement {
|
|
3
|
+
static observedAttributes: string[];
|
|
4
|
+
private _vueElement?;
|
|
5
|
+
private _shadowRoot?;
|
|
6
|
+
private _plugins;
|
|
7
|
+
get plugins(): DocsEditorPlugin[];
|
|
8
|
+
set plugins(value: DocsEditorPlugin[]);
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
12
|
+
private _buildProps;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=DocsEditorElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocsEditorElement.d.ts","sourceRoot":"","sources":["../src/DocsEditorElement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAQtE,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,MAAM,CAAC,kBAAkB,WAA4D;IAErF,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,WAAW,CAAC,CAAY;IAChC,OAAO,CAAC,QAAQ,CAAyB;IAEzC,IAAI,OAAO,IAAI,gBAAgB,EAAE,CAEhC;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAKpC;IAED,iBAAiB;IAgBjB,oBAAoB;IAMpB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKxF,OAAO,CAAC,WAAW;CAmCpB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
DocsEditorElement: () => DocsEditorElement,
|
|
24
|
+
registerDocsEditor: () => registerDocsEditor
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/DocsEditorElement.ts
|
|
29
|
+
var import_docflow_vue = require("@kedata-indonesia/docflow-vue");
|
|
30
|
+
var import_vue = require("vue");
|
|
31
|
+
|
|
32
|
+
// src/shadow.css?inline
|
|
33
|
+
var shadow_default = {};
|
|
34
|
+
|
|
35
|
+
// src/DocsEditorElement.ts
|
|
36
|
+
var VueDocsEditorElement = (0, import_vue.defineCustomElement)(import_docflow_vue.DocsEditor);
|
|
37
|
+
var DocsEditorElement = class extends HTMLElement {
|
|
38
|
+
static observedAttributes = ["room", "theme", "editable", "content", "websocket-url"];
|
|
39
|
+
_vueElement;
|
|
40
|
+
_shadowRoot;
|
|
41
|
+
_plugins = [];
|
|
42
|
+
get plugins() {
|
|
43
|
+
return this._plugins;
|
|
44
|
+
}
|
|
45
|
+
set plugins(value) {
|
|
46
|
+
this._plugins = value;
|
|
47
|
+
if (this._vueElement) {
|
|
48
|
+
Object.assign(this._vueElement, this._buildProps());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
53
|
+
this._shadowRoot = this.attachShadow({ mode: "open" });
|
|
54
|
+
const styleEl = document.createElement("style");
|
|
55
|
+
styleEl.textContent = shadow_default;
|
|
56
|
+
this._shadowRoot.appendChild(styleEl);
|
|
57
|
+
const props = this._buildProps();
|
|
58
|
+
this._vueElement = new VueDocsEditorElement(props);
|
|
59
|
+
this._shadowRoot.appendChild(this._vueElement);
|
|
60
|
+
}
|
|
61
|
+
disconnectedCallback() {
|
|
62
|
+
this._vueElement?.remove();
|
|
63
|
+
this._vueElement = void 0;
|
|
64
|
+
this._shadowRoot = void 0;
|
|
65
|
+
}
|
|
66
|
+
attributeChangedCallback(_name, oldValue, newValue) {
|
|
67
|
+
if (oldValue === newValue || !this._vueElement) return;
|
|
68
|
+
Object.assign(this._vueElement, this._buildProps());
|
|
69
|
+
}
|
|
70
|
+
_buildProps() {
|
|
71
|
+
const editableAttr = this.getAttribute("editable");
|
|
72
|
+
const editable = editableAttr === null ? true : editableAttr !== "false";
|
|
73
|
+
let modelValue;
|
|
74
|
+
const contentAttr = this.getAttribute("content");
|
|
75
|
+
if (contentAttr !== null) {
|
|
76
|
+
try {
|
|
77
|
+
modelValue = JSON.parse(contentAttr);
|
|
78
|
+
} catch {
|
|
79
|
+
modelValue = contentAttr;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const room = this.getAttribute("room");
|
|
83
|
+
const websocketUrl = this.getAttribute("websocket-url");
|
|
84
|
+
let collaboration;
|
|
85
|
+
if (room) {
|
|
86
|
+
collaboration = {
|
|
87
|
+
room,
|
|
88
|
+
user: { name: "Anonymous", color: "#3b82f6" }
|
|
89
|
+
};
|
|
90
|
+
if (websocketUrl) {
|
|
91
|
+
collaboration.provider = "websocket";
|
|
92
|
+
collaboration.websocketUrl = websocketUrl;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
modelValue,
|
|
97
|
+
editable,
|
|
98
|
+
collaboration,
|
|
99
|
+
plugins: this._plugins
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/index.ts
|
|
105
|
+
function registerDocsEditor(tagName = "docs-editor", registry = typeof customElements !== "undefined" ? customElements : void 0) {
|
|
106
|
+
if (registry && !registry.get(tagName)) {
|
|
107
|
+
registry.define(tagName, DocsEditorElement);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
DocsEditorElement,
|
|
113
|
+
registerDocsEditor
|
|
114
|
+
});
|