@apollohg/react-native-prose-editor 0.1.1 → 0.3.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/README.md +12 -7
- package/android/build.gradle +7 -2
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +289 -2
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +51 -1
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +16 -3
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +82 -1
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +403 -45
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +246 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +841 -155
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +125 -8
- package/{src/EditorTheme.ts → dist/EditorTheme.d.ts} +12 -52
- package/dist/EditorTheme.js +29 -0
- package/dist/EditorToolbar.d.ts +129 -0
- package/dist/EditorToolbar.js +394 -0
- package/dist/NativeEditorBridge.d.ts +242 -0
- package/dist/NativeEditorBridge.js +647 -0
- package/dist/NativeRichTextEditor.d.ts +142 -0
- package/dist/NativeRichTextEditor.js +649 -0
- package/dist/YjsCollaboration.d.ts +83 -0
- package/dist/YjsCollaboration.js +585 -0
- package/dist/addons.d.ts +70 -0
- package/dist/addons.js +77 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/schemas.d.ts +35 -0
- package/{src/schemas.ts → dist/schemas.js} +62 -27
- package/dist/useNativeEditor.d.ts +40 -0
- package/dist/useNativeEditor.js +117 -0
- package/ios/EditorAddons.swift +26 -3
- package/ios/EditorCore.xcframework/Info.plist +5 -5
- 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 +236 -0
- package/ios/EditorTheme.swift +51 -1
- package/ios/Generated_editor_core.swift +270 -2
- package/ios/NativeEditorExpoView.swift +612 -45
- package/ios/NativeEditorModule.swift +81 -0
- package/ios/PositionBridge.swift +22 -0
- package/ios/RenderBridge.swift +427 -39
- package/ios/RichTextEditorView.swift +1342 -18
- package/ios/editor_coreFFI/editor_coreFFI.h +209 -0
- package/package.json +80 -64
- 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 +404 -4
- package/src/EditorToolbar.tsx +0 -620
- package/src/NativeEditorBridge.ts +0 -607
- package/src/NativeRichTextEditor.tsx +0 -951
- package/src/addons.ts +0 -158
- package/src/index.ts +0 -63
- package/src/useNativeEditor.ts +0 -173
|
@@ -10,6 +10,42 @@ public class NativeEditorModule: Module {
|
|
|
10
10
|
Function("editorDestroy") { (id: Int) in
|
|
11
11
|
editorDestroy(id: UInt64(id))
|
|
12
12
|
}
|
|
13
|
+
Function("collaborationSessionCreate") { (configJson: String) -> Int in
|
|
14
|
+
Int(collaborationSessionCreate(configJson: configJson))
|
|
15
|
+
}
|
|
16
|
+
Function("collaborationSessionDestroy") { (id: Int) in
|
|
17
|
+
collaborationSessionDestroy(id: UInt64(id))
|
|
18
|
+
}
|
|
19
|
+
Function("collaborationSessionGetDocumentJson") { (id: Int) -> String in
|
|
20
|
+
collaborationSessionGetDocumentJson(id: UInt64(id))
|
|
21
|
+
}
|
|
22
|
+
Function("collaborationSessionGetEncodedState") { (id: Int) -> String in
|
|
23
|
+
collaborationSessionGetEncodedState(id: UInt64(id))
|
|
24
|
+
}
|
|
25
|
+
Function("collaborationSessionGetPeersJson") { (id: Int) -> String in
|
|
26
|
+
collaborationSessionGetPeersJson(id: UInt64(id))
|
|
27
|
+
}
|
|
28
|
+
Function("collaborationSessionStart") { (id: Int) -> String in
|
|
29
|
+
collaborationSessionStart(id: UInt64(id))
|
|
30
|
+
}
|
|
31
|
+
Function("collaborationSessionApplyLocalDocumentJson") { (id: Int, json: String) -> String in
|
|
32
|
+
collaborationSessionApplyLocalDocumentJson(id: UInt64(id), json: json)
|
|
33
|
+
}
|
|
34
|
+
Function("collaborationSessionApplyEncodedState") { (id: Int, encodedStateJson: String) -> String in
|
|
35
|
+
collaborationSessionApplyEncodedState(id: UInt64(id), encodedStateJson: encodedStateJson)
|
|
36
|
+
}
|
|
37
|
+
Function("collaborationSessionReplaceEncodedState") { (id: Int, encodedStateJson: String) -> String in
|
|
38
|
+
collaborationSessionReplaceEncodedState(id: UInt64(id), encodedStateJson: encodedStateJson)
|
|
39
|
+
}
|
|
40
|
+
Function("collaborationSessionHandleMessage") { (id: Int, messageJson: String) -> String in
|
|
41
|
+
collaborationSessionHandleMessage(id: UInt64(id), messageJson: messageJson)
|
|
42
|
+
}
|
|
43
|
+
Function("collaborationSessionSetLocalAwareness") { (id: Int, awarenessJson: String) -> String in
|
|
44
|
+
collaborationSessionSetLocalAwareness(id: UInt64(id), awarenessJson: awarenessJson)
|
|
45
|
+
}
|
|
46
|
+
Function("collaborationSessionClearLocalAwareness") { (id: Int) -> String in
|
|
47
|
+
collaborationSessionClearLocalAwareness(id: UInt64(id))
|
|
48
|
+
}
|
|
13
49
|
Function("editorSetHtml") { (id: Int, html: String) -> String in
|
|
14
50
|
editorSetHtml(id: UInt64(id), html: html)
|
|
15
51
|
}
|
|
@@ -70,6 +106,15 @@ public class NativeEditorModule: Module {
|
|
|
70
106
|
Function("editorToggleMark") { (id: Int, markName: String) -> String in
|
|
71
107
|
editorToggleMark(id: UInt64(id), markName: markName)
|
|
72
108
|
}
|
|
109
|
+
Function("editorSetMark") { (id: Int, markName: String, attrsJson: String) -> String in
|
|
110
|
+
editorSetMark(id: UInt64(id), markName: markName, attrsJson: attrsJson)
|
|
111
|
+
}
|
|
112
|
+
Function("editorUnsetMark") { (id: Int, markName: String) -> String in
|
|
113
|
+
editorUnsetMark(id: UInt64(id), markName: markName)
|
|
114
|
+
}
|
|
115
|
+
Function("editorToggleBlockquote") { (id: Int) -> String in
|
|
116
|
+
editorToggleBlockquote(id: UInt64(id))
|
|
117
|
+
}
|
|
73
118
|
Function("editorSetSelection") { (id: Int, anchor: Int, head: Int) in
|
|
74
119
|
editorSetSelection(id: UInt64(id), anchor: UInt32(anchor), head: UInt32(head))
|
|
75
120
|
}
|
|
@@ -90,6 +135,36 @@ public class NativeEditorModule: Module {
|
|
|
90
135
|
markName: markName
|
|
91
136
|
)
|
|
92
137
|
}
|
|
138
|
+
Function(
|
|
139
|
+
"editorSetMarkAtSelectionScalar"
|
|
140
|
+
) { (id: Int, scalarAnchor: Int, scalarHead: Int, markName: String, attrsJson: String) -> String in
|
|
141
|
+
editorSetMarkAtSelectionScalar(
|
|
142
|
+
id: UInt64(id),
|
|
143
|
+
scalarAnchor: UInt32(scalarAnchor),
|
|
144
|
+
scalarHead: UInt32(scalarHead),
|
|
145
|
+
markName: markName,
|
|
146
|
+
attrsJson: attrsJson
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
Function(
|
|
150
|
+
"editorUnsetMarkAtSelectionScalar"
|
|
151
|
+
) { (id: Int, scalarAnchor: Int, scalarHead: Int, markName: String) -> String in
|
|
152
|
+
editorUnsetMarkAtSelectionScalar(
|
|
153
|
+
id: UInt64(id),
|
|
154
|
+
scalarAnchor: UInt32(scalarAnchor),
|
|
155
|
+
scalarHead: UInt32(scalarHead),
|
|
156
|
+
markName: markName
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
Function(
|
|
160
|
+
"editorToggleBlockquoteAtSelectionScalar"
|
|
161
|
+
) { (id: Int, scalarAnchor: Int, scalarHead: Int) -> String in
|
|
162
|
+
editorToggleBlockquoteAtSelectionScalar(
|
|
163
|
+
id: UInt64(id),
|
|
164
|
+
scalarAnchor: UInt32(scalarAnchor),
|
|
165
|
+
scalarHead: UInt32(scalarHead)
|
|
166
|
+
)
|
|
167
|
+
}
|
|
93
168
|
Function(
|
|
94
169
|
"editorWrapInListAtSelectionScalar"
|
|
95
170
|
) { (id: Int, scalarAnchor: Int, scalarHead: Int, listType: String) -> String in
|
|
@@ -227,12 +302,18 @@ public class NativeEditorModule: Module {
|
|
|
227
302
|
Prop("heightBehavior") { (view: NativeEditorExpoView, heightBehavior: String) in
|
|
228
303
|
view.setHeightBehavior(heightBehavior)
|
|
229
304
|
}
|
|
305
|
+
Prop("allowImageResizing") { (view: NativeEditorExpoView, allowImageResizing: Bool) in
|
|
306
|
+
view.setAllowImageResizing(allowImageResizing)
|
|
307
|
+
}
|
|
230
308
|
Prop("themeJson") { (view: NativeEditorExpoView, themeJson: String?) in
|
|
231
309
|
view.setThemeJson(themeJson)
|
|
232
310
|
}
|
|
233
311
|
Prop("addonsJson") { (view: NativeEditorExpoView, addonsJson: String?) in
|
|
234
312
|
view.setAddonsJson(addonsJson)
|
|
235
313
|
}
|
|
314
|
+
Prop("remoteSelectionsJson") { (view: NativeEditorExpoView, remoteSelectionsJson: String?) in
|
|
315
|
+
view.setRemoteSelectionsJson(remoteSelectionsJson)
|
|
316
|
+
}
|
|
236
317
|
Prop("toolbarItemsJson") { (view: NativeEditorExpoView, toolbarItemsJson: String?) in
|
|
237
318
|
view.setToolbarButtonsJson(toolbarItemsJson)
|
|
238
319
|
}
|
package/ios/PositionBridge.swift
CHANGED
|
@@ -62,6 +62,12 @@ final class PositionBridge {
|
|
|
62
62
|
let clampedOffset = min(max(utf16Offset, 0), nsString.length)
|
|
63
63
|
var scalarOffset = utf16OffsetToScalar(clampedOffset, in: text)
|
|
64
64
|
|
|
65
|
+
for placeholderOffset in syntheticPlaceholderOffsets(in: textView) where clampedOffset > placeholderOffset {
|
|
66
|
+
if scalarOffset > 0 {
|
|
67
|
+
scalarOffset -= 1
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
for marker in virtualListMarkers(in: textView) where clampedOffset >= marker.paragraphStartUtf16 {
|
|
66
72
|
scalarOffset += marker.scalarLength
|
|
67
73
|
}
|
|
@@ -275,4 +281,20 @@ final class PositionBridge {
|
|
|
275
281
|
|
|
276
282
|
return markers.sorted { $0.paragraphStartUtf16 < $1.paragraphStartUtf16 }
|
|
277
283
|
}
|
|
284
|
+
|
|
285
|
+
private static func syntheticPlaceholderOffsets(in textView: UITextView) -> [Int] {
|
|
286
|
+
let textStorage = textView.textStorage
|
|
287
|
+
guard textStorage.length > 0 else { return [] }
|
|
288
|
+
|
|
289
|
+
var offsets: [Int] = []
|
|
290
|
+
textStorage.enumerateAttribute(
|
|
291
|
+
RenderBridgeAttributes.syntheticPlaceholder,
|
|
292
|
+
in: NSRange(location: 0, length: textStorage.length),
|
|
293
|
+
options: []
|
|
294
|
+
) { value, range, _ in
|
|
295
|
+
guard range.length > 0, (value as? Bool) == true else { return }
|
|
296
|
+
offsets.append(range.location)
|
|
297
|
+
}
|
|
298
|
+
return offsets
|
|
299
|
+
}
|
|
278
300
|
}
|