@zohodesk/dot 1.0.0-temp-197.1 → 1.0.0-temp-197.3
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 +11 -0
- package/es/form/fields/TextEditor/TextEditor.js +11 -21
- package/es/form/fields/TextEditor/props/defaultProps.js +4 -3
- package/es/form/fields/TextEditor/props/propTypes.js +3 -3
- package/es/utils/editorUtils.js +4 -4
- package/es/v1/form/fields/TextEditor/TextEditor.js +13 -22
- package/es/v1/form/fields/TextEditor/props/defaultProps.js +4 -3
- package/es/v1/form/fields/TextEditor/props/propTypes.js +3 -3
- package/es/v1/utils/editorUtils.js +4 -4
- package/lib/form/fields/TextEditor/TextEditor.js +11 -21
- package/lib/form/fields/TextEditor/props/defaultProps.js +4 -3
- package/lib/form/fields/TextEditor/props/propTypes.js +3 -3
- package/lib/utils/editorUtils.js +4 -4
- package/lib/v1/form/fields/TextEditor/TextEditor.js +13 -22
- package/lib/v1/form/fields/TextEditor/props/defaultProps.js +4 -3
- package/lib/v1/form/fields/TextEditor/props/propTypes.js +3 -3
- package/lib/v1/utils/editorUtils.js +4 -4
- package/package.json +1 -1
- package/result.json +1 -1
- package/unittest/index.html +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
In this Library, we Provide Some Basic Components to Build Your Application
|
|
4
4
|
|
|
5
|
+
# 1.5.5
|
|
6
|
+
- **TextEditor (v0&v1)**
|
|
7
|
+
- `inlineImageProps={allowedFileExtensions, fileNameMaxCharacters, fileSizeMax}` props added.
|
|
8
|
+
- default props,
|
|
9
|
+
- `allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"]`
|
|
10
|
+
- `fileNameMaxCharacters: 200,`
|
|
11
|
+
- `fileSizeMax: 3 * 1024 * 1024`
|
|
12
|
+
- `customInitOptions` prop added, using this can initialize the editor details.
|
|
13
|
+
- `customCSS` prop suppported to customize the style to apply for editor, it adds css in style tag.
|
|
14
|
+
- In `handleUpload` method reverted the `TicketReply` editor specific case handle.
|
|
15
|
+
|
|
5
16
|
# 1.5.4
|
|
6
17
|
- **CheckBoxField (v0&v1)**
|
|
7
18
|
- children prop added.
|
|
@@ -224,18 +224,6 @@ export default class TextEditor extends Component {
|
|
|
224
224
|
global.editor[id] = editorObj;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
const css = `pre {white-space: pre-wrap}, ${customCSS}`,
|
|
228
|
-
head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
|
|
229
|
-
style = document.createElement('style');
|
|
230
|
-
style.type = 'text/css';
|
|
231
|
-
|
|
232
|
-
if (style.styleSheet) {
|
|
233
|
-
style.styleSheet.cssText = css;
|
|
234
|
-
} else {
|
|
235
|
-
style.appendChild(editorObj.doc.createTextNode(css));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
head.appendChild(style);
|
|
239
227
|
editorCallback && editorCallback(editorObj);
|
|
240
228
|
const iframe = selectn('iframe.contentDocument.body', editorObj) || null;
|
|
241
229
|
const iframeHead = selectn('iframe.contentDocument.head', editorObj) || null;
|
|
@@ -251,9 +239,11 @@ export default class TextEditor extends Component {
|
|
|
251
239
|
iframe.classList.add('scroll');
|
|
252
240
|
}
|
|
253
241
|
|
|
254
|
-
let
|
|
255
|
-
|
|
256
|
-
|
|
242
|
+
let customStyleTag = document.createElement('style');
|
|
243
|
+
const customizedCSS = `pre {white-space: pre-wrap} ${customCSS}`;
|
|
244
|
+
const fontCSS = `@font-face {font-family: 'ZohoPuviRegular';src: url('https://static.zohocdn.com/zohofonts/zohopuvi/4.0/Zoho_Puvi_Regular.woff2') format('woff2');font-style: normal;font-weight: normal;text-rendering: optimizeLegibility;font-display: swap}@font-face {font-family: Regular;src: url('https://static.zohocdn.com/webfonts/lato2regular/font.woff2') format('woff2');font-weight: 400;font-style: normal;font-display: swap}@font-face {font-family: 'RobotoRegular';font-weight: 400;font-style: normal;font-display: swa;src: url('https://static.zohocdn.com/webfonts/robotoregular/font.woff2')}`;
|
|
245
|
+
customStyleTag.innerText = `${customizedCSS} ${fontCSS}`;
|
|
246
|
+
iframeHead.appendChild(customStyleTag);
|
|
257
247
|
}
|
|
258
248
|
}
|
|
259
249
|
|
|
@@ -272,15 +262,15 @@ export default class TextEditor extends Component {
|
|
|
272
262
|
fileNameLimitExceed
|
|
273
263
|
} = i18nKeys;
|
|
274
264
|
const {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
265
|
+
allowedFileExtensions,
|
|
266
|
+
fileNameMaxCharacters,
|
|
267
|
+
fileSizeMax
|
|
278
268
|
} = inlineImageProps;
|
|
279
269
|
|
|
280
|
-
if (!isFileNameSizeInvalid(file.name,
|
|
270
|
+
if (!isFileNameSizeInvalid(file.name, fileNameMaxCharacters)) {
|
|
281
271
|
if (file.size != 0) {
|
|
282
|
-
if (file.size <=
|
|
283
|
-
if (isImageFormat(file.name,
|
|
272
|
+
if (file.size <= fileSizeMax) {
|
|
273
|
+
if (isImageFormat(file.name, allowedFileExtensions)) {
|
|
284
274
|
progress && progress(true);
|
|
285
275
|
this.handleUpload(file).then(res => {
|
|
286
276
|
successCallback(res);
|
|
@@ -10,9 +10,10 @@ export const defaultProps = {
|
|
|
10
10
|
isNightMode: false,
|
|
11
11
|
isReadOnly: false,
|
|
12
12
|
dataSelectorId: 'textEditor',
|
|
13
|
+
customCSS: '',
|
|
13
14
|
inlineImageProps: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
|
|
16
|
+
fileNameMaxCharacters: 200,
|
|
17
|
+
fileSizeMax: 3 * 1024 * 1024
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -46,8 +46,8 @@ export const propTypes = {
|
|
|
46
46
|
customInitOptions: PropTypes.object,
|
|
47
47
|
customCSS: PropTypes.string,
|
|
48
48
|
inlineImageProps: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
allowedFileExtensions: PropTypes.array,
|
|
50
|
+
fileNameMaxCharacters: PropTypes.number,
|
|
51
|
+
fileSizeMax: PropTypes.number
|
|
52
52
|
}
|
|
53
53
|
};
|
package/es/utils/editorUtils.js
CHANGED
|
@@ -47,12 +47,12 @@ export function encodeForHtml(str) {
|
|
|
47
47
|
return str;
|
|
48
48
|
} // attachment
|
|
49
49
|
|
|
50
|
-
export function isFileNameSizeInvalid(fileName,
|
|
51
|
-
return fileName.length >
|
|
50
|
+
export function isFileNameSizeInvalid(fileName, fileNameMaxCharacters) {
|
|
51
|
+
return fileName.length > fileNameMaxCharacters;
|
|
52
52
|
}
|
|
53
|
-
export function isImageFormat(fileName,
|
|
53
|
+
export function isImageFormat(fileName, allowedFileExtensions) {
|
|
54
54
|
let extension = getExtensionFromFileName(fileName);
|
|
55
|
-
const isValidExtension =
|
|
55
|
+
const isValidExtension = allowedFileExtensions.includes(extension);
|
|
56
56
|
return isValidExtension;
|
|
57
57
|
}
|
|
58
58
|
export function getExtensionFromFileName(fileName) {
|
|
@@ -203,7 +203,8 @@ export default class TextEditor extends Component {
|
|
|
203
203
|
let {
|
|
204
204
|
editorCallback,
|
|
205
205
|
getRef,
|
|
206
|
-
isCustomScroll
|
|
206
|
+
isCustomScroll,
|
|
207
|
+
customCSS
|
|
207
208
|
} = this.props;
|
|
208
209
|
this.setState({
|
|
209
210
|
isEditorLoad: true,
|
|
@@ -218,18 +219,6 @@ export default class TextEditor extends Component {
|
|
|
218
219
|
global.editor[id] = editorObj;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
const css = 'pre {white-space: pre-wrap}',
|
|
222
|
-
head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
|
|
223
|
-
style = document.createElement('style');
|
|
224
|
-
style.type = 'text/css';
|
|
225
|
-
|
|
226
|
-
if (style.styleSheet) {
|
|
227
|
-
style.styleSheet.cssText = css;
|
|
228
|
-
} else {
|
|
229
|
-
style.appendChild(editorObj.doc.createTextNode(css));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
head.appendChild(style);
|
|
233
222
|
editorCallback && editorCallback(editorObj);
|
|
234
223
|
const iframe = selectn('iframe.contentDocument.body', editorObj) || null;
|
|
235
224
|
const iframeHead = selectn('iframe.contentDocument.head', editorObj) || null;
|
|
@@ -245,9 +234,11 @@ export default class TextEditor extends Component {
|
|
|
245
234
|
iframe.classList.add('scroll');
|
|
246
235
|
}
|
|
247
236
|
|
|
248
|
-
let
|
|
249
|
-
|
|
250
|
-
|
|
237
|
+
let customStyleTag = document.createElement('style');
|
|
238
|
+
const customizedCSS = `pre {white-space: pre-wrap} ${customCSS}`;
|
|
239
|
+
const fontCSS = `@font-face {font-family: 'ZohoPuviRegular';src: url('https://static.zohocdn.com/zohofonts/zohopuvi/4.0/Zoho_Puvi_Regular.woff2') format('woff2');font-style: normal;font-weight: normal;text-rendering: optimizeLegibility;font-display: swap}@font-face {font-family: Regular;src: url('https://static.zohocdn.com/webfonts/lato2regular/font.woff2') format('woff2');font-weight: 400;font-style: normal;font-display: swap}@font-face {font-family: 'RobotoRegular';font-weight: 400;font-style: normal;font-display: swa;src: url('https://static.zohocdn.com/webfonts/robotoregular/font.woff2')}`;
|
|
240
|
+
customStyleTag.innerText = `${customizedCSS} ${fontCSS}`;
|
|
241
|
+
iframeHead.appendChild(customStyleTag);
|
|
251
242
|
}
|
|
252
243
|
}
|
|
253
244
|
|
|
@@ -266,15 +257,15 @@ export default class TextEditor extends Component {
|
|
|
266
257
|
fileNameLimitExceed
|
|
267
258
|
} = i18nKeys;
|
|
268
259
|
const {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
allowedFileExtensions,
|
|
261
|
+
fileNameMaxCharacters,
|
|
262
|
+
fileSizeMax
|
|
272
263
|
} = inlineImageProps;
|
|
273
264
|
|
|
274
|
-
if (!isFileNameSizeInvalid(file.name,
|
|
265
|
+
if (!isFileNameSizeInvalid(file.name, fileNameMaxCharacters)) {
|
|
275
266
|
if (file.size != 0) {
|
|
276
|
-
if (file.size <=
|
|
277
|
-
if (isImageFormat(file.name,
|
|
267
|
+
if (file.size <= fileSizeMax) {
|
|
268
|
+
if (isImageFormat(file.name, allowedFileExtensions)) {
|
|
278
269
|
progress && progress(true);
|
|
279
270
|
this.handleUpload(file).then(res => {
|
|
280
271
|
successCallback(res);
|
|
@@ -10,9 +10,10 @@ export const defaultProps = {
|
|
|
10
10
|
isNightMode: false,
|
|
11
11
|
isReadOnly: false,
|
|
12
12
|
dataSelectorId: 'textEditor',
|
|
13
|
+
customCSS: '',
|
|
13
14
|
inlineImageProps: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
|
|
16
|
+
fileNameMaxCharacters: 200,
|
|
17
|
+
fileSizeMax: 3 * 1024 * 1024
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -44,8 +44,8 @@ export const propTypes = {
|
|
|
44
44
|
toggleEdit: PropTypes.func,
|
|
45
45
|
dataSelectorId: PropTypes.string,
|
|
46
46
|
inlineImageProps: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
allowedFileExtensions: PropTypes.array,
|
|
48
|
+
fileNameMaxCharacters: PropTypes.number,
|
|
49
|
+
fileSizeMax: PropTypes.number
|
|
50
50
|
}
|
|
51
51
|
};
|
|
@@ -47,12 +47,12 @@ export function encodeForHtml(str) {
|
|
|
47
47
|
return str;
|
|
48
48
|
} // attachment
|
|
49
49
|
|
|
50
|
-
export function isFileNameSizeInvalid(fileName,
|
|
51
|
-
return fileName.length >
|
|
50
|
+
export function isFileNameSizeInvalid(fileName, fileNameMaxCharacters) {
|
|
51
|
+
return fileName.length > fileNameMaxCharacters;
|
|
52
52
|
}
|
|
53
|
-
export function isImageFormat(fileName,
|
|
53
|
+
export function isImageFormat(fileName, allowedFileExtensions) {
|
|
54
54
|
let extension = getExtensionFromFileName(fileName);
|
|
55
|
-
const isValidExtension =
|
|
55
|
+
const isValidExtension = allowedFileExtensions.includes(extension);
|
|
56
56
|
return isValidExtension;
|
|
57
57
|
}
|
|
58
58
|
export function getExtensionFromFileName(fileName) {
|
|
@@ -269,18 +269,6 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
269
269
|
global.editor[id] = editorObj;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
var css = "pre {white-space: pre-wrap}, ".concat(customCSS),
|
|
273
|
-
head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
|
|
274
|
-
style = document.createElement('style');
|
|
275
|
-
style.type = 'text/css';
|
|
276
|
-
|
|
277
|
-
if (style.styleSheet) {
|
|
278
|
-
style.styleSheet.cssText = css;
|
|
279
|
-
} else {
|
|
280
|
-
style.appendChild(editorObj.doc.createTextNode(css));
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
head.appendChild(style);
|
|
284
272
|
editorCallback && editorCallback(editorObj);
|
|
285
273
|
var iframe = (0, _selectn["default"])('iframe.contentDocument.body', editorObj) || null;
|
|
286
274
|
var iframeHead = (0, _selectn["default"])('iframe.contentDocument.head', editorObj) || null;
|
|
@@ -298,9 +286,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
298
286
|
iframe.classList.add('scroll');
|
|
299
287
|
}
|
|
300
288
|
|
|
301
|
-
var
|
|
302
|
-
|
|
303
|
-
|
|
289
|
+
var customStyleTag = document.createElement('style');
|
|
290
|
+
var customizedCSS = "pre {white-space: pre-wrap} ".concat(customCSS);
|
|
291
|
+
var fontCSS = "@font-face {font-family: 'ZohoPuviRegular';src: url('https://static.zohocdn.com/zohofonts/zohopuvi/4.0/Zoho_Puvi_Regular.woff2') format('woff2');font-style: normal;font-weight: normal;text-rendering: optimizeLegibility;font-display: swap}@font-face {font-family: Regular;src: url('https://static.zohocdn.com/webfonts/lato2regular/font.woff2') format('woff2');font-weight: 400;font-style: normal;font-display: swap}@font-face {font-family: 'RobotoRegular';font-weight: 400;font-style: normal;font-display: swa;src: url('https://static.zohocdn.com/webfonts/robotoregular/font.woff2')}";
|
|
292
|
+
customStyleTag.innerText = "".concat(customizedCSS, " ").concat(fontCSS);
|
|
293
|
+
iframeHead.appendChild(customStyleTag);
|
|
304
294
|
}
|
|
305
295
|
}
|
|
306
296
|
}, {
|
|
@@ -316,14 +306,14 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
316
306
|
fileSizeLimitExceed = i18nKeys.fileSizeLimitExceed,
|
|
317
307
|
fileEmptyError = i18nKeys.fileEmptyError,
|
|
318
308
|
fileNameLimitExceed = i18nKeys.fileNameLimitExceed;
|
|
319
|
-
var
|
|
320
|
-
|
|
321
|
-
|
|
309
|
+
var allowedFileExtensions = inlineImageProps.allowedFileExtensions,
|
|
310
|
+
fileNameMaxCharacters = inlineImageProps.fileNameMaxCharacters,
|
|
311
|
+
fileSizeMax = inlineImageProps.fileSizeMax;
|
|
322
312
|
|
|
323
|
-
if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name,
|
|
313
|
+
if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name, fileNameMaxCharacters)) {
|
|
324
314
|
if (file.size != 0) {
|
|
325
|
-
if (file.size <=
|
|
326
|
-
if ((0, _editorUtils.isImageFormat)(file.name,
|
|
315
|
+
if (file.size <= fileSizeMax) {
|
|
316
|
+
if ((0, _editorUtils.isImageFormat)(file.name, allowedFileExtensions)) {
|
|
327
317
|
progress && progress(true);
|
|
328
318
|
this.handleUpload(file).then(function (res) {
|
|
329
319
|
successCallback(res);
|
|
@@ -16,10 +16,11 @@ var defaultProps = {
|
|
|
16
16
|
isNightMode: false,
|
|
17
17
|
isReadOnly: false,
|
|
18
18
|
dataSelectorId: 'textEditor',
|
|
19
|
+
customCSS: '',
|
|
19
20
|
inlineImageProps: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
|
|
22
|
+
fileNameMaxCharacters: 200,
|
|
23
|
+
fileSizeMax: 3 * 1024 * 1024
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
exports.defaultProps = defaultProps;
|
|
@@ -56,9 +56,9 @@ var propTypes = {
|
|
|
56
56
|
customInitOptions: _propTypes["default"].object,
|
|
57
57
|
customCSS: _propTypes["default"].string,
|
|
58
58
|
inlineImageProps: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
allowedFileExtensions: _propTypes["default"].array,
|
|
60
|
+
fileNameMaxCharacters: _propTypes["default"].number,
|
|
61
|
+
fileSizeMax: _propTypes["default"].number
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
exports.propTypes = propTypes;
|
package/lib/utils/editorUtils.js
CHANGED
|
@@ -67,13 +67,13 @@ function encodeForHtml(str) {
|
|
|
67
67
|
} // attachment
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
function isFileNameSizeInvalid(fileName,
|
|
71
|
-
return fileName.length >
|
|
70
|
+
function isFileNameSizeInvalid(fileName, fileNameMaxCharacters) {
|
|
71
|
+
return fileName.length > fileNameMaxCharacters;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function isImageFormat(fileName,
|
|
74
|
+
function isImageFormat(fileName, allowedFileExtensions) {
|
|
75
75
|
var extension = getExtensionFromFileName(fileName);
|
|
76
|
-
var isValidExtension =
|
|
76
|
+
var isValidExtension = allowedFileExtensions.includes(extension);
|
|
77
77
|
return isValidExtension;
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -251,7 +251,8 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
251
251
|
var _this$props5 = this.props,
|
|
252
252
|
editorCallback = _this$props5.editorCallback,
|
|
253
253
|
getRef = _this$props5.getRef,
|
|
254
|
-
isCustomScroll = _this$props5.isCustomScroll
|
|
254
|
+
isCustomScroll = _this$props5.isCustomScroll,
|
|
255
|
+
customCSS = _this$props5.customCSS;
|
|
255
256
|
this.setState({
|
|
256
257
|
isEditorLoad: true,
|
|
257
258
|
isEditorShow: true
|
|
@@ -263,18 +264,6 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
263
264
|
global.editor[id] = editorObj;
|
|
264
265
|
}
|
|
265
266
|
|
|
266
|
-
var css = 'pre {white-space: pre-wrap}',
|
|
267
|
-
head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
|
|
268
|
-
style = document.createElement('style');
|
|
269
|
-
style.type = 'text/css';
|
|
270
|
-
|
|
271
|
-
if (style.styleSheet) {
|
|
272
|
-
style.styleSheet.cssText = css;
|
|
273
|
-
} else {
|
|
274
|
-
style.appendChild(editorObj.doc.createTextNode(css));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
head.appendChild(style);
|
|
278
267
|
editorCallback && editorCallback(editorObj);
|
|
279
268
|
var iframe = (0, _selectn["default"])('iframe.contentDocument.body', editorObj) || null;
|
|
280
269
|
var iframeHead = (0, _selectn["default"])('iframe.contentDocument.head', editorObj) || null;
|
|
@@ -292,9 +281,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
292
281
|
iframe.classList.add('scroll');
|
|
293
282
|
}
|
|
294
283
|
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
284
|
+
var customStyleTag = document.createElement('style');
|
|
285
|
+
var customizedCSS = "pre {white-space: pre-wrap} ".concat(customCSS);
|
|
286
|
+
var fontCSS = "@font-face {font-family: 'ZohoPuviRegular';src: url('https://static.zohocdn.com/zohofonts/zohopuvi/4.0/Zoho_Puvi_Regular.woff2') format('woff2');font-style: normal;font-weight: normal;text-rendering: optimizeLegibility;font-display: swap}@font-face {font-family: Regular;src: url('https://static.zohocdn.com/webfonts/lato2regular/font.woff2') format('woff2');font-weight: 400;font-style: normal;font-display: swap}@font-face {font-family: 'RobotoRegular';font-weight: 400;font-style: normal;font-display: swa;src: url('https://static.zohocdn.com/webfonts/robotoregular/font.woff2')}";
|
|
287
|
+
customStyleTag.innerText = "".concat(customizedCSS, " ").concat(fontCSS);
|
|
288
|
+
iframeHead.appendChild(customStyleTag);
|
|
298
289
|
}
|
|
299
290
|
}
|
|
300
291
|
}, {
|
|
@@ -310,14 +301,14 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
310
301
|
fileSizeLimitExceed = i18nKeys.fileSizeLimitExceed,
|
|
311
302
|
fileEmptyError = i18nKeys.fileEmptyError,
|
|
312
303
|
fileNameLimitExceed = i18nKeys.fileNameLimitExceed;
|
|
313
|
-
var
|
|
314
|
-
|
|
315
|
-
|
|
304
|
+
var allowedFileExtensions = inlineImageProps.allowedFileExtensions,
|
|
305
|
+
fileNameMaxCharacters = inlineImageProps.fileNameMaxCharacters,
|
|
306
|
+
fileSizeMax = inlineImageProps.fileSizeMax;
|
|
316
307
|
|
|
317
|
-
if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name,
|
|
308
|
+
if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name, fileNameMaxCharacters)) {
|
|
318
309
|
if (file.size != 0) {
|
|
319
|
-
if (file.size <=
|
|
320
|
-
if ((0, _editorUtils.isImageFormat)(file.name,
|
|
310
|
+
if (file.size <= fileSizeMax) {
|
|
311
|
+
if ((0, _editorUtils.isImageFormat)(file.name, allowedFileExtensions)) {
|
|
321
312
|
progress && progress(true);
|
|
322
313
|
this.handleUpload(file).then(function (res) {
|
|
323
314
|
successCallback(res);
|
|
@@ -16,10 +16,11 @@ var defaultProps = {
|
|
|
16
16
|
isNightMode: false,
|
|
17
17
|
isReadOnly: false,
|
|
18
18
|
dataSelectorId: 'textEditor',
|
|
19
|
+
customCSS: '',
|
|
19
20
|
inlineImageProps: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
|
|
22
|
+
fileNameMaxCharacters: 200,
|
|
23
|
+
fileSizeMax: 3 * 1024 * 1024
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
exports.defaultProps = defaultProps;
|
|
@@ -54,9 +54,9 @@ var propTypes = {
|
|
|
54
54
|
toggleEdit: _propTypes["default"].func,
|
|
55
55
|
dataSelectorId: _propTypes["default"].string,
|
|
56
56
|
inlineImageProps: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
allowedFileExtensions: _propTypes["default"].array,
|
|
58
|
+
fileNameMaxCharacters: _propTypes["default"].number,
|
|
59
|
+
fileSizeMax: _propTypes["default"].number
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
exports.propTypes = propTypes;
|
|
@@ -67,13 +67,13 @@ function encodeForHtml(str) {
|
|
|
67
67
|
} // attachment
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
function isFileNameSizeInvalid(fileName,
|
|
71
|
-
return fileName.length >
|
|
70
|
+
function isFileNameSizeInvalid(fileName, fileNameMaxCharacters) {
|
|
71
|
+
return fileName.length > fileNameMaxCharacters;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function isImageFormat(fileName,
|
|
74
|
+
function isImageFormat(fileName, allowedFileExtensions) {
|
|
75
75
|
var extension = getExtensionFromFileName(fileName);
|
|
76
|
-
var isValidExtension =
|
|
76
|
+
var isValidExtension = allowedFileExtensions.includes(extension);
|
|
77
77
|
return isValidExtension;
|
|
78
78
|
}
|
|
79
79
|
|