@unicef-polymer/etools-form-builder 3.1.6 → 3.1.8
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/assets/translations.js +4 -4
- package/dist/form-fields/field-renderer-component.js +1 -2
- package/dist/rich-editor/rich-action.d.ts +1 -0
- package/dist/rich-editor/rich-action.js +8 -9
- package/dist/rich-editor/rich-toolbar.d.ts +4 -0
- package/dist/rich-editor/rich-toolbar.js +83 -10
- package/dist/rich-editor/rich-viewer.js +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ const translations = {
|
|
|
31
31
|
DOCUMENT_TYPE: 'Document type',
|
|
32
32
|
SELECT_DOCUMENT_TYPE: 'Select Document Type',
|
|
33
33
|
PLEASE_ANSWER: 'Important: Please provide the answer if available',
|
|
34
|
-
NORMAL_TEXT: '
|
|
34
|
+
NORMAL_TEXT: 'Text',
|
|
35
35
|
HEADING1: 'Heading 1',
|
|
36
36
|
HEADING2: 'Heading 2',
|
|
37
37
|
HEADING3: 'Heading 3',
|
|
@@ -81,7 +81,7 @@ const translations = {
|
|
|
81
81
|
DOCUMENT_TYPE: 'Type de document',
|
|
82
82
|
SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document',
|
|
83
83
|
PLEASE_ANSWER: 'Important : veuillez fournir la réponse si disponible',
|
|
84
|
-
NORMAL_TEXT: 'Texte
|
|
84
|
+
NORMAL_TEXT: 'Texte',
|
|
85
85
|
HEADING1: 'Titre 1',
|
|
86
86
|
HEADING2: 'Titre 2',
|
|
87
87
|
HEADING3: 'Titre 3',
|
|
@@ -131,7 +131,7 @@ const translations = {
|
|
|
131
131
|
DOCUMENT_TYPE: 'نوع الوثيقة',
|
|
132
132
|
SELECT_DOCUMENT_TYPE: 'حدد نوع المستند',
|
|
133
133
|
PLEASE_ANSWER: 'هام: يرجى تقديم الإجابة إذا كانت متوفرة',
|
|
134
|
-
NORMAL_TEXT: 'نص
|
|
134
|
+
NORMAL_TEXT: 'نص',
|
|
135
135
|
HEADING1: 'العنوان 1',
|
|
136
136
|
HEADING2: 'العنوان 2',
|
|
137
137
|
HEADING3: 'العنوان 3',
|
|
@@ -181,7 +181,7 @@ const translations = {
|
|
|
181
181
|
DOCUMENT_TYPE: 'Tipo de Documento',
|
|
182
182
|
SELECT_DOCUMENT_TYPE: 'Seleccionar tipo de documento',
|
|
183
183
|
PLEASE_ANSWER: 'Importante: proporcione la respuesta si está disponible.',
|
|
184
|
-
NORMAL_TEXT: 'Texto
|
|
184
|
+
NORMAL_TEXT: 'Texto',
|
|
185
185
|
HEADING1: 'Título 1',
|
|
186
186
|
HEADING2: 'Título 2',
|
|
187
187
|
HEADING3: 'Título 3',
|
|
@@ -224,7 +224,6 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
|
|
|
224
224
|
.additional-field {
|
|
225
225
|
padding-top: 15px;
|
|
226
226
|
padding-bottom: 20px;
|
|
227
|
-
background-color: var(--secondary-background-color);
|
|
228
227
|
}
|
|
229
228
|
.wide-field-container {
|
|
230
229
|
padding-bottom: 10px;
|
|
@@ -235,7 +234,7 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
|
|
|
235
234
|
}
|
|
236
235
|
.wide-field-container .question-text {
|
|
237
236
|
color: var(--secondary-text-color);
|
|
238
|
-
font-weight:
|
|
237
|
+
font-weight: 600;
|
|
239
238
|
}
|
|
240
239
|
.mandatory_warning etools-icon {
|
|
241
240
|
--etools-icon-fill-color: #f59e0b !important;
|
|
@@ -20,7 +20,7 @@ let RichAction = class RichAction extends LitElement {
|
|
|
20
20
|
option-label="name"
|
|
21
21
|
option-value="value"
|
|
22
22
|
.options="${this.values}"
|
|
23
|
-
.selected="${this.values[0].value}"
|
|
23
|
+
.selected="${this.selectedValue || this.values[0].value}"
|
|
24
24
|
dynamic-align
|
|
25
25
|
hide-search
|
|
26
26
|
trigger-value-change-event
|
|
@@ -28,12 +28,12 @@ let RichAction = class RichAction extends LitElement {
|
|
|
28
28
|
if (detail === undefined || detail.selectedItem === null) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (selectedValue === '--') {
|
|
31
|
+
this.selectedValue = detail.selectedItem.value;
|
|
32
|
+
if (this.selectedValue === '--') {
|
|
33
33
|
editorCommand('removeFormat', undefined);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
editorCommand(this.command, selectedValue);
|
|
36
|
+
editorCommand(this.command, this.selectedValue);
|
|
37
37
|
}
|
|
38
38
|
}}"
|
|
39
39
|
>
|
|
@@ -64,15 +64,11 @@ RichAction.styles = css `
|
|
|
64
64
|
flex-direction: row;
|
|
65
65
|
flex-wrap: wrap;
|
|
66
66
|
align-items: center;
|
|
67
|
-
margin-inline-end: 4px;
|
|
68
|
-
}
|
|
69
|
-
section * {
|
|
70
|
-
margin: 2px;
|
|
71
67
|
}
|
|
72
68
|
etools-icon-button {
|
|
73
69
|
cursor: pointer;
|
|
74
70
|
width: 12px;
|
|
75
|
-
padding:
|
|
71
|
+
padding: 0px 8px;
|
|
76
72
|
}
|
|
77
73
|
etools-dropdown {
|
|
78
74
|
min-width: 140px;
|
|
@@ -85,6 +81,9 @@ __decorate([
|
|
|
85
81
|
__decorate([
|
|
86
82
|
property({ type: String })
|
|
87
83
|
], RichAction.prototype, "value", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
property({ type: String })
|
|
86
|
+
], RichAction.prototype, "selectedValue", void 0);
|
|
88
87
|
__decorate([
|
|
89
88
|
property({ type: String })
|
|
90
89
|
], RichAction.prototype, "icon", void 0);
|
|
@@ -9,8 +9,12 @@ export declare class RichToolbar extends LitElement {
|
|
|
9
9
|
node: Element;
|
|
10
10
|
formatColor: string;
|
|
11
11
|
backgroundColor: string;
|
|
12
|
+
selectedFormatBlock?: string;
|
|
13
|
+
selectedFontSize?: string;
|
|
12
14
|
selection: Selection | null;
|
|
13
15
|
language: string;
|
|
16
|
+
formatBlocks: string[];
|
|
17
|
+
fontSizes: string[];
|
|
14
18
|
render(): import("lit-html").TemplateResult<1>;
|
|
15
19
|
constructor();
|
|
16
20
|
connectedCallback(): void;
|
|
@@ -12,9 +12,21 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
12
12
|
<rich-action icon="editor:format-bold" command="bold" ?active=${tags.includes('b')}></rich-action>
|
|
13
13
|
<rich-action icon="editor:format-italic" command="italic" ?active=${tags.includes('i')}></rich-action>
|
|
14
14
|
<rich-action icon="editor:format-underlined" command="underline" ?active=${tags.includes('u')}></rich-action>
|
|
15
|
-
<rich-action
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
<rich-action
|
|
16
|
+
icon="editor:format-align-left"
|
|
17
|
+
command="justifyleft"
|
|
18
|
+
?active=${tags.includes('text-align-left')}
|
|
19
|
+
></rich-action>
|
|
20
|
+
<rich-action
|
|
21
|
+
icon="editor:format-align-center"
|
|
22
|
+
command="justifycenter"
|
|
23
|
+
?active=${tags.includes('text-align-center')}
|
|
24
|
+
></rich-action>
|
|
25
|
+
<rich-action
|
|
26
|
+
icon="editor:format-align-right"
|
|
27
|
+
command="justifyright"
|
|
28
|
+
?active=${tags.includes('text-align-right')}
|
|
29
|
+
></rich-action>
|
|
18
30
|
<rich-action
|
|
19
31
|
icon="editor:format-list-numbered"
|
|
20
32
|
command="insertorderedlist"
|
|
@@ -25,7 +37,12 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
25
37
|
command="insertunorderedlist"
|
|
26
38
|
?active=${tags.includes('ul')}
|
|
27
39
|
></rich-action>
|
|
28
|
-
<rich-action
|
|
40
|
+
<rich-action
|
|
41
|
+
icon="format_quote"
|
|
42
|
+
command="formatblock"
|
|
43
|
+
value="blockquote"
|
|
44
|
+
?active=${tags.includes('blockquote')}
|
|
45
|
+
></rich-action>
|
|
29
46
|
<!-- <rich-action icon="format_indent_decrease" command="outdent"></rich-action>
|
|
30
47
|
<rich-action icon="format_indent_increase" command="indent"></rich-action> -->
|
|
31
48
|
<rich-action
|
|
@@ -40,13 +57,17 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
40
57
|
}}
|
|
41
58
|
>
|
|
42
59
|
</rich-action>
|
|
43
|
-
<rich-action icon="editor:unlink"
|
|
60
|
+
<rich-action icon="editor:unlink" command="unlink"></rich-action>
|
|
44
61
|
<rich-action
|
|
45
62
|
icon="editor:format-color-text"
|
|
46
63
|
.color="${this.formatColor}"
|
|
47
64
|
@action=${() => editorCommand('forecolor', this.formatColor)}
|
|
48
65
|
>
|
|
49
|
-
<etools-icon-button
|
|
66
|
+
<etools-icon-button
|
|
67
|
+
class="arrow-icon"
|
|
68
|
+
name="arrow-drop-down"
|
|
69
|
+
@click="${() => this.fgColorInput.click()}"
|
|
70
|
+
></etools-icon-button>
|
|
50
71
|
<input
|
|
51
72
|
type="color"
|
|
52
73
|
id="fg-color"
|
|
@@ -62,7 +83,11 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
62
83
|
.color="${this.backgroundColor}"
|
|
63
84
|
@action=${() => editorCommand('backcolor', this.backgroundColor)}
|
|
64
85
|
>
|
|
65
|
-
<etools-icon-button
|
|
86
|
+
<etools-icon-button
|
|
87
|
+
class="arrow-icon"
|
|
88
|
+
name="arrow-drop-down"
|
|
89
|
+
@click="${() => this.bdColorInput.click()}"
|
|
90
|
+
></etools-icon-button>
|
|
66
91
|
<input
|
|
67
92
|
type="color"
|
|
68
93
|
id="bd-color"
|
|
@@ -76,6 +101,7 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
76
101
|
<rich-action
|
|
77
102
|
icon="title"
|
|
78
103
|
command="formatblock"
|
|
104
|
+
.selectedValue="${this.selectedFormatBlock}"
|
|
79
105
|
.values=${[
|
|
80
106
|
{ name: getTranslation(this.language, 'NORMAL_TEXT'), value: '--' },
|
|
81
107
|
{ name: getTranslation(this.language, 'HEADING1'), value: 'h1' },
|
|
@@ -91,6 +117,7 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
91
117
|
<rich-action
|
|
92
118
|
icon="editor:format-size"
|
|
93
119
|
command="fontsize"
|
|
120
|
+
.selectedValue="${this.selectedFontSize}"
|
|
94
121
|
.values=${[
|
|
95
122
|
{ name: getTranslation(this.language, 'FONT_SIZE'), value: '--' },
|
|
96
123
|
{ name: getTranslation(this.language, 'VERY_SMALL'), value: '1' },
|
|
@@ -115,6 +142,8 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
115
142
|
this.formatColor = '#000000';
|
|
116
143
|
this.backgroundColor = '#000000';
|
|
117
144
|
this.selection = null;
|
|
145
|
+
this.formatBlocks = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre'];
|
|
146
|
+
this.fontSizes = ['1', '2', '3', '4', '5', '6', '7'];
|
|
118
147
|
if (!this.language) {
|
|
119
148
|
this.language = window.EtoolsLanguage || 'en';
|
|
120
149
|
}
|
|
@@ -135,15 +164,38 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
135
164
|
var _a;
|
|
136
165
|
let tags = [];
|
|
137
166
|
if (this.selection) {
|
|
138
|
-
|
|
167
|
+
this.selectedFontSize = this.selectedFormatBlock = '';
|
|
168
|
+
if (this.selection.type === 'Range' || this.selection.type === 'Caret') {
|
|
139
169
|
// @ts-ignore
|
|
140
170
|
let parentNode = this.selection.baseNode;
|
|
141
171
|
if (parentNode) {
|
|
142
172
|
const checkNode = () => {
|
|
143
|
-
var _a, _b;
|
|
173
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
144
174
|
const tag = (_b = (_a = parentNode === null || parentNode === void 0 ? void 0 : parentNode.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.trim();
|
|
145
|
-
if (tag)
|
|
175
|
+
if (tag) {
|
|
146
176
|
tags.push(tag);
|
|
177
|
+
const textAlign = (_c = parentNode.style) === null || _c === void 0 ? void 0 : _c.textAlign;
|
|
178
|
+
if (textAlign) {
|
|
179
|
+
tags.push(`text-align-${textAlign}`);
|
|
180
|
+
}
|
|
181
|
+
const backgroundColor = (_d = parentNode.style) === null || _d === void 0 ? void 0 : _d.backgroundColor;
|
|
182
|
+
if (backgroundColor) {
|
|
183
|
+
tags.push(`background-color`);
|
|
184
|
+
this.backgroundColor = backgroundColor;
|
|
185
|
+
}
|
|
186
|
+
const fontColor = ((_e = parentNode.style) === null || _e === void 0 ? void 0 : _e.fontColor) || ((_f = parentNode.attributes.getNamedItem('color')) === null || _f === void 0 ? void 0 : _f.value);
|
|
187
|
+
if (fontColor) {
|
|
188
|
+
tags.push(`font-color`);
|
|
189
|
+
this.formatColor = fontColor;
|
|
190
|
+
}
|
|
191
|
+
const fontSize = ((_g = parentNode.style) === null || _g === void 0 ? void 0 : _g.fontSize) || ((_h = parentNode.attributes.getNamedItem('size')) === null || _h === void 0 ? void 0 : _h.value);
|
|
192
|
+
if (fontSize && this.fontSizes.includes(fontSize)) {
|
|
193
|
+
this.selectedFontSize = fontSize;
|
|
194
|
+
}
|
|
195
|
+
if (this.formatBlocks.includes(tag)) {
|
|
196
|
+
this.selectedFormatBlock = tag;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
147
199
|
};
|
|
148
200
|
while (parentNode != null) {
|
|
149
201
|
checkNode();
|
|
@@ -160,6 +212,12 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
160
212
|
.map((tag) => tag.replace(/<|>/g, ''));
|
|
161
213
|
}
|
|
162
214
|
}
|
|
215
|
+
if (!tags.includes('background-color')) {
|
|
216
|
+
this.backgroundColor = '#000000';
|
|
217
|
+
}
|
|
218
|
+
if (!tags.includes('font-color')) {
|
|
219
|
+
this.formatColor = '#000000';
|
|
220
|
+
}
|
|
163
221
|
return tags;
|
|
164
222
|
}
|
|
165
223
|
};
|
|
@@ -185,6 +243,15 @@ RichToolbar.styles = css `
|
|
|
185
243
|
input[type='color']::-webkit-color-swatch {
|
|
186
244
|
border: none;
|
|
187
245
|
}
|
|
246
|
+
rich-action {
|
|
247
|
+
margin: 2px 4px 2px 2px;
|
|
248
|
+
}
|
|
249
|
+
rich-action[active] {
|
|
250
|
+
background-color: #e8e8e8;
|
|
251
|
+
}
|
|
252
|
+
.arrow-icon {
|
|
253
|
+
margin-left: -6px;
|
|
254
|
+
}
|
|
188
255
|
`;
|
|
189
256
|
__decorate([
|
|
190
257
|
query('#fg-color')
|
|
@@ -204,6 +271,12 @@ __decorate([
|
|
|
204
271
|
__decorate([
|
|
205
272
|
property({ type: String })
|
|
206
273
|
], RichToolbar.prototype, "backgroundColor", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
property({ type: String })
|
|
276
|
+
], RichToolbar.prototype, "selectedFormatBlock", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
property({ type: String })
|
|
279
|
+
], RichToolbar.prototype, "selectedFontSize", void 0);
|
|
207
280
|
__decorate([
|
|
208
281
|
property({ type: Object, hasChanged: () => true })
|
|
209
282
|
], RichToolbar.prototype, "selection", void 0);
|