@uxland/primary-shell 1.0.16 → 1.0.17

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.
Files changed (54) hide show
  1. package/dist/UI/components/primaria-breadcumbs/primaria-breadcumbs.d.ts +1 -0
  2. package/dist/UI/index.d.ts +1 -0
  3. package/dist/UI/shared-components/dss-container/dss-container.d.ts +7 -0
  4. package/dist/UI/shared-components/index.d.ts +2 -0
  5. package/dist/UI/shared-components/primaria-content-switcher/primaria-content-switcher.d.ts +14 -0
  6. package/dist/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +20 -0
  7. package/dist/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +12 -0
  8. package/dist/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +16 -0
  9. package/dist/UI/shared-components/primaria-interaction/confirm.d.ts +3 -0
  10. package/dist/UI/shared-components/primaria-interaction/index.d.ts +4 -0
  11. package/dist/UI/shared-components/primaria-interaction/notify.d.ts +4 -0
  12. package/dist/UI/shared-components/primaria-interaction/typings.d.ts +28 -0
  13. package/dist/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts +10 -0
  14. package/dist/UI/shared-components/primaria-menu-item/template.d.ts +3 -0
  15. package/dist/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.d.ts +57 -0
  16. package/dist/UI/shared-components/primaria-text-editor/template.d.ts +1 -0
  17. package/dist/UI/shared-components/primaria-text-editor/utils.d.ts +1 -0
  18. package/dist/api/interaction-manager/interaction.d.ts +1 -1
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +24029 -14713
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.umd.cjs +526 -383
  23. package/dist/index.umd.cjs.map +1 -1
  24. package/package.json +3 -2
  25. package/src/UI/components/clinical-monitoring/styles.scss +1 -0
  26. package/src/UI/components/index.ts +1 -1
  27. package/src/UI/components/primaria-breadcumbs/primaria-breadcumbs.ts +5 -1
  28. package/src/UI/components/primaria-shell/styles.scss +1 -3
  29. package/src/UI/components/primaria-shell/template.ts +1 -3
  30. package/src/UI/index.ts +1 -0
  31. package/src/UI/shared-components/design-system.css +1 -0
  32. package/src/UI/shared-components/dss-container/dss-container.ts +32 -0
  33. package/src/UI/shared-components/dss-container/styles.scss +21 -0
  34. package/src/UI/shared-components/index.ts +5 -0
  35. package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +79 -0
  36. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.scss +155 -0
  37. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +119 -0
  38. package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.scss +128 -0
  39. package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +73 -0
  40. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +39 -0
  41. package/src/UI/shared-components/primaria-interaction/confirm.ts +26 -0
  42. package/src/UI/shared-components/primaria-interaction/index.ts +4 -0
  43. package/src/UI/shared-components/primaria-interaction/notify.ts +153 -0
  44. package/src/UI/shared-components/primaria-interaction/typings.ts +32 -0
  45. package/src/UI/shared-components/primaria-menu-item/primaria-menu-item.ts +25 -0
  46. package/src/UI/shared-components/primaria-menu-item/styles.scss +10 -0
  47. package/src/UI/shared-components/primaria-menu-item/template.ts +8 -0
  48. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +230 -0
  49. package/src/UI/shared-components/primaria-text-editor/styles.scss +972 -0
  50. package/src/UI/shared-components/primaria-text-editor/template.ts +8 -0
  51. package/src/UI/shared-components/primaria-text-editor/utils.ts +39 -0
  52. package/src/api/interaction-manager/interaction.ts +1 -1
  53. package/src/index.ts +2 -0
  54. package/src/initializer.ts +1 -1
@@ -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
+ }