@uxland/primary-shell 1.1.0 → 2.0.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/README.md +231 -0
- package/dist/UI/components/clinical-monitoring/clinical-monitoring.d.ts +11 -0
- package/dist/UI/components/clinical-monitoring/template.d.ts +3 -0
- package/dist/UI/components/index.d.ts +1 -0
- package/dist/UI/components/primaria-breadcumbs/primaria-breadcumbs.d.ts +9 -0
- package/dist/UI/components/primaria-breadcumbs/template.d.ts +3 -0
- package/dist/UI/components/primaria-shell/primaria-shell.d.ts +14 -0
- package/dist/UI/components/primaria-shell/template.d.ts +3 -0
- package/dist/UI/components/title-view/template.d.ts +3 -0
- package/dist/UI/components/title-view/title-view.d.ts +9 -0
- package/dist/UI/index.d.ts +2 -0
- package/dist/UI/shared-components/dss-container/dss-container.d.ts +7 -0
- package/dist/UI/shared-components/index.d.ts +2 -0
- package/dist/UI/shared-components/primaria-content-switcher/primaria-content-switcher.d.ts +14 -0
- package/dist/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +20 -0
- package/dist/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +12 -0
- package/dist/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +16 -0
- package/dist/UI/shared-components/primaria-interaction/confirm.d.ts +3 -0
- package/dist/UI/shared-components/primaria-interaction/index.d.ts +4 -0
- package/dist/UI/shared-components/primaria-interaction/notify.d.ts +4 -0
- package/dist/UI/shared-components/primaria-interaction/typings.d.ts +28 -0
- package/dist/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts +10 -0
- package/dist/UI/shared-components/primaria-menu-item/template.d.ts +3 -0
- package/dist/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.d.ts +57 -0
- package/dist/UI/shared-components/primaria-text-editor/template.d.ts +1 -0
- package/dist/UI/shared-components/primaria-text-editor/utils.d.ts +1 -0
- package/dist/UI/styles/theme/apply-theme.d.ts +1 -0
- package/dist/api/api.d.ts +27 -0
- package/dist/api/broker/factory.d.ts +3 -0
- package/dist/api/broker/factory.test.d.ts +1 -0
- package/dist/api/broker/primaria-broker.d.ts +5 -0
- package/dist/api/global-state/global-state.d.ts +35 -0
- package/dist/api/global-state/global-state.test.d.ts +1 -0
- package/dist/api/interaction-manager/interaction.d.ts +8 -0
- package/dist/api/localization/localization.test.d.ts +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26335 -239
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +8647 -0
- package/dist/index.umd.cjs.map +1 -0
- package/dist/initializer.d.ts +1 -0
- package/dist/locales.d.ts +15 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/region-manager.d.ts +16 -0
- package/dist/regions.d.ts +14 -0
- package/dist/style.css +3 -0
- package/package.json +23 -15
- package/src/UI/components/clinical-monitoring/clinical-monitoring.ts +28 -0
- package/src/UI/components/clinical-monitoring/styles.scss +29 -0
- package/src/UI/components/clinical-monitoring/template.ts +12 -0
- package/src/UI/components/index.ts +5 -0
- package/src/UI/components/primaria-breadcumbs/primaria-breadcumbs.ts +27 -0
- package/src/UI/components/primaria-breadcumbs/styles.scss +25 -0
- package/src/UI/components/primaria-breadcumbs/template.ts +15 -0
- package/src/UI/components/primaria-shell/primaria-shell.ts +37 -0
- package/src/UI/components/primaria-shell/styles.scss +68 -0
- package/src/UI/components/primaria-shell/template.ts +94 -0
- package/src/UI/components/title-view/styles.scss +5 -0
- package/src/UI/components/title-view/template.ts +6 -0
- package/src/UI/components/title-view/title-view.ts +23 -0
- package/src/UI/images/Gencat_Logotip.svg +70 -0
- package/src/UI/images/Salut_Logotip.svg +8 -0
- package/src/UI/index.ts +2 -0
- package/src/UI/shared-components/design-system.css +1 -0
- package/src/UI/shared-components/dss-container/dss-container.ts +32 -0
- package/src/UI/shared-components/dss-container/styles.scss +23 -0
- package/src/UI/shared-components/index.ts +5 -0
- package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +79 -0
- package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.scss +155 -0
- package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +120 -0
- package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.scss +128 -0
- package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +73 -0
- package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +39 -0
- package/src/UI/shared-components/primaria-interaction/confirm.ts +30 -0
- package/src/UI/shared-components/primaria-interaction/index.ts +4 -0
- package/src/UI/shared-components/primaria-interaction/notify.ts +153 -0
- package/src/UI/shared-components/primaria-interaction/typings.ts +32 -0
- package/src/UI/shared-components/primaria-menu-item/primaria-menu-item.ts +25 -0
- package/src/UI/shared-components/primaria-menu-item/styles.scss +10 -0
- package/src/UI/shared-components/primaria-menu-item/template.ts +8 -0
- package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +230 -0
- package/src/UI/shared-components/primaria-text-editor/styles.scss +972 -0
- package/src/UI/shared-components/primaria-text-editor/template.ts +8 -0
- package/src/UI/shared-components/primaria-text-editor/utils.ts +39 -0
- package/src/UI/styles/_flex-layout.scss +203 -0
- package/src/UI/styles/_normalize.scss +3 -0
- package/src/UI/styles/_variables.scss +40 -0
- package/src/UI/styles/styles.scss +3 -0
- package/src/UI/styles/theme/apply-theme.ts +11 -0
- package/src/api/api.ts +63 -0
- package/src/api/broker/factory.test.ts +124 -0
- package/src/api/broker/factory.ts +122 -0
- package/src/api/broker/primaria-broker.ts +11 -0
- package/src/api/global-state/global-state.test.ts +53 -0
- package/src/api/global-state/global-state.ts +49 -0
- package/src/api/interaction-manager/interaction.ts +21 -0
- package/src/api/localization/localization.test.ts +61 -0
- package/src/api/localization/localization.ts +54 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +12 -0
- package/src/initializer.ts +39 -4
- package/src/locales.ts +24 -0
- package/src/plugin.ts +9 -0
- package/src/region-manager.ts +155 -0
- package/src/regions.ts +17 -6
- package/dist/index.mjs +0 -3209
- package/index.ts +0 -3
- package/src/primary-shell.ts +0 -78
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import Quill from "uxl-quill/dist/quill";
|
|
4
|
+
import styles from "./styles.scss?inline";
|
|
5
|
+
import { template } from "./template";
|
|
6
|
+
import { fixSpellCheckerIssue } from "./utils";
|
|
7
|
+
|
|
8
|
+
fixSpellCheckerIssue(Quill);
|
|
9
|
+
|
|
10
|
+
@customElement("primaria-rich-text-editor")
|
|
11
|
+
export class PrimariaRichTextEditor extends LitElement {
|
|
12
|
+
render() {
|
|
13
|
+
return html` ${template(this)} `;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static styles = css`
|
|
17
|
+
${unsafeCSS(styles)}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
firstUpdated() {
|
|
21
|
+
// const rte: PrimariaRichTextEditor = this;
|
|
22
|
+
this.quill = new Quill(this.shadowRoot?.querySelector("#rte"), this._getOptions());
|
|
23
|
+
this.quill.on("text-change", (delta, oldDelta, source) => {
|
|
24
|
+
const plainValue = this.quill.getText();
|
|
25
|
+
const values = {
|
|
26
|
+
html: (<any>this).shadowRoot.querySelector(".ql-editor").innerHTML,
|
|
27
|
+
plain: plainValue,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const textChanged = new CustomEvent("text-changed", {
|
|
31
|
+
composed: true,
|
|
32
|
+
detail: values,
|
|
33
|
+
});
|
|
34
|
+
(<any>this).dispatchEvent(textChanged);
|
|
35
|
+
this.range = this.getCursorPosition();
|
|
36
|
+
});
|
|
37
|
+
this.quill.on("selection-change", (range, oldRange, source) => {
|
|
38
|
+
if (range) this.range = range;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@property()
|
|
43
|
+
quill: Quill | null;
|
|
44
|
+
|
|
45
|
+
@property()
|
|
46
|
+
options: string;
|
|
47
|
+
|
|
48
|
+
@property({ type: Object })
|
|
49
|
+
range: { index: number; length: number };
|
|
50
|
+
|
|
51
|
+
@property({ type: Array })
|
|
52
|
+
availableOptions: string[] = [
|
|
53
|
+
"bold",
|
|
54
|
+
"italic",
|
|
55
|
+
"underline",
|
|
56
|
+
"strike",
|
|
57
|
+
"blockquote",
|
|
58
|
+
"code-block",
|
|
59
|
+
"image",
|
|
60
|
+
"video",
|
|
61
|
+
"link",
|
|
62
|
+
"color",
|
|
63
|
+
"background",
|
|
64
|
+
"ol",
|
|
65
|
+
"ul",
|
|
66
|
+
"subindex",
|
|
67
|
+
"superindex",
|
|
68
|
+
// 'outdent',
|
|
69
|
+
// 'indent',
|
|
70
|
+
"size",
|
|
71
|
+
"header",
|
|
72
|
+
"font",
|
|
73
|
+
"align",
|
|
74
|
+
// "clear",
|
|
75
|
+
"undo",
|
|
76
|
+
"redo",
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
@property({ type: Array })
|
|
80
|
+
availableFormats: string[] = [
|
|
81
|
+
"background",
|
|
82
|
+
"bold",
|
|
83
|
+
"color",
|
|
84
|
+
"font",
|
|
85
|
+
"code",
|
|
86
|
+
"italic",
|
|
87
|
+
"link",
|
|
88
|
+
"size",
|
|
89
|
+
"strike",
|
|
90
|
+
"script",
|
|
91
|
+
"underline",
|
|
92
|
+
"blockquote",
|
|
93
|
+
"header",
|
|
94
|
+
// 'indent',
|
|
95
|
+
"list",
|
|
96
|
+
"align",
|
|
97
|
+
"direction",
|
|
98
|
+
"code-block",
|
|
99
|
+
"formula",
|
|
100
|
+
"image",
|
|
101
|
+
"video",
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
@property()
|
|
105
|
+
formats: string;
|
|
106
|
+
|
|
107
|
+
_getOptions() {
|
|
108
|
+
let toolbarOptions = [];
|
|
109
|
+
const availableOpts = this.availableOptions;
|
|
110
|
+
if (this.options === undefined || this.options.length === 0) {
|
|
111
|
+
toolbarOptions = [
|
|
112
|
+
["bold", "italic", "underline", "strike"],
|
|
113
|
+
["blockquote", "code-block"],
|
|
114
|
+
[{ header: 1 }, { header: 2 }],
|
|
115
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
116
|
+
[{ script: "sub" }, { script: "super" }],
|
|
117
|
+
// [{indent: '-1'}, {indent: '+1'}],
|
|
118
|
+
[{ direction: "rtl" }],
|
|
119
|
+
[{ size: ["small", false, "large", "huge", "20px"] }],
|
|
120
|
+
[{ header: [1, 2, 3, 4, 5, 6, false] }],
|
|
121
|
+
[{ color: [] }, { background: [] }],
|
|
122
|
+
[{ font: [] }],
|
|
123
|
+
[{ align: [] }],
|
|
124
|
+
["image"],
|
|
125
|
+
["video"],
|
|
126
|
+
// ["clean"],
|
|
127
|
+
];
|
|
128
|
+
} else {
|
|
129
|
+
toolbarOptions = this.options.split(",");
|
|
130
|
+
toolbarOptions.forEach((option) => {
|
|
131
|
+
if (availableOpts.indexOf(option) <= -1)
|
|
132
|
+
toolbarOptions.splice(toolbarOptions.indexOf(option), 1);
|
|
133
|
+
});
|
|
134
|
+
toolbarOptions = toolbarOptions.map(function (option) {
|
|
135
|
+
if (option == "color") return { color: [] };
|
|
136
|
+
else if (option == "ol") return { list: "ordered" };
|
|
137
|
+
else if (option == "ul") return { list: "bullet" };
|
|
138
|
+
else if (option == "subindex") return { script: "sub" };
|
|
139
|
+
else if (option == "superindex") return { script: "super" };
|
|
140
|
+
// else if (option == 'outdent') return {indent: '-1'};
|
|
141
|
+
// else if (option == 'indent') return {indent: '+1'};
|
|
142
|
+
else if (option == "size") return { size: ["small", false, "large", "huge"] };
|
|
143
|
+
else if (option == "header") return { header: [1, 2, 3, 4, 5, 6, false] };
|
|
144
|
+
else if (option == "background") return { background: [] };
|
|
145
|
+
else if (option == "font") return { font: [] };
|
|
146
|
+
else if (option == "align") return { align: [] };
|
|
147
|
+
/* else if (option == 'undo') return {undo: undo_icon};
|
|
148
|
+
else if (option == 'redo') return {redo: redo_icon}; */ else return option;
|
|
149
|
+
});
|
|
150
|
+
// if (toolbarOptions.indexOf("clean") < 0) {
|
|
151
|
+
// toolbarOptions.push("clean");
|
|
152
|
+
// }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* const icons = Quill.import('ui/icons');
|
|
156
|
+
icons['undo'] = undo_icon;
|
|
157
|
+
icons['redo'] = redo_icon; */
|
|
158
|
+
|
|
159
|
+
let formats = this.availableFormats;
|
|
160
|
+
if (this.formats) {
|
|
161
|
+
formats = this.formats.split(",");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
modules: {
|
|
166
|
+
toolbar: {
|
|
167
|
+
container: toolbarOptions,
|
|
168
|
+
handlers: {
|
|
169
|
+
redo() {
|
|
170
|
+
this.quill.history.redo();
|
|
171
|
+
},
|
|
172
|
+
undo() {
|
|
173
|
+
this.quill.history.undo();
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
history: {
|
|
178
|
+
delay: 1000,
|
|
179
|
+
maxStack: 50,
|
|
180
|
+
userOnly: false,
|
|
181
|
+
},
|
|
182
|
+
keyboard: {
|
|
183
|
+
bindings: {
|
|
184
|
+
indent: {
|
|
185
|
+
// highlight tab or tab at beginning of list, indent or blockquote
|
|
186
|
+
key: "Tab",
|
|
187
|
+
format: ["blockquote", "indent", "list"],
|
|
188
|
+
handler(range, context) {
|
|
189
|
+
if (
|
|
190
|
+
(context.collapsed && context.offset !== 0) ||
|
|
191
|
+
context.format?.list === "ordered" // disable ordered list auto-numbering on indentation
|
|
192
|
+
)
|
|
193
|
+
return true;
|
|
194
|
+
this.quill.format("indent", "+1", Quill.sources.USER);
|
|
195
|
+
return false;
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
"list autofill": {
|
|
199
|
+
key: " ",
|
|
200
|
+
shiftKey: null,
|
|
201
|
+
collapsed: true,
|
|
202
|
+
format: {
|
|
203
|
+
"code-block": false,
|
|
204
|
+
blockquote: false,
|
|
205
|
+
table: false,
|
|
206
|
+
},
|
|
207
|
+
prefix: /^\s*?(\d+\.|-|\*)$/,
|
|
208
|
+
handler(range, context) {
|
|
209
|
+
if (this.quill.scroll.query("list") == null) return true;
|
|
210
|
+
const { length } = context.prefix;
|
|
211
|
+
const line = this.quill.getLine(range.index);
|
|
212
|
+
const offset = line[1];
|
|
213
|
+
if (offset > length) return true;
|
|
214
|
+
this.quill.insertText(range.index, " ", Quill.sources.USER);
|
|
215
|
+
this.quill.setSelection(range.index - length, Quill.sources.SILENT);
|
|
216
|
+
return false;
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
theme: "snow",
|
|
223
|
+
formats: formats,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
public getCursorPosition() {
|
|
228
|
+
return this.quill.getSelection();
|
|
229
|
+
}
|
|
230
|
+
}
|