@openeditor/react-native-prose-editor 0.0.2
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 +180 -0
- package/android/build.gradle +69 -0
- package/android/consumer-rules.pro +18 -0
- package/android/src/androidTest/AndroidManifest.xml +8 -0
- package/android/src/androidTest/java/com/apollohg/editor/MeasureHeightInstrumentedTest.kt +53 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceCollaborationInitialSyncTest.kt +241 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceImeRegressionTest.kt +338 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceOutsideTapTest.kt +789 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDevicePerformanceTest.kt +350 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeEditorOutsideTapActivity.kt +5 -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/CaretGeometry.kt +50 -0
- package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +135 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +4527 -0
- package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +14 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +999 -0
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +474 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +3137 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +561 -0
- package/android/src/main/java/com/apollohg/editor/NativeProseViewerExpoView.kt +315 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +1413 -0
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +133 -0
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +315 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +2172 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +399 -0
- package/android/src/sharedTest/java/com/apollohg/editor/NativePerformanceSupport.kt +482 -0
- package/android/src/test/java/com/apollohg/editor/CaretGeometryTest.kt +137 -0
- package/android/src/test/java/com/apollohg/editor/EditorEditTextHardwareKeyTest.kt +321 -0
- package/android/src/test/java/com/apollohg/editor/EditorInputConnectionTest.kt +4202 -0
- package/android/src/test/java/com/apollohg/editor/NativeEditorExpoViewTest.kt +2581 -0
- package/android/src/test/java/com/apollohg/editor/NativeEditorModuleTest.kt +27 -0
- package/android/src/test/java/com/apollohg/editor/NativePerformanceTest.kt +197 -0
- package/android/src/test/java/com/apollohg/editor/NativeProseViewerExpoViewTest.kt +84 -0
- package/android/src/test/java/com/apollohg/editor/NativeToolbarTest.kt +544 -0
- package/android/src/test/java/com/apollohg/editor/PositionBridgeTest.kt +461 -0
- package/android/src/test/java/com/apollohg/editor/RenderBridgeTest.kt +2054 -0
- package/android/src/test/java/com/apollohg/editor/RichTextEditorViewTest.kt +1367 -0
- package/app.plugin.js +62 -0
- package/dist/EditorTheme.d.ts +113 -0
- package/dist/EditorTheme.js +29 -0
- package/dist/EditorToolbar.d.ts +191 -0
- package/dist/EditorToolbar.js +1095 -0
- package/dist/NativeEditorBridge.d.ts +325 -0
- package/dist/NativeEditorBridge.js +933 -0
- package/dist/NativeProseViewer.d.ts +53 -0
- package/dist/NativeProseViewer.js +480 -0
- package/dist/NativeRichTextEditor.d.ts +183 -0
- package/dist/NativeRichTextEditor.js +2574 -0
- package/dist/YjsCollaboration.d.ts +90 -0
- package/dist/YjsCollaboration.js +743 -0
- package/dist/addons.d.ts +100 -0
- package/dist/addons.js +82 -0
- package/dist/heightCache.d.ts +6 -0
- package/dist/heightCache.js +45 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +30 -0
- package/dist/schemas.d.ts +37 -0
- package/dist/schemas.js +263 -0
- package/dist/useNativeEditor.d.ts +42 -0
- package/dist/useNativeEditor.js +124 -0
- package/expo-module.config.json +9 -0
- package/ios/EditorAddons.swift +327 -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 +774 -0
- package/ios/EditorTheme.swift +515 -0
- package/ios/Generated_editor_core.swift +1513 -0
- package/ios/NativeEditorExpoView.swift +3593 -0
- package/ios/NativeEditorModule.swift +624 -0
- package/ios/NativeProseViewerExpoView.swift +276 -0
- package/ios/PositionBridge.swift +558 -0
- package/ios/ReactNativeProseEditor.podspec +49 -0
- package/ios/RenderBridge.swift +1708 -0
- package/ios/RichTextEditorView.swift +6150 -0
- package/ios/Tests/NativePerformanceTests.swift +687 -0
- package/ios/Tests/PositionBridgeTests.swift +706 -0
- package/ios/Tests/RenderBridgeTests.swift +2236 -0
- package/ios/Tests/RichTextEditorViewTests.swift +6548 -0
- package/ios/editor_coreFFI/editor_coreFFI.h +1289 -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 +74 -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 +2563 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and
|
|
27
|
+
configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object
|
|
31
|
+
code, generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
46
|
+
version of the Work and any modifications or additions to that Work or
|
|
47
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
48
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
49
|
+
Entity authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal, or
|
|
51
|
+
written communication sent to the Licensor or its representatives, including
|
|
52
|
+
but not limited to communication on electronic mailing lists, source code
|
|
53
|
+
control systems, and issue tracking systems that are managed by, or on behalf
|
|
54
|
+
of, the Licensor for the purpose of discussing and improving the Work, but
|
|
55
|
+
excluding communication that is conspicuously marked or otherwise designated in
|
|
56
|
+
writing by the copyright owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
70
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
71
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
72
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
73
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
74
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
75
|
+
their Contribution(s) alone or by combination of their Contribution(s) with the
|
|
76
|
+
Work to which such Contribution(s) was submitted. If You institute patent
|
|
77
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
78
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
80
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
81
|
+
the date such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
88
|
+
of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
95
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
96
|
+
part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents
|
|
106
|
+
of the NOTICE file are for informational purposes only and do not modify the
|
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
|
110
|
+
modifying the License.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
113
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
114
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
115
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
116
|
+
complies with the conditions stated in this License.
|
|
117
|
+
|
|
118
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
119
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
120
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
121
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
122
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
123
|
+
executed with Licensor regarding such Contributions.
|
|
124
|
+
|
|
125
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
126
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
127
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
128
|
+
reproducing the content of the NOTICE file.
|
|
129
|
+
|
|
130
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
131
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
132
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
133
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
134
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
137
|
+
associated with Your exercise of permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
140
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
141
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
142
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
143
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
144
|
+
character arising as a result of this License or out of the use or inability to
|
|
145
|
+
use the Work (including but not limited to damages for loss of goodwill, work
|
|
146
|
+
stoppage, computer failure or malfunction, or any and all other commercial
|
|
147
|
+
damages or losses), even if such Contributor has been advised of the
|
|
148
|
+
possibility of such damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
151
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
152
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
153
|
+
and/or rights consistent with this License. However, in accepting such
|
|
154
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
156
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# React Native Prose Editor [](https://www.npmjs.com/package/@openeditor/react-native-prose-editor)
|
|
2
|
+
|
|
3
|
+
`@openeditor/react-native-prose-editor` is a native rich text editor for React Native with a Rust document core, native iOS and Android rendering, configurable schemas, and a React-facing toolbar and theme API.
|
|
4
|
+
|
|
5
|
+
This project is currently in `alpha` and the API, behavior, and packaging may still change.
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://raw.githubusercontent.com/wiki/apollohg/react-native-prose-editor/images/example-ios.png" alt="Example editor iOS" width="45%" align="top" />
|
|
9
|
+
<img src="https://raw.githubusercontent.com/wiki/apollohg/react-native-prose-editor/images/example-android.png" alt="Example editor Android" width="45%" align="top" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
This repository contains three main pieces:
|
|
13
|
+
|
|
14
|
+
- the editor package itself under [`src`](./src), [`ios`](./ios), [`android`](./android), and [`rust`](./rust)
|
|
15
|
+
- an Expo SDK 54 development app under [`example`](./example)
|
|
16
|
+
- a runnable iOS XCTest harness for native regression coverage
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
The editor already supports:
|
|
21
|
+
|
|
22
|
+
- HTML and ProseMirror JSON content input/output
|
|
23
|
+
- configurable schemas
|
|
24
|
+
- marks such as bold, italic, underline, strike, and links
|
|
25
|
+
- blockquotes
|
|
26
|
+
- bullet and ordered lists with indent/outdent behavior
|
|
27
|
+
- hard breaks and horizontal rules
|
|
28
|
+
- native @-mentions with themed suggestion UI in the toolbar area
|
|
29
|
+
- native theming for text, lists, horizontal rules, mentions, and the toolbar
|
|
30
|
+
- configurable toolbar items, including app-defined actions
|
|
31
|
+
- auto-grow height behavior for parent-managed scroll containers
|
|
32
|
+
- a Rust-backed undo/redo history model
|
|
33
|
+
|
|
34
|
+
## Repository Layout
|
|
35
|
+
|
|
36
|
+
- [`src`](./src): React Native component API, toolbar, schemas, and TypeScript types
|
|
37
|
+
- [`ios`](./ios): iOS native view, toolbar accessory, rendering bridge, and generated Rust bindings
|
|
38
|
+
- [`android`](./android): Android native view, rendering bridge, and Expo module wiring
|
|
39
|
+
- [`Rust Editor Core`](./rust/editor-core): document model, transforms, schema system, selection, history, serialization, and tests
|
|
40
|
+
- [`example`](./example): Expo 54 app for manual QA and development
|
|
41
|
+
|
|
42
|
+
This package now lives inside the OpenEditor monorepo. Documentation is being consolidated here while the old
|
|
43
|
+
standalone fork is retired.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
This package currently requires Expo Modules. Use it in an Expo development build or in a bare React Native app that has Expo Modules configured.
|
|
48
|
+
|
|
49
|
+
The minimum tested Expo version is SDK 54.
|
|
50
|
+
|
|
51
|
+
Required peer dependencies:
|
|
52
|
+
|
|
53
|
+
- `expo`
|
|
54
|
+
- `react`
|
|
55
|
+
- `react-native`
|
|
56
|
+
- `@expo/vector-icons`
|
|
57
|
+
|
|
58
|
+
Install the package:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npm install @openeditor/react-native-prose-editor@0.0.1
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Expo prebuild apps should add the package config plugin so Android excludes
|
|
65
|
+
obsolete JNA ABI copies that modern NDKs cannot strip:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
export default {
|
|
69
|
+
expo: {
|
|
70
|
+
plugins: ['@openeditor/react-native-prose-editor'],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For bare React Native apps or existing generated Android projects, add the same
|
|
76
|
+
packaging exclude to `android/gradle.properties` when your template applies
|
|
77
|
+
`android.packagingOptions.*` properties:
|
|
78
|
+
|
|
79
|
+
```properties
|
|
80
|
+
android.packagingOptions.excludes=**/armeabi/libjnidispatch.so,**/mips/libjnidispatch.so,**/mips64/libjnidispatch.so
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If your Android project does not read those Gradle properties, add the patterns
|
|
84
|
+
directly under the app module's `android.packagingOptions.jniLibs.excludes`.
|
|
85
|
+
|
|
86
|
+
For local package development in this repo:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm install
|
|
90
|
+
npm --prefix example install
|
|
91
|
+
npm run example:prebuild
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The installation details in this README are the current source of truth while package documentation is consolidated into the monorepo.
|
|
95
|
+
|
|
96
|
+
## Basic Usage
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import React, { useRef } from 'react';
|
|
100
|
+
import {
|
|
101
|
+
NativeRichTextEditor,
|
|
102
|
+
type NativeRichTextEditorRef,
|
|
103
|
+
} from '@openeditor/react-native-prose-editor';
|
|
104
|
+
|
|
105
|
+
export function EditorScreen() {
|
|
106
|
+
const editorRef = useRef<NativeRichTextEditorRef>(null);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<NativeRichTextEditor
|
|
110
|
+
ref={editorRef}
|
|
111
|
+
initialContent="<p>Hello world</p>"
|
|
112
|
+
placeholder="Start typing..."
|
|
113
|
+
onContentChange={(html) => {
|
|
114
|
+
console.log(html);
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Customization
|
|
122
|
+
|
|
123
|
+
The main extension points today are:
|
|
124
|
+
|
|
125
|
+
- `schema`: provide a custom schema definition
|
|
126
|
+
- `theme`: style text blocks, blockquotes, lists, horizontal rules, background, and toolbar chrome, including a native-looking keyboard toolbar mode
|
|
127
|
+
- `toolbarItems`: define the visible toolbar controls and order
|
|
128
|
+
- `onToolbarAction`: handle app-defined toolbar buttons
|
|
129
|
+
- `onRequestLink`: collect or edit hyperlink URLs when a toolbar link item is pressed
|
|
130
|
+
- `addons`: configure optional features like @-mentions
|
|
131
|
+
- `heightBehavior`: switch between internal scrolling and auto-grow
|
|
132
|
+
|
|
133
|
+
For setup and customization details, use this README and the package source as the current source of truth while documentation is consolidated into the monorepo.
|
|
134
|
+
|
|
135
|
+
For whole-document JSON loads, `initialJSON`, controlled `valueJSON`, and `setContentJson()` will normalize an empty root document like `{ type: 'doc', content: [] }` to the active schema's empty text block so block-constrained schemas still load a valid empty document. For chat composer or draft-reset flows, prefer the ref method `clearContent()`.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
Common commands:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
npm run typecheck
|
|
143
|
+
npm run bench:rust -- --quick
|
|
144
|
+
npm run example:start
|
|
145
|
+
npm run example:ios
|
|
146
|
+
npm run example:android
|
|
147
|
+
npm run build:rust
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Tests:
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
npm test # TypeScript unit tests
|
|
154
|
+
cargo test --manifest-path rust/editor-core/Cargo.toml # Rust core tests
|
|
155
|
+
npm run android:test # Android Robolectric tests
|
|
156
|
+
npm run android:test:perf # Android native perf test suite
|
|
157
|
+
npm run android:test:perf:device # Android on-device perf instrumentation suite
|
|
158
|
+
npm run ios:test:perf # iOS native perf XCTest suite
|
|
159
|
+
npm run ios:test:perf:device # iOS on-device perf XCTest suite
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Benchmarks:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
npm run bench:rust -- --quick
|
|
166
|
+
npm run bench:rust -- --filter collaboration
|
|
167
|
+
npm run bench:rust -- --json > perf-results.json
|
|
168
|
+
npm run android:test:perf
|
|
169
|
+
npm run android:test:perf:device
|
|
170
|
+
npm run ios:test:perf
|
|
171
|
+
npm run ios:test:perf:device
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
Documentation is being consolidated into this README and the OpenEditor monorepo as part of the engine migration.
|
|
177
|
+
|
|
178
|
+
## Project Status
|
|
179
|
+
|
|
180
|
+
The project is usable and already covers the core editing flows, but the API and documentation are still evolving as the package moves toward wider use.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
3
|
+
plugins {
|
|
4
|
+
id 'com.android.library'
|
|
5
|
+
id 'expo-module-gradle-plugin'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
def packageJson = new JsonSlurper().parse(file('../package.json'))
|
|
9
|
+
|
|
10
|
+
group = 'com.openeditor'
|
|
11
|
+
version = packageJson.version
|
|
12
|
+
|
|
13
|
+
android {
|
|
14
|
+
namespace = "com.openeditor.editor"
|
|
15
|
+
testOptions {
|
|
16
|
+
unitTests.includeAndroidResources = true
|
|
17
|
+
unitTests.all { test ->
|
|
18
|
+
if (project.findProperty("openeditorShowPerfTestOutput") == "true") {
|
|
19
|
+
test.testLogging {
|
|
20
|
+
events "passed", "failed"
|
|
21
|
+
showStandardStreams = true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
defaultConfig {
|
|
27
|
+
versionCode = 1
|
|
28
|
+
versionName = packageJson.version
|
|
29
|
+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
30
|
+
consumerProguardFiles "consumer-rules.pro"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Include prebuilt Rust .so files from the package's rust/android/ directory
|
|
34
|
+
sourceSets {
|
|
35
|
+
main {
|
|
36
|
+
jniLibs.srcDirs = [
|
|
37
|
+
"${project.projectDir}/../rust/android"
|
|
38
|
+
]
|
|
39
|
+
// Include the generated Kotlin UniFFI bindings
|
|
40
|
+
java.srcDirs += [
|
|
41
|
+
"${project.projectDir}/../rust/bindings/kotlin"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
test {
|
|
45
|
+
java.srcDirs += [
|
|
46
|
+
"${project.projectDir}/src/sharedTest/java"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
androidTest {
|
|
50
|
+
java.srcDirs += [
|
|
51
|
+
"${project.projectDir}/src/sharedTest/java"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
dependencies {
|
|
58
|
+
implementation "androidx.appcompat:appcompat:1.7.0"
|
|
59
|
+
implementation "com.google.android.material:material:1.12.0"
|
|
60
|
+
|
|
61
|
+
api "net.java.dev.jna:jna:5.18.1@aar"
|
|
62
|
+
|
|
63
|
+
testImplementation "junit:junit:4.13.2"
|
|
64
|
+
testImplementation "org.robolectric:robolectric:4.14.1"
|
|
65
|
+
|
|
66
|
+
androidTestImplementation "androidx.test:core-ktx:1.6.1"
|
|
67
|
+
androidTestImplementation "androidx.test:runner:1.6.2"
|
|
68
|
+
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# JNA includes desktop AWT helpers that are not available on Android. The editor
|
|
2
|
+
# bindings do not call those APIs, but R8 still validates the references.
|
|
3
|
+
-dontwarn java.awt.**
|
|
4
|
+
|
|
5
|
+
# UniFFI uses JNA reflection/proxies to bind Kotlin method and structure field
|
|
6
|
+
# names to the Rust library. Keep these names stable in consuming release builds.
|
|
7
|
+
-keep class com.sun.jna.** { *; }
|
|
8
|
+
-keep class uniffi.editor_core.** { *; }
|
|
9
|
+
-keepattributes Signature,InnerClasses,EnclosingMethod,*Annotation*
|
|
10
|
+
|
|
11
|
+
# Preserve native editor View class names in consuming release builds so Android
|
|
12
|
+
# framework ViewGroup crashes identify the owning component in crash reporters.
|
|
13
|
+
-keepnames class com.openeditor.editor.** extends android.view.View
|
|
14
|
+
|
|
15
|
+
# JNA inspects Library interfaces and Structure fields reflectively. These
|
|
16
|
+
# member rules make that contract explicit for ProGuard/R8 consumers.
|
|
17
|
+
-keepclassmembers class * implements com.sun.jna.Library { *; }
|
|
18
|
+
-keepclassmembers class * extends com.sun.jna.Structure { *; }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<application>
|
|
3
|
+
<activity
|
|
4
|
+
android:name="com.openeditor.editor.NativeEditorOutsideTapActivity"
|
|
5
|
+
android:exported="false"
|
|
6
|
+
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
|
7
|
+
</application>
|
|
8
|
+
</manifest>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package com.openeditor.editor
|
|
2
|
+
|
|
3
|
+
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
4
|
+
import org.junit.Assert.assertTrue
|
|
5
|
+
import org.junit.Test
|
|
6
|
+
import org.junit.runner.RunWith
|
|
7
|
+
|
|
8
|
+
@RunWith(AndroidJUnit4::class)
|
|
9
|
+
class MeasureHeightInstrumentedTest {
|
|
10
|
+
|
|
11
|
+
@Test
|
|
12
|
+
fun measureHeight_narrowerWidthProducesTallerResult() {
|
|
13
|
+
val longText = "word ".repeat(100)
|
|
14
|
+
val renderJSON = """[{"type":"blockStart","nodeType":"paragraph","depth":0},{"type":"textRun","text":"$longText"},{"type":"blockEnd"}]"""
|
|
15
|
+
val narrowHeight = RenderBridge.measureHeight(
|
|
16
|
+
json = renderJSON,
|
|
17
|
+
themeJson = null,
|
|
18
|
+
width = 100f,
|
|
19
|
+
density = 1f
|
|
20
|
+
)
|
|
21
|
+
val wideHeight = RenderBridge.measureHeight(
|
|
22
|
+
json = renderJSON,
|
|
23
|
+
themeJson = null,
|
|
24
|
+
width = 1000f,
|
|
25
|
+
density = 1f
|
|
26
|
+
)
|
|
27
|
+
assertTrue(
|
|
28
|
+
"Narrower width ($narrowHeight) should be taller than wider ($wideHeight)",
|
|
29
|
+
narrowHeight > wideHeight
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Test
|
|
34
|
+
fun measureHeight_largerFontProducesTallerResult() {
|
|
35
|
+
val renderJSON = """[{"type":"blockStart","nodeType":"paragraph","depth":0},{"type":"textRun","text":"Hello world"},{"type":"blockEnd"}]"""
|
|
36
|
+
val smallHeight = RenderBridge.measureHeight(
|
|
37
|
+
json = renderJSON,
|
|
38
|
+
themeJson = """{"text":{"fontSize":12}}""",
|
|
39
|
+
width = 375f,
|
|
40
|
+
density = 1f
|
|
41
|
+
)
|
|
42
|
+
val largeHeight = RenderBridge.measureHeight(
|
|
43
|
+
json = renderJSON,
|
|
44
|
+
themeJson = """{"text":{"fontSize":32}}""",
|
|
45
|
+
width = 375f,
|
|
46
|
+
density = 1f
|
|
47
|
+
)
|
|
48
|
+
assertTrue(
|
|
49
|
+
"Larger font ($largeHeight) should be taller than smaller ($smallHeight)",
|
|
50
|
+
largeHeight > smallHeight
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
}
|