@unicef-polymer/etools-form-builder 3.1.3 → 3.1.5

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.
@@ -30,7 +30,24 @@ const translations = {
30
30
  NUMBER_MUST_BE_LOWER_THAN: 'Number must be lower than {0}',
31
31
  DOCUMENT_TYPE: 'Document type',
32
32
  SELECT_DOCUMENT_TYPE: 'Select Document Type',
33
- PLEASE_ANSWER: 'Important: Please provide the answer if available'
33
+ PLEASE_ANSWER: 'Important: Please provide the answer if available',
34
+ NORMAL_TEXT: 'Normal Text',
35
+ HEADING1: 'Heading 1',
36
+ HEADING2: 'Heading 2',
37
+ HEADING3: 'Heading 3',
38
+ HEADING4: 'Heading 4',
39
+ HEADING5: 'Heading 5',
40
+ HEADING6: 'Heading 6',
41
+ PARAGRAPH: 'Paragraph',
42
+ PRE_FORMATTED: 'Pre-Formatted',
43
+ FONT_SIZE: 'Font Size',
44
+ VERY_SMALL: 'Very Small',
45
+ SMALL: 'Small',
46
+ NORMAL: 'Normal',
47
+ MEDIUM_LARGE: 'Medium Large',
48
+ LARGE: 'Large',
49
+ VERY_LARGE: 'Very Large',
50
+ MAXIMUM: 'Maximum'
34
51
  },
