rn-rich-text-editor 0.0.6 → 0.0.7
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/RichEditor.d.ts +1 -0
- package/dist/RichEditor.js +111 -105
- package/package.json +1 -1
package/dist/RichEditor.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface RichTextEditorRef {
|
|
|
24
24
|
dismissKeyboard: () => void;
|
|
25
25
|
getContentHtml: () => Promise<string>;
|
|
26
26
|
isKeyboardOpen: boolean;
|
|
27
|
+
sendAction: (action: string) => void;
|
|
27
28
|
}
|
|
28
29
|
export declare const RichTextEditor: any;
|
|
29
30
|
export default RichTextEditor;
|
package/dist/RichEditor.js
CHANGED
|
@@ -238,116 +238,122 @@ exports.RichTextEditor = (0, react_1.forwardRef)(function RichTextEditor({ conte
|
|
|
238
238
|
}
|
|
239
239
|
sendAction(actions_1.actions.init);
|
|
240
240
|
};
|
|
241
|
-
(0, react_1.useImperativeHandle)(ref, () =>
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
268
|
-
(_c = (_b = webRef.current) === null || _b === void 0 ? void 0 : _b.requestFocus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
269
|
-
}
|
|
270
|
-
sendAction(actions_1.actions.content, 'focus');
|
|
271
|
-
},
|
|
272
|
-
showAndroidKeyboard() {
|
|
273
|
-
var _a, _b, _c;
|
|
274
|
-
if (react_native_1.Platform.OS === 'android') {
|
|
275
|
-
if (!keyOpenRef.current)
|
|
276
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
277
|
-
(_c = (_b = webRef.current) === null || _b === void 0 ? void 0 : _b.requestFocus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
insertImage(attributes, styleOpt) {
|
|
281
|
-
sendAction(actions_1.actions.insertImage, 'result', attributes, styleOpt);
|
|
282
|
-
},
|
|
283
|
-
insertVideo(attributes, styleOpt) {
|
|
284
|
-
sendAction(actions_1.actions.insertVideo, 'result', attributes, styleOpt);
|
|
285
|
-
},
|
|
286
|
-
insertText(text) {
|
|
287
|
-
sendAction(actions_1.actions.insertText, 'result', text);
|
|
288
|
-
},
|
|
289
|
-
insertHTML(html) {
|
|
290
|
-
sendAction(actions_1.actions.insertHTML, 'result', html);
|
|
291
|
-
},
|
|
292
|
-
insertLink(title, url) {
|
|
293
|
-
var _a, _b, _c;
|
|
294
|
-
if (url) {
|
|
241
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
242
|
+
const postActionToWebView = sendAction;
|
|
243
|
+
return {
|
|
244
|
+
registerToolbar(listener) {
|
|
245
|
+
selectionChangeListeners.current = [...selectionChangeListeners.current, listener];
|
|
246
|
+
},
|
|
247
|
+
setContentFocusHandler(listener) {
|
|
248
|
+
focusListeners.current.push(listener);
|
|
249
|
+
},
|
|
250
|
+
setContentHTML(html) {
|
|
251
|
+
sendAction(actions_1.actions.content, 'setHtml', html);
|
|
252
|
+
},
|
|
253
|
+
setPlaceholder(placeholderText) {
|
|
254
|
+
sendAction(actions_1.actions.content, 'setPlaceholder', placeholderText);
|
|
255
|
+
},
|
|
256
|
+
setContentStyle(styles) {
|
|
257
|
+
sendAction(actions_1.actions.content, 'setContentStyle', styles);
|
|
258
|
+
},
|
|
259
|
+
setDisable(dis) {
|
|
260
|
+
sendAction(actions_1.actions.content, 'setDisable', !!dis);
|
|
261
|
+
},
|
|
262
|
+
blurContentEditor() {
|
|
263
|
+
sendAction(actions_1.actions.content, 'blur');
|
|
264
|
+
},
|
|
265
|
+
focusContentEditor() {
|
|
266
|
+
var _a, _b, _c;
|
|
295
267
|
if (react_native_1.Platform.OS === 'android') {
|
|
296
268
|
if (!keyOpenRef.current)
|
|
297
269
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
298
270
|
(_c = (_b = webRef.current) === null || _b === void 0 ? void 0 : _b.requestFocus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
299
271
|
}
|
|
300
|
-
sendAction(actions_1.actions.
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
272
|
+
sendAction(actions_1.actions.content, 'focus');
|
|
273
|
+
},
|
|
274
|
+
showAndroidKeyboard() {
|
|
275
|
+
var _a, _b, _c;
|
|
276
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
277
|
+
if (!keyOpenRef.current)
|
|
278
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
279
|
+
(_c = (_b = webRef.current) === null || _b === void 0 ? void 0 : _b.requestFocus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
insertImage(attributes, styleOpt) {
|
|
283
|
+
sendAction(actions_1.actions.insertImage, 'result', attributes, styleOpt);
|
|
284
|
+
},
|
|
285
|
+
insertVideo(attributes, styleOpt) {
|
|
286
|
+
sendAction(actions_1.actions.insertVideo, 'result', attributes, styleOpt);
|
|
287
|
+
},
|
|
288
|
+
insertText(text) {
|
|
289
|
+
sendAction(actions_1.actions.insertText, 'result', text);
|
|
290
|
+
},
|
|
291
|
+
insertHTML(html) {
|
|
292
|
+
sendAction(actions_1.actions.insertHTML, 'result', html);
|
|
293
|
+
},
|
|
294
|
+
insertLink(title, url) {
|
|
295
|
+
var _a, _b, _c;
|
|
296
|
+
if (url) {
|
|
297
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
298
|
+
if (!keyOpenRef.current)
|
|
299
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
300
|
+
(_c = (_b = webRef.current) === null || _b === void 0 ? void 0 : _b.requestFocus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
301
|
+
}
|
|
302
|
+
sendAction(actions_1.actions.insertLink, 'result', { title, url });
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
injectJavascript(script) {
|
|
306
|
+
var _a, _b;
|
|
307
|
+
return (_b = (_a = webRef.current) === null || _a === void 0 ? void 0 : _a.injectJavaScript) === null || _b === void 0 ? void 0 : _b.call(_a, script);
|
|
308
|
+
},
|
|
309
|
+
preCode(type) {
|
|
310
|
+
sendAction(actions_1.actions.code, 'result', type);
|
|
311
|
+
},
|
|
312
|
+
setFontSize(size) {
|
|
313
|
+
sendAction(actions_1.actions.fontSize, 'result', size);
|
|
314
|
+
},
|
|
315
|
+
setForeColor(color) {
|
|
316
|
+
sendAction(actions_1.actions.foreColor, 'result', color);
|
|
317
|
+
},
|
|
318
|
+
setHiliteColor(color) {
|
|
319
|
+
sendAction(actions_1.actions.hiliteColor, 'result', color);
|
|
320
|
+
},
|
|
321
|
+
setFontName(name) {
|
|
322
|
+
sendAction(actions_1.actions.fontName, 'result', name);
|
|
323
|
+
},
|
|
324
|
+
commandDOM(command) {
|
|
325
|
+
if (command)
|
|
326
|
+
sendAction(actions_1.actions.content, 'commandDOM', command);
|
|
327
|
+
},
|
|
328
|
+
command(command) {
|
|
329
|
+
if (command)
|
|
330
|
+
sendAction(actions_1.actions.content, 'command', command);
|
|
331
|
+
},
|
|
332
|
+
dismissKeyboard() {
|
|
333
|
+
if (focusRef.current)
|
|
334
|
+
sendAction(actions_1.actions.content, 'blur');
|
|
335
|
+
else
|
|
336
|
+
react_native_1.Keyboard.dismiss();
|
|
337
|
+
},
|
|
338
|
+
get isKeyboardOpen() {
|
|
339
|
+
return keyOpenRef.current;
|
|
340
|
+
},
|
|
341
|
+
getContentHtml() {
|
|
342
|
+
return new Promise((resolve, reject) => {
|
|
343
|
+
contentResolveRef.current = resolve;
|
|
344
|
+
contentRejectRef.current = reject;
|
|
345
|
+
postActionToWebView(actions_1.actions.content, 'postHtml');
|
|
346
|
+
pendingContentHtmlRef.current = setTimeout(() => {
|
|
347
|
+
if (contentRejectRef.current)
|
|
348
|
+
contentRejectRef.current('timeout');
|
|
349
|
+
}, 5000);
|
|
350
|
+
});
|
|
351
|
+
},
|
|
352
|
+
sendAction(action) {
|
|
353
|
+
postActionToWebView(action, 'result');
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
});
|
|
351
357
|
const onViewLayout = ({ nativeEvent: { layout } }) => {
|
|
352
358
|
layoutRef.current = layout;
|
|
353
359
|
};
|