1 | /* |
2 | Copyright - 2017 2023 - wwwouaiebe - Contact: https://www.ouaie.be/ |
3 | |
4 | This program is free software; |
5 | you can redistribute it and/or modify it under the terms of the |
6 | GNU General Public License as published by the Free Software Foundation; |
7 | either version 3 of the License, or any later version. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | /* |
19 | Changes: |
20 | - v4.0.0: |
21 | - created from v3.6.0 |
22 | Doc reviewed 202208 |
23 | */ |
24 | |
25 | import theHTMLSanitizer from '../../../core/htmlSanitizer/HTMLSanitizer.js'; |
26 | |
27 | import { ICON_DIMENSIONS } from '../../../main/Constants.js'; |
28 | |
29 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
30 | /** |
31 | Simple container for predefined icons data of the NoteDialogToolbar |
32 | */ |
33 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
34 | |
35 | // eslint-disable-next-line no-unused-vars |
36 | class PredefinedIconData { |
37 | |
38 | /** |
39 | The name of the predefined icon. This name will be displayed in the select of the NoteDialogToolbar |
40 | @type {String} |
41 | */ |
42 | |
43 | #name; |
44 | |
45 | /** |
46 | The html definition of the predefined icon |
47 | @type {String} |
48 | */ |
49 | |
50 | #icon; |
51 | |
52 | /** |
53 | The tooltip of the predefined icon |
54 | @type {String} |
55 | */ |
56 | |
57 | #tooltip; |
58 | |
59 | /** |
60 | The width of the predefined icon |
61 | @type {Number} |
62 | */ |
63 | |
64 | #width; |
65 | |
66 | /** |
67 | The height of the predefined icon |
68 | @type {Number} |
69 | */ |
70 | |
71 | #height; |
72 | |
73 | /** |
74 | The constructor |
75 | @param {JsonObject} jsonPredefinedIconData A json object with the data for the predefined icon |
76 | */ |
77 | |
78 | constructor ( jsonPredefinedIconData ) { |
79 | this.#name = |
80 | 'string' === typeof ( jsonPredefinedIconData?.name ) |
81 | ? |
82 | theHTMLSanitizer.sanitizeToJsString ( jsonPredefinedIconData.name ) |
83 | : |
84 | '?'; |
85 | this.#icon = |
86 | 'string' === typeof ( jsonPredefinedIconData.icon ) |
87 | ? |
88 | theHTMLSanitizer.sanitizeToHtmlString ( jsonPredefinedIconData?.icon ).htmlString |
89 | : |
90 | '?'; |
91 | this.#tooltip = |
92 | 'string' === typeof ( jsonPredefinedIconData?.tooltip ) |
93 | ? |
94 | theHTMLSanitizer.sanitizeToHtmlString ( jsonPredefinedIconData.tooltip ).htmlString |
95 | : |
96 | '?'; |
97 | this.#width = |
98 | 'number' === typeof ( jsonPredefinedIconData?.width ) ? jsonPredefinedIconData.width : ICON_DIMENSIONS.width; |
99 | this.#height = |
100 | 'number' === typeof ( jsonPredefinedIconData?.height ) ? jsonPredefinedIconData.height : ICON_DIMENSIONS.height; |
101 | } |
102 | |
103 | /** |
104 | The name of the predefined icon. This name will be displayed in the select of the NoteDialog |
105 | @type {String} |
106 | */ |
107 | |
108 | get name ( ) { return this.#name; } |
109 | |
110 | /** |
111 | The html definition of the predefined icon |
112 | @type {String} |
113 | */ |
114 | |
115 | get icon ( ) { return this.#icon; } |
116 | |
117 | /** |
118 | The tooltip of the predefined icon |
119 | @type {String} |
120 | */ |
121 | |
122 | get tooltip ( ) { return this.#tooltip; } |
123 | |
124 | /** |
125 | The width of the predefined icon |
126 | @type {Number} |
127 | */ |
128 | |
129 | get width ( ) { return this.#width; } |
130 | |
131 | /** |
132 | The height of the predefined icon |
133 | @type {Number} |
134 | */ |
135 | |
136 | get height ( ) { return this.#height; } |
137 | |
138 | } |
139 | |
140 | export default PredefinedIconData; |
141 | |
142 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
143 |