rn-rich-text-editor 0.0.2 → 0.0.4
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.js +5 -1
- package/dist/RichToolbar.d.ts +1 -1
- package/dist/RichToolbar.js +42 -0
- package/dist/actions.d.ts +14 -0
- package/dist/actions.js +15 -1
- package/dist/editor/createHTML.js +52 -20
- package/dist/img/blockquote.png +0 -0
- package/dist/img/blockquote@2x.png +0 -0
- package/dist/img/blockquote@3x.png +0 -0
- package/dist/img/bold.png +0 -0
- package/dist/img/bold@2x.png +0 -0
- package/dist/img/bold@3x.png +0 -0
- package/dist/img/checkbox.png +0 -0
- package/dist/img/checkbox@2x.png +0 -0
- package/dist/img/checkbox@3x.png +0 -0
- package/dist/img/code.png +0 -0
- package/dist/img/code@2x.png +0 -0
- package/dist/img/code@3x.png +0 -0
- package/dist/img/fontSize.png +0 -0
- package/dist/img/fontSize@2x.png +0 -0
- package/dist/img/fontSize@3x.png +0 -0
- package/dist/img/heading1.png +0 -0
- package/dist/img/image.png +0 -0
- package/dist/img/image@2x.png +0 -0
- package/dist/img/image@3x.png +0 -0
- package/dist/img/indent.png +0 -0
- package/dist/img/indent@2x.png +0 -0
- package/dist/img/indent@3x.png +0 -0
- package/dist/img/italic.png +0 -0
- package/dist/img/italic@2x.png +0 -0
- package/dist/img/italic@3x.png +0 -0
- package/dist/img/justify_center.png +0 -0
- package/dist/img/justify_center@2x.png +0 -0
- package/dist/img/justify_center@3x.png +0 -0
- package/dist/img/justify_full.png +0 -0
- package/dist/img/justify_full@2x.png +0 -0
- package/dist/img/justify_full@3x.png +0 -0
- package/dist/img/justify_left.png +0 -0
- package/dist/img/justify_left@2x.png +0 -0
- package/dist/img/justify_left@3x.png +0 -0
- package/dist/img/justify_right.png +0 -0
- package/dist/img/justify_right@2x.png +0 -0
- package/dist/img/justify_right@3x.png +0 -0
- package/dist/img/keyboard.png +0 -0
- package/dist/img/keyboard@2x.png +0 -0
- package/dist/img/keyboard@3x.png +0 -0
- package/dist/img/line.png +0 -0
- package/dist/img/line@2x.png +0 -0
- package/dist/img/line@3x.png +0 -0
- package/dist/img/link.png +0 -0
- package/dist/img/link@2x.png +0 -0
- package/dist/img/link@3x.png +0 -0
- package/dist/img/ol.png +0 -0
- package/dist/img/ol@2x.png +0 -0
- package/dist/img/ol@3x.png +0 -0
- package/dist/img/outdent.png +0 -0
- package/dist/img/outdent@2x.png +0 -0
- package/dist/img/outdent@3x.png +0 -0
- package/dist/img/redo.png +0 -0
- package/dist/img/redo@2x.png +0 -0
- package/dist/img/redo@3x.png +0 -0
- package/dist/img/remove_format.png +0 -0
- package/dist/img/remove_format@2x.png +0 -0
- package/dist/img/remove_format@3x.png +0 -0
- package/dist/img/strikethrough.png +0 -0
- package/dist/img/strikethrough@2x.png +0 -0
- package/dist/img/strikethrough@3x.png +0 -0
- package/dist/img/subscript.png +0 -0
- package/dist/img/subscript@2x.png +0 -0
- package/dist/img/subscript@3x.png +0 -0
- package/dist/img/superscript.png +0 -0
- package/dist/img/superscript@2x.png +0 -0
- package/dist/img/superscript@3x.png +0 -0
- package/dist/img/table.png +0 -0
- package/dist/img/table@2x.png +0 -0
- package/dist/img/table@3x.png +0 -0
- package/dist/img/ul.png +0 -0
- package/dist/img/ul@2x.png +0 -0
- package/dist/img/ul@3x.png +0 -0
- package/dist/img/underline.png +0 -0
- package/dist/img/underline@2x.png +0 -0
- package/dist/img/underline@3x.png +0 -0
- package/dist/img/undo.png +0 -0
- package/dist/img/undo@2x.png +0 -0
- package/dist/img/undo@3x.png +0 -0
- package/dist/img/video.png +0 -0
- package/dist/img/video@2x.png +0 -0
- package/dist/img/video@3x.png +0 -0
- package/package.json +2 -2
package/dist/RichEditor.js
CHANGED
|
@@ -131,10 +131,14 @@ exports.RichEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
131
131
|
},
|
|
132
132
|
}));
|
|
133
133
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
134
|
-
react_1.default.createElement(react_native_webview_1.WebView, { ref: webRef, originWhitelist: ['*'], javaScriptEnabled: true, scrollEnabled: false, source: (0, createHTML_1.createHTML)(), onMessage: handleMessage, ...props.webViewProps }),
|
|
134
|
+
react_1.default.createElement(react_native_webview_1.WebView, { ref: webRef, originWhitelist: ['*'], javaScriptEnabled: true, scrollEnabled: false, source: (0, createHTML_1.createHTML)(), onMessage: handleMessage, style: [styles.editorWebView, props.style], ...props.webViewProps }),
|
|
135
135
|
react_native_1.Platform.OS === 'android' && (react_1.default.createElement(react_native_1.TextInput, { ref: inputRef, style: styles.hiddenInput }))));
|
|
136
136
|
});
|
|
137
137
|
const styles = react_native_1.StyleSheet.create({
|
|
138
|
+
editorWebView: {
|
|
139
|
+
minHeight: 150,
|
|
140
|
+
backgroundColor: '#fff',
|
|
141
|
+
},
|
|
138
142
|
hiddenInput: {
|
|
139
143
|
position: 'absolute',
|
|
140
144
|
width: 1,
|
package/dist/RichToolbar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const defaultActions: ("bold" | "italic" | "underline" | "checkboxList" | "link" | "keyboard")[];
|
|
2
|
+
export declare const defaultActions: ("bold" | "italic" | "underline" | "strikethrough" | "removeFormat" | "checkboxList" | "insertUnorderedList" | "insertOrderedList" | "blockquote" | "code" | "link" | "indent" | "outdent" | "justifyLeft" | "justifyCenter" | "justifyRight" | "justifyFull" | "undo" | "redo" | "keyboard")[];
|
|
3
3
|
interface RichToolbarProps {
|
|
4
4
|
editor?: {
|
|
5
5
|
current: any;
|
package/dist/RichToolbar.js
CHANGED
|
@@ -40,10 +40,24 @@ const react_native_1 = require("react-native");
|
|
|
40
40
|
const actions_1 = require("./actions");
|
|
41
41
|
exports.defaultActions = [
|
|
42
42
|
actions_1.actions.keyboard,
|
|
43
|
+
actions_1.actions.undo,
|
|
44
|
+
actions_1.actions.redo,
|
|
43
45
|
actions_1.actions.setBold,
|
|
44
46
|
actions_1.actions.setItalic,
|
|
45
47
|
actions_1.actions.setUnderline,
|
|
48
|
+
actions_1.actions.strikethrough,
|
|
49
|
+
actions_1.actions.removeFormat,
|
|
50
|
+
actions_1.actions.insertUnorderedList,
|
|
51
|
+
actions_1.actions.insertOrderedList,
|
|
46
52
|
actions_1.actions.checkboxList,
|
|
53
|
+
actions_1.actions.blockquote,
|
|
54
|
+
actions_1.actions.code,
|
|
55
|
+
actions_1.actions.indent,
|
|
56
|
+
actions_1.actions.outdent,
|
|
57
|
+
actions_1.actions.justifyLeft,
|
|
58
|
+
actions_1.actions.justifyCenter,
|
|
59
|
+
actions_1.actions.justifyRight,
|
|
60
|
+
actions_1.actions.justifyFull,
|
|
47
61
|
actions_1.actions.insertLink,
|
|
48
62
|
];
|
|
49
63
|
// Icons from img folder - direct require now that icons exist
|
|
@@ -52,8 +66,22 @@ function getDefaultIcon() {
|
|
|
52
66
|
[actions_1.actions.setBold]: require('./img/bold.png'),
|
|
53
67
|
[actions_1.actions.setItalic]: require('./img/italic.png'),
|
|
54
68
|
[actions_1.actions.setUnderline]: require('./img/underline.png'),
|
|
69
|
+
[actions_1.actions.strikethrough]: require('./img/strikethrough.png'),
|
|
70
|
+
[actions_1.actions.removeFormat]: require('./img/remove_format.png'),
|
|
55
71
|
[actions_1.actions.checkboxList]: require('./img/checkbox.png'),
|
|
72
|
+
[actions_1.actions.insertUnorderedList]: require('./img/ul.png'),
|
|
73
|
+
[actions_1.actions.insertOrderedList]: require('./img/ol.png'),
|
|
74
|
+
[actions_1.actions.blockquote]: require('./img/blockquote.png'),
|
|
75
|
+
[actions_1.actions.code]: require('./img/code.png'),
|
|
56
76
|
[actions_1.actions.insertLink]: require('./img/link.png'),
|
|
77
|
+
[actions_1.actions.indent]: require('./img/indent.png'),
|
|
78
|
+
[actions_1.actions.outdent]: require('./img/outdent.png'),
|
|
79
|
+
[actions_1.actions.justifyLeft]: require('./img/justify_left.png'),
|
|
80
|
+
[actions_1.actions.justifyCenter]: require('./img/justify_center.png'),
|
|
81
|
+
[actions_1.actions.justifyRight]: require('./img/justify_right.png'),
|
|
82
|
+
[actions_1.actions.justifyFull]: require('./img/justify_full.png'),
|
|
83
|
+
[actions_1.actions.undo]: require('./img/undo.png'),
|
|
84
|
+
[actions_1.actions.redo]: require('./img/redo.png'),
|
|
57
85
|
[actions_1.actions.keyboard]: require('./img/keyboard.png'),
|
|
58
86
|
};
|
|
59
87
|
}
|
|
@@ -127,7 +155,21 @@ function RichToolbar({ editor, getEditor, actions: actionsProp = exports.default
|
|
|
127
155
|
case actions_1.actions.setBold:
|
|
128
156
|
case actions_1.actions.setItalic:
|
|
129
157
|
case actions_1.actions.setUnderline:
|
|
158
|
+
case actions_1.actions.strikethrough:
|
|
159
|
+
case actions_1.actions.removeFormat:
|
|
130
160
|
case actions_1.actions.checkboxList:
|
|
161
|
+
case actions_1.actions.insertUnorderedList:
|
|
162
|
+
case actions_1.actions.insertOrderedList:
|
|
163
|
+
case actions_1.actions.blockquote:
|
|
164
|
+
case actions_1.actions.code:
|
|
165
|
+
case actions_1.actions.indent:
|
|
166
|
+
case actions_1.actions.outdent:
|
|
167
|
+
case actions_1.actions.justifyLeft:
|
|
168
|
+
case actions_1.actions.justifyCenter:
|
|
169
|
+
case actions_1.actions.justifyRight:
|
|
170
|
+
case actions_1.actions.justifyFull:
|
|
171
|
+
case actions_1.actions.undo:
|
|
172
|
+
case actions_1.actions.redo:
|
|
131
173
|
(_c = editorInstance.showAndroidKeyboard) === null || _c === void 0 ? void 0 : _c.call(editorInstance);
|
|
132
174
|
(_d = editorInstance.sendAction) === null || _d === void 0 ? void 0 : _d.call(editorInstance, action);
|
|
133
175
|
break;
|
package/dist/actions.d.ts
CHANGED
|
@@ -2,8 +2,22 @@ export declare const actions: {
|
|
|
2
2
|
readonly setBold: "bold";
|
|
3
3
|
readonly setItalic: "italic";
|
|
4
4
|
readonly setUnderline: "underline";
|
|
5
|
+
readonly strikethrough: "strikethrough";
|
|
6
|
+
readonly removeFormat: "removeFormat";
|
|
5
7
|
readonly checkboxList: "checkboxList";
|
|
8
|
+
readonly insertUnorderedList: "insertUnorderedList";
|
|
9
|
+
readonly insertOrderedList: "insertOrderedList";
|
|
10
|
+
readonly blockquote: "blockquote";
|
|
11
|
+
readonly code: "code";
|
|
6
12
|
readonly insertLink: "link";
|
|
13
|
+
readonly indent: "indent";
|
|
14
|
+
readonly outdent: "outdent";
|
|
15
|
+
readonly justifyLeft: "justifyLeft";
|
|
16
|
+
readonly justifyCenter: "justifyCenter";
|
|
17
|
+
readonly justifyRight: "justifyRight";
|
|
18
|
+
readonly justifyFull: "justifyFull";
|
|
19
|
+
readonly undo: "undo";
|
|
20
|
+
readonly redo: "redo";
|
|
7
21
|
readonly keyboard: "keyboard";
|
|
8
22
|
readonly init: "init";
|
|
9
23
|
};
|
package/dist/actions.js
CHANGED
|
@@ -5,8 +5,22 @@ exports.actions = {
|
|
|
5
5
|
setBold: 'bold',
|
|
6
6
|
setItalic: 'italic',
|
|
7
7
|
setUnderline: 'underline',
|
|
8
|
+
strikethrough: 'strikethrough',
|
|
9
|
+
removeFormat: 'removeFormat',
|
|
8
10
|
checkboxList: 'checkboxList',
|
|
11
|
+
insertUnorderedList: 'insertUnorderedList',
|
|
12
|
+
insertOrderedList: 'insertOrderedList',
|
|
13
|
+
blockquote: 'blockquote',
|
|
14
|
+
code: 'code',
|
|
9
15
|
insertLink: 'link',
|
|
16
|
+
indent: 'indent',
|
|
17
|
+
outdent: 'outdent',
|
|
18
|
+
justifyLeft: 'justifyLeft',
|
|
19
|
+
justifyCenter: 'justifyCenter',
|
|
20
|
+
justifyRight: 'justifyRight',
|
|
21
|
+
justifyFull: 'justifyFull',
|
|
22
|
+
undo: 'undo',
|
|
23
|
+
redo: 'redo',
|
|
10
24
|
keyboard: 'keyboard',
|
|
11
|
-
init: 'init'
|
|
25
|
+
init: 'init',
|
|
12
26
|
};
|
|
@@ -10,11 +10,19 @@ function createHTML() {
|
|
|
10
10
|
<head>
|
|
11
11
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
12
12
|
<style>
|
|
13
|
-
body {
|
|
13
|
+
html, body {
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
font-family: system-ui;
|
|
17
|
+
min-height: 200px;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
14
20
|
#editor {
|
|
15
21
|
padding: 12px;
|
|
16
|
-
min-height:
|
|
22
|
+
min-height: 150px;
|
|
17
23
|
outline: none;
|
|
24
|
+
-webkit-user-select: text;
|
|
25
|
+
user-select: text;
|
|
18
26
|
}
|
|
19
27
|
[placeholder]:empty::before {
|
|
20
28
|
content: attr(placeholder);
|
|
@@ -59,11 +67,48 @@ ${(0, contentCSS_1.getContentCSS)()}
|
|
|
59
67
|
window.addEventListener('message', e => {
|
|
60
68
|
const msg = JSON.parse(e.data);
|
|
61
69
|
const type = msg.type;
|
|
62
|
-
|
|
63
|
-
if (type === '
|
|
64
|
-
|
|
65
|
-
else if (type === '
|
|
66
|
-
|
|
70
|
+
|
|
71
|
+
if (type === 'focus') {
|
|
72
|
+
editor.focus();
|
|
73
|
+
} else if (type === 'blur') {
|
|
74
|
+
editor.blur();
|
|
75
|
+
} else if (type === 'bold') {
|
|
76
|
+
document.execCommand('bold');
|
|
77
|
+
} else if (type === 'italic') {
|
|
78
|
+
document.execCommand('italic');
|
|
79
|
+
} else if (type === 'underline') {
|
|
80
|
+
document.execCommand('underline');
|
|
81
|
+
} else if (type === 'strikethrough') {
|
|
82
|
+
document.execCommand('strikeThrough');
|
|
83
|
+
} else if (type === 'removeFormat') {
|
|
84
|
+
document.execCommand('removeFormat');
|
|
85
|
+
} else if (type === 'undo') {
|
|
86
|
+
document.execCommand('undo');
|
|
87
|
+
} else if (type === 'redo') {
|
|
88
|
+
document.execCommand('redo');
|
|
89
|
+
} else if (type === 'insertUnorderedList') {
|
|
90
|
+
document.execCommand('insertUnorderedList');
|
|
91
|
+
} else if (type === 'insertOrderedList') {
|
|
92
|
+
document.execCommand('insertOrderedList');
|
|
93
|
+
} else if (type === 'checkboxList') {
|
|
94
|
+
document.execCommand('insertOrderedList');
|
|
95
|
+
} else if (type === 'indent') {
|
|
96
|
+
document.execCommand('indent');
|
|
97
|
+
} else if (type === 'outdent') {
|
|
98
|
+
document.execCommand('outdent');
|
|
99
|
+
} else if (type === 'justifyLeft') {
|
|
100
|
+
document.execCommand('justifyLeft');
|
|
101
|
+
} else if (type === 'justifyCenter') {
|
|
102
|
+
document.execCommand('justifyCenter');
|
|
103
|
+
} else if (type === 'justifyRight') {
|
|
104
|
+
document.execCommand('justifyRight');
|
|
105
|
+
} else if (type === 'justifyFull') {
|
|
106
|
+
document.execCommand('justifyFull');
|
|
107
|
+
} else if (type === 'blockquote') {
|
|
108
|
+
document.execCommand('formatBlock', false, 'blockquote');
|
|
109
|
+
} else if (type === 'code') {
|
|
110
|
+
document.execCommand('formatBlock', false, 'pre');
|
|
111
|
+
} else if (type === 'link') {
|
|
67
112
|
const url = prompt('Enter link URL:');
|
|
68
113
|
if (url) {
|
|
69
114
|
const sel = window.getSelection();
|
|
@@ -75,19 +120,6 @@ ${(0, contentCSS_1.getContentCSS)()}
|
|
|
75
120
|
range.insertNode(link);
|
|
76
121
|
}
|
|
77
122
|
}
|
|
78
|
-
else if (type === 'checkboxList') {
|
|
79
|
-
if (document.queryCommandState('insertOrderedList')) {
|
|
80
|
-
document.execCommand('insertOrderedList');
|
|
81
|
-
} else {
|
|
82
|
-
document.execCommand('insertOrderedList');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else if (type === 'focus') {
|
|
86
|
-
editor.focus();
|
|
87
|
-
}
|
|
88
|
-
else if (type === 'blur') {
|
|
89
|
-
editor.blur();
|
|
90
|
-
}
|
|
91
123
|
});
|
|
92
124
|
</script>
|
|
93
125
|
</body>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/img/ol.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/img/ul.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rn-rich-text-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A rich text editor component for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"package.json"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "tsc",
|
|
24
|
+
"build": "tsc && cp -r src/img dist/",
|
|
25
25
|
"watch": "tsc -w"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|