@apollohg/react-native-rich-text-editor-code-highlighting 2.0.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/NativeEditorCodeHighlighting.podspec +24 -0
- package/README.md +47 -0
- package/RUST-STANDARD-LIBRARY-NOTICES.html +8266 -0
- package/THIRD_PARTY_NOTICES.md +18451 -0
- package/android/build.gradle +25 -0
- package/android/consumer-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/apollohg/editor/highlighting/NativeCodeHighlightingModule.kt +17 -0
- package/android/src/main/java/com/apollohg/editor/highlighting/SyntectHighlightingProvider.kt +23 -0
- package/android/src/main/java/uniffi/native_editor_highlighting/native_editor_highlighting.kt +1259 -0
- package/android/src/main/jniLibs/arm64-v8a/libnative_editor_highlighting.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libnative_editor_highlighting.so +0 -0
- package/android/src/main/jniLibs/x86/libnative_editor_highlighting.so +0 -0
- package/android/src/main/jniLibs/x86_64/libnative_editor_highlighting.so +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +25 -0
- package/expo-module.config.json +10 -0
- package/ios/Generated_highlighting.swift +728 -0
- package/ios/NativeCodeHighlightingModule.swift +14 -0
- package/ios/NativeEditorHighlighting.xcframework/Info.plist +44 -0
- package/ios/NativeEditorHighlighting.xcframework/ios-arm64/libnative_editor_highlighting.a +0 -0
- package/ios/NativeEditorHighlighting.xcframework/ios-arm64_x86_64-simulator/libnative_editor_highlighting.a +0 -0
- package/ios/SyntectHighlightingProvider.swift +12 -0
- package/ios/native_editor_highlightingFFI/module.modulemap +7 -0
- package/ios/native_editor_highlightingFFI/native_editor_highlightingFFI.h +551 -0
- package/package.json +49 -0
- package/scripts/verify-package.mjs +19 -0
- package/src/index.ts +41 -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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
|
+
Pod::Spec.new do |s|
|
|
4
|
+
s.name = 'NativeEditorCodeHighlighting'
|
|
5
|
+
s.version = package['version']
|
|
6
|
+
s.summary = package['description']
|
|
7
|
+
s.homepage = 'https://github.com/apollohg/react-native-rich-text-editor'
|
|
8
|
+
s.author = 'Apollo HG'
|
|
9
|
+
s.license = { :type => 'Apache-2.0', :file => 'LICENSE' }
|
|
10
|
+
s.source = { :git => 'https://github.com/apollohg/react-native-rich-text-editor.git' }
|
|
11
|
+
s.platforms = { :ios => '16.4' }
|
|
12
|
+
s.swift_version = '5.9'
|
|
13
|
+
s.static_framework = false
|
|
14
|
+
s.dependency 'ExpoModulesCore'
|
|
15
|
+
s.dependency 'ReactNativeProseEditor'
|
|
16
|
+
s.source_files = 'ios/*.swift'
|
|
17
|
+
s.vendored_frameworks = 'ios/NativeEditorHighlighting.xcframework'
|
|
18
|
+
s.preserve_paths = 'ios/native_editor_highlightingFFI/**/*'
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
'DEFINES_MODULE' => 'YES',
|
|
21
|
+
'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/ios/native_editor_highlightingFFI',
|
|
22
|
+
'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/ios/native_editor_highlightingFFI'
|
|
23
|
+
}
|
|
24
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Native code highlighting
|
|
2
|
+
|
|
3
|
+
Optional syntax highlighting for `@apollohg/react-native-rich-text-editor`. Requires Expo native modules and a native app rebuild after installation.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @apollohg/react-native-rich-text-editor-code-highlighting
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { RichTextEditor } from '@apollohg/react-native-rich-text-editor';
|
|
11
|
+
import { createCodeHighlightingAddon } from '@apollohg/react-native-rich-text-editor-code-highlighting';
|
|
12
|
+
|
|
13
|
+
const highlighting = createCodeHighlightingAddon({ theme: 'base16-ocean.dark' });
|
|
14
|
+
|
|
15
|
+
<RichTextEditor documentHandle={documentHandle} addons={[highlighting]} />;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`RichTextViewer` accepts the same addon. Set the code block's `language` attribute to select its grammar. Supported language values are `javascript`/`js`, `typescript`/`ts`, `tsx`, `jsx`, `swift`, `kotlin`/`kt`, `rust`/`rs`, `python`/`py`, `json`, `html`, `css`, and `bash`/`shell`/`sh`. JSX uses the TypeScript React grammar. Missing, plain, and unsupported language values render ordinary code without guessing.
|
|
19
|
+
|
|
20
|
+
`codeHighlightingThemes` lists the seven supported theme names. The selected theme contributes token foregrounds and bold/italic/underline traits. The editor's `codeBlock` style controls panel geometry and background.
|
|
21
|
+
|
|
22
|
+
The package registers its native provider synchronously when imported. Factories only create immutable configuration. Omit the descriptor to disable work for a view; uninstall and rebuild to remove the engine and grammar assets from the app. The base editor does not install this package automatically.
|
|
23
|
+
|
|
24
|
+
The engine uses syntect 5.3.0 with its pure Rust regex backend and the two-face 0.5.1 compatible grammar pack. Prebuilt libraries are included for iOS device/simulator and Android arm64-v8a, armeabi-v7a, x86, and x86_64. Consumer installation does not invoke Cargo.
|
|
25
|
+
|
|
26
|
+
Blocks over 64 KiB, lines over 4 KiB, or blocks over 1,000 lines fall back to ordinary styling. A worker-local cache retains at most 64 blocks and 1 MiB of accounted source/range data. Regex backtracking has the upstream finite step limit; this is not a wall-clock timeout. No syntax state or color marks are written to the document.
|
|
27
|
+
|
|
28
|
+
The core and all extensions share the same release version. Installing only the core does not install this extension or its native engine and grammar assets.
|
|
29
|
+
|
|
30
|
+
Maintainers build from this repository with Rust 1.95.0, the seven mobile Rust targets, Xcode, Android NDK and cargo-ndk installed:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm run build
|
|
34
|
+
npm run test:rust
|
|
35
|
+
npm run build:native
|
|
36
|
+
npm pack
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Licenses and attribution
|
|
40
|
+
|
|
41
|
+
This package's own code is [Apache-2.0](./LICENSE). Syntect is MIT-licensed; its bundled grammars, themes, Rust dependencies, and native dependencies retain their own licenses. Full texts, copyright notices, and corresponding-source links are included in [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) and [RUST-STANDARD-LIBRARY-NOTICES.html](./RUST-STANDARD-LIBRARY-NOTICES.html).
|
|
42
|
+
|
|
43
|
+
Include these notices alongside the core editor's notices in your distributed app's open-source acknowledgements or accompanying materials. Keep the MPL corresponding-source links and notices for the framework/native dependency versions your app actually resolves. Refresh these files when upgrading dependencies, syntax/theme assets, or the Rust toolchain.
|
|
44
|
+
|
|
45
|
+
## Releases
|
|
46
|
+
|
|
47
|
+
Bump versions from the repository root with `npm version`; its version hook synchronizes every extension and the example lockfile. The Publish / Dry Run workflow builds and validates the core and highlighting artifacts, then publishes them together when a GitHub release is published. Pushes and pull requests affecting extensions run the same validation without publishing. Unchanged native sources reuse their own build cache; JavaScript and tarballs are always rebuilt. A retry skips package versions already published after a partial release.
|