35
52
  fr: {
36
53
  SAVE: 'Sauvegarder',
@@ -63,7 +80,24 @@ const translations = {
63
80
  NUMBER_MUST_BE_LOWER_THAN: 'Le nombre doit être inférieur à {0}',
64
81
  DOCUMENT_TYPE: 'Type de document',
65
82
  SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document',
66
- PLEASE_ANSWER: 'Important : veuillez fournir la réponse si disponible'
83
+ PLEASE_ANSWER: 'Important : veuillez fournir la réponse si disponible',
84
+ NORMAL_TEXT: 'Texte normal',
85
+ HEADING1: 'Titre 1',
86
+ HEADING2: 'Titre 2',
87
+ HEADING3: 'Titre 3',
88
+ HEADING4: 'Titre 4',
89
+ HEADING5: 'Titre 5',
90
+ HEADING6: 'Titre 6',
91
+ PARAGRAPH: 'Paragraphe',
92
+ PRE_FORMATTED: 'Pré-formaté',
93
+ FONT_SIZE: 'Taille de la police',
94
+ VERY_SMALL: 'Très petit',
95
+ SMALL: 'Petit',
96
+ NORMAL: 'Normale',
97
+ MEDIUM_LARGE: 'Moyen Grand',
98
+ LARGE: 'Grand',
99
+ VERY_LARGE: 'Très grand',
100
+ MAXIMUM: 'Maximum'
67
101
  },
68
102
  ar: {
69
103
  SAVE: 'يحفظ',
@@ -96,7 +130,24 @@ const translations = {
96
130
  NUMBER_MUST_BE_LOWER_THAN: 'يجب أن يكون الرقم أقل من {0}',
97
131
  DOCUMENT_TYPE: 'نوع الوثيقة',
98
132
  SELECT_DOCUMENT_TYPE: 'حدد نوع المستند',
99
- PLEASE_ANSWER: 'هام: يرجى تقديم الإجابة إذا كانت متوفرة'
133
+ PLEASE_ANSWER: 'هام: يرجى تقديم الإجابة إذا كانت متوفرة',
134
+ NORMAL_TEXT: 'نص عادي',
135
+ HEADING1: 'العنوان 1',
136
+ HEADING2: 'العنوان 2',
137
+ HEADING3: 'العنوان 3',
138
+ HEADING4: 'العنوان 4',
139
+ HEADING5: 'العنوان 5',
140
+ HEADING6: 'العنوان 6',
141
+ PARAGRAPH: 'فقرة',
142
+ PRE_FORMATTED: 'منسقة مسبقًا',
143
+ FONT_SIZE: 'حجم الخط',
144
+ VERY_SMALL: 'صغير جدًا',
145
+ SMALL: 'صغير',
146
+ NORMAL: 'طبيعي',
147
+ MEDIUM_LARGE: 'متوسطة كبيرة',
148
+ LARGE: 'كبير',
149
+ VERY_LARGE: 'كبير جدًا',
150
+ MAXIMUM: 'الحد الأقصى'
100
151
  },
101
152
  es: {
102
153
  SAVE: 'Guardar',
@@ -129,7 +180,24 @@ const translations = {
129
180
  NUMBER_MUST_BE_LOWER_THAN: 'El número debe ser inferior a {0}',
130
181
  DOCUMENT_TYPE: 'Tipo de Documento',
131
182
  SELECT_DOCUMENT_TYPE: 'Seleccionar tipo de documento',
132
- PLEASE_ANSWER: 'Importante: proporcione la respuesta si está disponible.'
183
+ PLEASE_ANSWER: 'Importante: proporcione la respuesta si está disponible.',
184
+ NORMAL_TEXT: 'Texto normal',
185
+ HEADING1: 'Título 1',
186
+ HEADING2: 'Título 2',
187
+ HEADING3: 'Título 3',
188
+ HEADING4: 'Título 4',
189
+ HEADING5: 'Título 5',
190
+ HEADING6: 'Título 6',
191
+ PARAGRAPH: 'Párrafo',
192
+ PRE_FORMATTED: 'Preformateado',
193
+ FONT_SIZE: 'Tamaño de fuente',
194
+ VERY_SMALL: 'Muy pequeño',
195
+ SMALL: 'Pequeño',
196
+ NORMAL: 'Normal',
197
+ MEDIUM_LARGE: 'Mediano Grande',
198
+ LARGE: 'Grande',
199
+ VERY_LARGE: 'Muy Grande',
200
+ MAXIMUM: 'Máximo'
133
201
  }
134
202
  };
135
203
  export default translations;
@@ -62,6 +62,7 @@ RichAction.styles = css `
62
62
  height: 100%;
63
63
  display: flex;
64
64
  flex-direction: row;
65
+ flex-wrap: wrap;
65
66
  align-items: center;
66
67
  margin-inline-end: 4px;
67
68
  }
@@ -75,7 +76,7 @@ RichAction.styles = css `
75
76
  }
76
77
  etools-dropdown {
77
78
  min-width: 140px;
78
- margin-block-end: 24px;
79
+ margin-block-end: 2px;
79
80
  }
80
81
  `;
81
82
  __decorate([
@@ -1,4 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
+ import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
2
3
  import './rich-action';
3
4
  export declare class RichToolbar extends LitElement {
4
5
  static styles: import("lit").CSSResult;
@@ -9,6 +10,11 @@ export declare class RichToolbar extends LitElement {
9
10
  formatColor: string;
10
11
  backgroundColor: string;
11
12
  selection: Selection | null;
13
+ language: string;
12
14
  render(): import("lit-html").TemplateResult<1>;
15
+ constructor();
16
+ connectedCallback(): void;
17
+ disconnectedCallback(): void;
18
+ handleLanguageChange(e: CustomEvent): void;
13
19
  getTags(): string[];
14
20
  }
@@ -1,19 +1,14 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, html, LitElement } from 'lit';
3
3
  import { property, customElement, query, state } from 'lit/decorators.js';
4
+ import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
4
5
  import './rich-action';
5
6
  import { editorCommand } from './rich-action';
7
+ import { getTranslation } from '../lib/utils/translate';
6
8
  let RichToolbar = class RichToolbar extends LitElement {
7
- constructor() {
8
- super(...arguments);
9
- this.formatColor = '#000000';
10
- this.backgroundColor = '#000000';
11
- this.selection = null;
12
- }
13
9
  render() {
14
10
  const tags = this.getTags();
15
11
  return html `<header>
16
- <rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
17
12
  <rich-action icon="editor:format-bold" command="bold" ?active=${tags.includes('b')}></rich-action>
18
13
  <rich-action icon="editor:format-italic" command="italic" ?active=${tags.includes('i')}></rich-action>
19
14
  <rich-action icon="editor:format-underlined" command="underline" ?active=${tags.includes('u')}></rich-action>
@@ -49,8 +44,9 @@ let RichToolbar = class RichToolbar extends LitElement {
49
44
  <rich-action
50
45
  icon="editor:format-color-text"
51
46
  .color="${this.formatColor}"
52
- @action=${() => this.fgColorInput.click()}
47
+ @action=${() => editorCommand('forecolor', this.formatColor)}
53
48
  >
49
+ <etools-icon-button name="arrow-drop-down" @click="${() => this.fgColorInput.click()}"></etools-icon-button>
54
50
  <input
55
51
  type="color"
56
52
  id="fg-color"
@@ -62,10 +58,11 @@ let RichToolbar = class RichToolbar extends LitElement {
62
58
  />
63
59
  </rich-action>
64
60
  <rich-action
65
- icon="editor:border-color"
61
+ icon="editor:background-color"
66
62
  .color="${this.backgroundColor}"
67
- @action=${() => this.bdColorInput.click()}
63
+ @action=${() => editorCommand('backcolor', this.backgroundColor)}
68
64
  >
65
+ <etools-icon-button name="arrow-drop-down" @click="${() => this.bdColorInput.click()}"></etools-icon-button>
69
66
  <input
70
67
  type="color"
71
68
  id="bd-color"
@@ -80,38 +77,60 @@ let RichToolbar = class RichToolbar extends LitElement {
80
77
  icon="title"
81
78
  command="formatblock"
82
79
  .values=${[
83
- { name: 'Normal Text', value: '--' },
84
- { name: 'Heading 1', value: 'h1' },
85
- { name: 'Heading 2', value: 'h2' },
86
- { name: 'Heading 3', value: 'h3' },
87
- { name: 'Heading 4', value: 'h4' },
88
- { name: 'Heading 5', value: 'h5' },
89
- { name: 'Heading 6', value: 'h6' },
90
- { name: 'Paragraph', value: 'p' },
91
- { name: 'Pre-Formatted', value: 'pre' }
80
+ { name: getTranslation(this.language, 'NORMAL_TEXT'), value: '--' },
81
+ { name: getTranslation(this.language, 'HEADING1'), value: 'h1' },
82
+ { name: getTranslation(this.language, 'HEADING2'), value: 'h2' },
83
+ { name: getTranslation(this.language, 'HEADING3'), value: 'h3' },
84
+ { name: getTranslation(this.language, 'HEADING4'), value: 'h4' },
85
+ { name: getTranslation(this.language, 'HEADING5'), value: 'h5' },
86
+ { name: getTranslation(this.language, 'HEADING6'), value: 'h6' },
87
+ { name: getTranslation(this.language, 'PARAGRAPH'), value: 'p' },
88
+ { name: getTranslation(this.language, 'PRE_FORMATTED'), value: 'pre' }
92
89
  ]}
93
90
  ></rich-action>
94
91
  <rich-action
95
92
  icon="editor:format-size"
96
93
  command="fontsize"
97
94
  .values=${[
98
- { name: 'Font Size', value: '--' },
99
- { name: 'Very Small', value: '1' },
100
- { name: 'Small', value: '2' },
101
- { name: 'Normal', value: '3' },
102
- { name: 'Medium Large', value: '4' },
103
- { name: 'Large', value: '5' },
104
- { name: 'Very Large', value: '6' },
105
- { name: 'Maximum', value: '7' }
95
+ { name: getTranslation(this.language, 'FONT_SIZE'), value: '--' },
96
+ { name: getTranslation(this.language, 'VERY_SMALL'), value: '1' },
97
+ { name: getTranslation(this.language, 'SMALL'), value: '2' },
98
+ { name: getTranslation(this.language, 'NORMAL'), value: '3' },
99
+ { name: getTranslation(this.language, 'MEDIUM_LARGE'), value: '4' },
100
+ { name: getTranslation(this.language, 'LARGE'), value: '5' },
101
+ { name: getTranslation(this.language, 'VERY_LARGE'), value: '6' },
102
+ { name: getTranslation(this.language, 'MAXIMUM'), value: '7' }
106
103
  ]}
107
104
  ></rich-action>
108
105
  <rich-action icon="undo" command="undo"></rich-action>
109
106
  <rich-action icon="redo" command="redo"></rich-action>
107
+ <rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
110
108
  <!-- <rich-action icon="content_cut" command="cut"></rich-action> -->
111
109
  <!-- <rich-action icon="content_copy" command="copy"></rich-action>
112
110
  <rich-action icon="content_paste" command="paste"></rich-action> -->
113
111
  </header>`;
114
112
  }
113
+ constructor() {
114
+ super();
115
+ this.formatColor = '#000000';
116
+ this.backgroundColor = '#000000';
117
+ this.selection = null;
118
+ if (!this.language) {
119
+ this.language = window.EtoolsLanguage || 'en';
120
+ }
121
+ this.handleLanguageChange = this.handleLanguageChange.bind(this);
122
+ }
123
+ connectedCallback() {
124
+ super.connectedCallback();
125
+ document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
126
+ }
127
+ disconnectedCallback() {
128
+ super.disconnectedCallback();
129
+ document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
130
+ }
131
+ handleLanguageChange(e) {
132
+ this.language = e.detail.language;
133
+ }
115
134
  getTags() {
116
135
  var _a;
117
136
  let tags = [];
@@ -149,7 +168,7 @@ RichToolbar.styles = css `
149
168
  width: 100%;
150
169
  display: flex;
151
170
  flex-direction: row;
152
- align-items: center;
171
+ align-items: flex-end;
153
172
  justify-content: flex-start;
154
173
  padding-inline-start: 12px;
155
174
  flex-wrap: wrap;
@@ -188,6 +207,9 @@ __decorate([
188
207
  __decorate([
189
208
  property({ type: Object, hasChanged: () => true })
190
209
  ], RichToolbar.prototype, "selection", void 0);
210
+ __decorate([
211
+ property()
212
+ ], RichToolbar.prototype, "language", void 0);
191
213
  RichToolbar = __decorate([
192
214
  customElement('rich-toolbar')
193
215
  ], RichToolbar);
@@ -44,8 +44,10 @@ let RichViewer = class RichViewer extends LitElement {
44
44
  };
45
45
  RichViewer.styles = css `
46
46
  article {
47
- width: calc(100% - var(--rich-padding) * 2);
48
- height: calc(100% - var(--rich-padding) * 2);
47
+ width: calc(100% - 24px);
48
+ padding: 12px;
49
+ height: auto;
50
+ min-height: 60px;
49
51
  }
50
52
 
51
53
  article[contenteditable='true'] {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unicef-polymer/etools-form-builder",
3
3
  "description": "Etools FM Form Builder components",
4
- "version": "3.1.3",
4
+ "version": "3.1.5",
5
5
  "type": "module",
6
6
  "contributors": [
7
7
  "eTools Team"
@@ -32,14 +32,14 @@
32
32
  "typescript": "^4.9.5"
33
33
  },
34
34
  "peerDependencies": {
35
- "@unicef-polymer/etools-unicef": ">=1.2.0"
35
+ "@unicef-polymer/etools-unicef": ">=1.2.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@eslint/eslintrc": "^3.2.0",
39
39
  "@eslint/js": "^9.16.0",
40
40
  "@typescript-eslint/eslint-plugin": "^8.17.0",
41
41
  "@typescript-eslint/parser": "^8.17.0",
42
- "@unicef-polymer/etools-unicef": "^1.2.0",
42
+ "@unicef-polymer/etools-unicef": "^1.2.1",
43
43
  "eslint": "^9.16.0",
44
44
  "eslint-config-prettier": "^9.1.0",
45
45
  "eslint-plugin-html": "^8.1.2",