@apollohg/react-native-prose-editor 0.1.0
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/LICENSE +160 -0
- package/README.md +143 -0
- package/android/build.gradle +39 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
- package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +131 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +1057 -0
- package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +14 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +191 -0
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +325 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +647 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +257 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +714 -0
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +76 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +1044 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +211 -0
- package/expo-module.config.json +9 -0
- package/ios/EditorAddons.swift +228 -0
- package/ios/EditorCore.xcframework/Info.plist +44 -0
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/EditorLayoutManager.swift +254 -0
- package/ios/EditorTheme.swift +372 -0
- package/ios/Generated_editor_core.swift +1143 -0
- package/ios/NativeEditorExpoView.swift +1417 -0
- package/ios/NativeEditorModule.swift +263 -0
- package/ios/PositionBridge.swift +278 -0
- package/ios/ReactNativeProseEditor.podspec +49 -0
- package/ios/RenderBridge.swift +825 -0
- package/ios/RichTextEditorView.swift +1559 -0
- package/ios/editor_coreFFI/editor_coreFFI.h +1014 -0
- package/ios/editor_coreFFI/module.modulemap +7 -0
- package/ios/editor_coreFFI.h +904 -0
- package/ios/editor_coreFFI.modulemap +7 -0
- package/package.json +66 -0
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +2014 -0
- package/src/EditorTheme.ts +130 -0
- package/src/EditorToolbar.tsx +620 -0
- package/src/NativeEditorBridge.ts +607 -0
- package/src/NativeRichTextEditor.tsx +951 -0
- package/src/addons.ts +158 -0
- package/src/index.ts +63 -0
- package/src/schemas.ts +153 -0
- package/src/useNativeEditor.ts +173 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
package com.apollohg.editor
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import uniffi.editor_core.*
|
|
6
|
+
|
|
7
|
+
class NativeEditorModule : Module() {
|
|
8
|
+
override fun definition() = ModuleDefinition {
|
|
9
|
+
Name("NativeEditor")
|
|
10
|
+
|
|
11
|
+
Function("editorCreate") { configJson: String ->
|
|
12
|
+
editorCreate(configJson).toLong()
|
|
13
|
+
}
|
|
14
|
+
Function("editorDestroy") { id: Int ->
|
|
15
|
+
editorDestroy(id.toULong())
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Function("editorSetHtml") { id: Int, html: String ->
|
|
19
|
+
editorSetHtml(id.toULong(), html)
|
|
20
|
+
}
|
|
21
|
+
Function("editorGetHtml") { id: Int ->
|
|
22
|
+
editorGetHtml(id.toULong())
|
|
23
|
+
}
|
|
24
|
+
Function("editorSetJson") { id: Int, json: String ->
|
|
25
|
+
editorSetJson(id.toULong(), json)
|
|
26
|
+
}
|
|
27
|
+
Function("editorGetJson") { id: Int ->
|
|
28
|
+
editorGetJson(id.toULong())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Function("editorInsertText") { id: Int, pos: Int, text: String ->
|
|
32
|
+
editorInsertText(id.toULong(), pos.toUInt(), text)
|
|
33
|
+
}
|
|
34
|
+
Function("editorReplaceSelectionText") { id: Int, text: String ->
|
|
35
|
+
editorReplaceSelectionText(id.toULong(), text)
|
|
36
|
+
}
|
|
37
|
+
Function("editorDeleteRange") { id: Int, from: Int, to: Int ->
|
|
38
|
+
editorDeleteRange(id.toULong(), from.toUInt(), to.toUInt())
|
|
39
|
+
}
|
|
40
|
+
Function("editorSplitBlock") { id: Int, pos: Int ->
|
|
41
|
+
editorSplitBlock(id.toULong(), pos.toUInt())
|
|
42
|
+
}
|
|
43
|
+
Function("editorInsertContentHtml") { id: Int, html: String ->
|
|
44
|
+
editorInsertContentHtml(id.toULong(), html)
|
|
45
|
+
}
|
|
46
|
+
Function("editorReplaceHtml") { id: Int, html: String ->
|
|
47
|
+
editorReplaceHtml(id.toULong(), html)
|
|
48
|
+
}
|
|
49
|
+
Function("editorReplaceJson") { id: Int, json: String ->
|
|
50
|
+
editorReplaceJson(id.toULong(), json)
|
|
51
|
+
}
|
|
52
|
+
Function("editorInsertContentJson") { id: Int, json: String ->
|
|
53
|
+
editorInsertContentJson(id.toULong(), json)
|
|
54
|
+
}
|
|
55
|
+
Function(
|
|
56
|
+
"editorInsertContentJsonAtSelectionScalar"
|
|
57
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int, json: String ->
|
|
58
|
+
editorInsertContentJsonAtSelectionScalar(
|
|
59
|
+
id.toULong(),
|
|
60
|
+
scalarAnchor.toUInt(),
|
|
61
|
+
scalarHead.toUInt(),
|
|
62
|
+
json
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
Function("editorWrapInList") { id: Int, listType: String ->
|
|
66
|
+
editorWrapInList(id.toULong(), listType)
|
|
67
|
+
}
|
|
68
|
+
Function("editorUnwrapFromList") { id: Int ->
|
|
69
|
+
editorUnwrapFromList(id.toULong())
|
|
70
|
+
}
|
|
71
|
+
Function("editorIndentListItem") { id: Int ->
|
|
72
|
+
editorIndentListItem(id.toULong())
|
|
73
|
+
}
|
|
74
|
+
Function("editorOutdentListItem") { id: Int ->
|
|
75
|
+
editorOutdentListItem(id.toULong())
|
|
76
|
+
}
|
|
77
|
+
Function("editorInsertNode") { id: Int, nodeType: String ->
|
|
78
|
+
editorInsertNode(id.toULong(), nodeType)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Function("editorInsertTextScalar") { id: Int, scalarPos: Int, text: String ->
|
|
82
|
+
editorInsertTextScalar(id.toULong(), scalarPos.toUInt(), text)
|
|
83
|
+
}
|
|
84
|
+
Function("editorDeleteScalarRange") { id: Int, scalarFrom: Int, scalarTo: Int ->
|
|
85
|
+
editorDeleteScalarRange(id.toULong(), scalarFrom.toUInt(), scalarTo.toUInt())
|
|
86
|
+
}
|
|
87
|
+
Function("editorReplaceTextScalar") { id: Int, scalarFrom: Int, scalarTo: Int, text: String ->
|
|
88
|
+
editorReplaceTextScalar(id.toULong(), scalarFrom.toUInt(), scalarTo.toUInt(), text)
|
|
89
|
+
}
|
|
90
|
+
Function("editorSplitBlockScalar") { id: Int, scalarPos: Int ->
|
|
91
|
+
editorSplitBlockScalar(id.toULong(), scalarPos.toUInt())
|
|
92
|
+
}
|
|
93
|
+
Function("editorDeleteAndSplitScalar") { id: Int, scalarFrom: Int, scalarTo: Int ->
|
|
94
|
+
editorDeleteAndSplitScalar(id.toULong(), scalarFrom.toUInt(), scalarTo.toUInt())
|
|
95
|
+
}
|
|
96
|
+
Function(
|
|
97
|
+
"editorToggleMarkAtSelectionScalar"
|
|
98
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int, markName: String ->
|
|
99
|
+
editorToggleMarkAtSelectionScalar(
|
|
100
|
+
id.toULong(),
|
|
101
|
+
scalarAnchor.toUInt(),
|
|
102
|
+
scalarHead.toUInt(),
|
|
103
|
+
markName
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
Function(
|
|
107
|
+
"editorWrapInListAtSelectionScalar"
|
|
108
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int, listType: String ->
|
|
109
|
+
editorWrapInListAtSelectionScalar(
|
|
110
|
+
id.toULong(),
|
|
111
|
+
scalarAnchor.toUInt(),
|
|
112
|
+
scalarHead.toUInt(),
|
|
113
|
+
listType
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
Function(
|
|
117
|
+
"editorUnwrapFromListAtSelectionScalar"
|
|
118
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int ->
|
|
119
|
+
editorUnwrapFromListAtSelectionScalar(
|
|
120
|
+
id.toULong(),
|
|
121
|
+
scalarAnchor.toUInt(),
|
|
122
|
+
scalarHead.toUInt()
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
Function(
|
|
126
|
+
"editorIndentListItemAtSelectionScalar"
|
|
127
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int ->
|
|
128
|
+
editorIndentListItemAtSelectionScalar(
|
|
129
|
+
id.toULong(),
|
|
130
|
+
scalarAnchor.toUInt(),
|
|
131
|
+
scalarHead.toUInt()
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
Function(
|
|
135
|
+
"editorOutdentListItemAtSelectionScalar"
|
|
136
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int ->
|
|
137
|
+
editorOutdentListItemAtSelectionScalar(
|
|
138
|
+
id.toULong(),
|
|
139
|
+
scalarAnchor.toUInt(),
|
|
140
|
+
scalarHead.toUInt()
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
Function(
|
|
144
|
+
"editorInsertNodeAtSelectionScalar"
|
|
145
|
+
) { id: Int, scalarAnchor: Int, scalarHead: Int, nodeType: String ->
|
|
146
|
+
editorInsertNodeAtSelectionScalar(
|
|
147
|
+
id.toULong(),
|
|
148
|
+
scalarAnchor.toUInt(),
|
|
149
|
+
scalarHead.toUInt(),
|
|
150
|
+
nodeType
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Function("editorToggleMark") { id: Int, markName: String ->
|
|
155
|
+
editorToggleMark(id.toULong(), markName)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Function("editorSetSelection") { id: Int, anchor: Int, head: Int ->
|
|
159
|
+
editorSetSelection(id.toULong(), anchor.toUInt(), head.toUInt())
|
|
160
|
+
}
|
|
161
|
+
Function("editorSetSelectionScalar") { id: Int, scalarAnchor: Int, scalarHead: Int ->
|
|
162
|
+
editorSetSelectionScalar(id.toULong(), scalarAnchor.toUInt(), scalarHead.toUInt())
|
|
163
|
+
}
|
|
164
|
+
Function("editorGetSelection") { id: Int ->
|
|
165
|
+
editorGetSelection(id.toULong())
|
|
166
|
+
}
|
|
167
|
+
Function("editorDocToScalar") { id: Int, docPos: Int ->
|
|
168
|
+
editorDocToScalar(id.toULong(), docPos.toUInt()).toInt()
|
|
169
|
+
}
|
|
170
|
+
Function("editorScalarToDoc") { id: Int, scalar: Int ->
|
|
171
|
+
editorScalarToDoc(id.toULong(), scalar.toUInt()).toInt()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Function("editorGetCurrentState") { id: Int ->
|
|
175
|
+
editorGetCurrentState(id.toULong())
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
Function("editorUndo") { id: Int ->
|
|
179
|
+
editorUndo(id.toULong())
|
|
180
|
+
}
|
|
181
|
+
Function("editorRedo") { id: Int ->
|
|
182
|
+
editorRedo(id.toULong())
|
|
183
|
+
}
|
|
184
|
+
Function("editorCanUndo") { id: Int ->
|
|
185
|
+
editorCanUndo(id.toULong())
|
|
186
|
+
}
|
|
187
|
+
Function("editorCanRedo") { id: Int ->
|
|
188
|
+
editorCanRedo(id.toULong())
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
View(NativeEditorExpoView::class) {
|
|
192
|
+
Events(
|
|
193
|
+
"onEditorUpdate",
|
|
194
|
+
"onSelectionChange",
|
|
195
|
+
"onFocusChange",
|
|
196
|
+
"onContentHeightChange",
|
|
197
|
+
"onToolbarAction",
|
|
198
|
+
"onAddonEvent"
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
Prop("editorId") { view: NativeEditorExpoView, id: Int ->
|
|
202
|
+
view.setEditorId(id.toLong())
|
|
203
|
+
}
|
|
204
|
+
Prop("editable") { view: NativeEditorExpoView, editable: Boolean ->
|
|
205
|
+
view.richTextView.editorEditText.isEditable = editable
|
|
206
|
+
}
|
|
207
|
+
Prop("placeholder") { view: NativeEditorExpoView, placeholder: String ->
|
|
208
|
+
view.richTextView.editorEditText.hint = placeholder
|
|
209
|
+
}
|
|
210
|
+
Prop("autoFocus") { view: NativeEditorExpoView, autoFocus: Boolean ->
|
|
211
|
+
view.setAutoFocus(autoFocus)
|
|
212
|
+
}
|
|
213
|
+
Prop("showToolbar") { view: NativeEditorExpoView, showToolbar: Boolean ->
|
|
214
|
+
view.setShowToolbar(showToolbar)
|
|
215
|
+
}
|
|
216
|
+
Prop("toolbarPlacement") { view: NativeEditorExpoView, toolbarPlacement: String? ->
|
|
217
|
+
view.setToolbarPlacement(toolbarPlacement)
|
|
218
|
+
}
|
|
219
|
+
Prop("heightBehavior") { view: NativeEditorExpoView, heightBehavior: String ->
|
|
220
|
+
view.setHeightBehavior(heightBehavior)
|
|
221
|
+
}
|
|
222
|
+
Prop("themeJson") { view: NativeEditorExpoView, themeJson: String? ->
|
|
223
|
+
view.setThemeJson(themeJson)
|
|
224
|
+
}
|
|
225
|
+
Prop("addonsJson") { view: NativeEditorExpoView, addonsJson: String? ->
|
|
226
|
+
view.setAddonsJson(addonsJson)
|
|
227
|
+
}
|
|
228
|
+
Prop("toolbarItemsJson") { view: NativeEditorExpoView, toolbarItemsJson: String? ->
|
|
229
|
+
view.setToolbarItemsJson(toolbarItemsJson)
|
|
230
|
+
}
|
|
231
|
+
Prop("toolbarFrameJson") { view: NativeEditorExpoView, toolbarFrameJson: String? ->
|
|
232
|
+
view.setToolbarFrameJson(toolbarFrameJson)
|
|
233
|
+
}
|
|
234
|
+
Prop("editorUpdateJson") { view: NativeEditorExpoView, editorUpdateJson: String? ->
|
|
235
|
+
view.setPendingEditorUpdateJson(editorUpdateJson)
|
|
236
|
+
}
|
|
237
|
+
Prop("editorUpdateRevision") { view: NativeEditorExpoView, editorUpdateRevision: Int ->
|
|
238
|
+
view.setPendingEditorUpdateRevision(editorUpdateRevision)
|
|
239
|
+
}
|
|
240
|
+
OnViewDidUpdateProps { view: NativeEditorExpoView ->
|
|
241
|
+
view.applyPendingEditorUpdateIfNeeded()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
AsyncFunction("focus") { view: NativeEditorExpoView ->
|
|
245
|
+
view.focus()
|
|
246
|
+
}
|
|
247
|
+
AsyncFunction("blur") { view: NativeEditorExpoView ->
|
|
248
|
+
view.blur()
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
AsyncFunction("applyEditorUpdate") { view: NativeEditorExpoView, updateJson: String ->
|
|
252
|
+
view.applyEditorUpdate(updateJson)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|