react-native-rn-story-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 +20 -0
- package/README.md +77 -0
- package/RnStoryEditor.podspec +20 -0
- package/android/build.gradle +67 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/rnstoryeditor/RnStoryEditorPackage.kt +17 -0
- package/android/src/main/java/com/rnstoryeditor/RnStoryEditorView.kt +15 -0
- package/android/src/main/java/com/rnstoryeditor/RnStoryEditorViewManager.kt +57 -0
- package/ios/RnStoryEditorView.h +14 -0
- package/ios/RnStoryEditorView.mm +48 -0
- package/lib/module/RnStoryEditorViewNativeComponent.ts +15 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/RnStoryEditorViewNativeComponent.d.ts +9 -0
- package/lib/typescript/src/RnStoryEditorViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +183 -0
- package/src/RnStoryEditorViewNativeComponent.ts +15 -0
- package/src/index.ts +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dhaval Joshi Pote
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# react-native-rn-story-editor
|
|
2
|
+
|
|
3
|
+
This is library for the Editing tools
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-rn-story-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { StoryEditorView, StoryEditorCommands } from "react-native-rn-story-editor";
|
|
15
|
+
|
|
16
|
+
// Use the component with numeric color
|
|
17
|
+
<StoryEditorView color={0xFF32a852} style={styles.box} />
|
|
18
|
+
|
|
19
|
+
// Or use the component with hex string color
|
|
20
|
+
<StoryEditorView colorString="#32a852" style={styles.box} />
|
|
21
|
+
|
|
22
|
+
// Use commands when needed
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
StoryEditorCommands.exportImage(ref);
|
|
25
|
+
StoryEditorCommands.showTextInput(ref);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
|
|
30
|
+
### Unit Tests
|
|
31
|
+
```bash
|
|
32
|
+
npm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Manual Testing
|
|
36
|
+
```bash
|
|
37
|
+
# Test on Android
|
|
38
|
+
npm run example:android
|
|
39
|
+
|
|
40
|
+
# Test on iOS
|
|
41
|
+
npm run example:ios
|
|
42
|
+
|
|
43
|
+
# Test different React Native versions
|
|
44
|
+
cd example
|
|
45
|
+
npm install react-native@0.72
|
|
46
|
+
npm install react-native@0.73
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Cross-Platform Verification
|
|
50
|
+
- ✅ Android: Tested on API 24+ (emulators/devices)
|
|
51
|
+
- ✅ iOS: Test on iOS 12+ (simulators/devices)
|
|
52
|
+
- ✅ React Native: Test with multiple versions
|
|
53
|
+
- ✅ TypeScript: All types compile correctly
|
|
54
|
+
- ✅ Props: Color, style, and other props work
|
|
55
|
+
- ✅ Commands: exportImage and showTextInput functions
|
|
56
|
+
|
|
57
|
+
### Before Publishing Checklist
|
|
58
|
+
- [ ] All tests pass
|
|
59
|
+
- [ ] Manual testing on Android/iOS
|
|
60
|
+
- [ ] TypeScript builds without errors
|
|
61
|
+
- [ ] Example app runs successfully
|
|
62
|
+
- [ ] Documentation is up to date
|
|
63
|
+
- [ ] Version is incremented
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
68
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
69
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RnStoryEditor"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/joshiidhaval/react-native-rn-story-editor.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.RnStoryEditor = [
|
|
3
|
+
kotlinVersion: "2.0.21",
|
|
4
|
+
minSdkVersion: 24,
|
|
5
|
+
compileSdkVersion: 36,
|
|
6
|
+
targetSdkVersion: 36
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
ext.getExtOrDefault = { prop ->
|
|
10
|
+
if (rootProject.ext.has(prop)) {
|
|
11
|
+
return rootProject.ext.get(prop)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return RnStoryEditor[prop]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
repositories {
|
|
18
|
+
google()
|
|
19
|
+
mavenCentral()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dependencies {
|
|
23
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
24
|
+
// noinspection DifferentKotlinGradleVersion
|
|
25
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
apply plugin: "com.android.library"
|
|
31
|
+
apply plugin: "kotlin-android"
|
|
32
|
+
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
|
|
35
|
+
android {
|
|
36
|
+
namespace "com.rnstoryeditor"
|
|
37
|
+
|
|
38
|
+
compileSdkVersion getExtOrDefault("compileSdkVersion")
|
|
39
|
+
|
|
40
|
+
defaultConfig {
|
|
41
|
+
minSdkVersion getExtOrDefault("minSdkVersion")
|
|
42
|
+
targetSdkVersion getExtOrDefault("targetSdkVersion")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
buildFeatures {
|
|
46
|
+
buildConfig true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
buildTypes {
|
|
50
|
+
release {
|
|
51
|
+
minifyEnabled false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lint {
|
|
56
|
+
disable "GradleCompatible"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
compileOptions {
|
|
60
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
dependencies {
|
|
66
|
+
implementation "com.facebook.react:react-android"
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.rnstoryeditor
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
class RnStoryEditorViewPackage : BaseReactPackage() {
|
|
10
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
11
|
+
return listOf(RnStoryEditorViewManager())
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
|
|
15
|
+
|
|
16
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider { emptyMap() }
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.rnstoryeditor
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.AttributeSet
|
|
5
|
+
import android.view.View
|
|
6
|
+
|
|
7
|
+
class RnStoryEditorView : View {
|
|
8
|
+
constructor(context: Context?) : super(context)
|
|
9
|
+
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
|
10
|
+
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
11
|
+
context,
|
|
12
|
+
attrs,
|
|
13
|
+
defStyleAttr
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.rnstoryeditor
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.RnStoryEditorViewManagerInterface
|
|
10
|
+
import com.facebook.react.viewmanagers.RnStoryEditorViewManagerDelegate
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = RnStoryEditorViewManager.NAME)
|
|
14
|
+
class RnStoryEditorViewManager : SimpleViewManager<RnStoryEditorView>(),
|
|
15
|
+
RnStoryEditorViewManagerInterface<RnStoryEditorView> {
|
|
16
|
+
private val mDelegate: ViewManagerDelegate<RnStoryEditorView>
|
|
17
|
+
|
|
18
|
+
init {
|
|
19
|
+
mDelegate = RnStoryEditorViewManagerDelegate(this)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun getDelegate(): ViewManagerDelegate<RnStoryEditorView>? {
|
|
23
|
+
return mDelegate
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getName(): String {
|
|
27
|
+
return NAME
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public override fun createViewInstance(context: ThemedReactContext): RnStoryEditorView {
|
|
31
|
+
return RnStoryEditorView(context)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ReactProp(name = "color")
|
|
35
|
+
override fun setColor(view: RnStoryEditorView?, color: Int?) {
|
|
36
|
+
view?.setBackgroundColor(color ?: Color.TRANSPARENT)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@ReactProp(name = "colorString")
|
|
40
|
+
override fun setColorString(view: RnStoryEditorView?, color: String?) {
|
|
41
|
+
val androidColor = when {
|
|
42
|
+
color?.startsWith("#") == true -> {
|
|
43
|
+
try {
|
|
44
|
+
Color.parseColor(color)
|
|
45
|
+
} catch (e: IllegalArgumentException) {
|
|
46
|
+
Color.TRANSPARENT
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else -> Color.TRANSPARENT
|
|
50
|
+
}
|
|
51
|
+
view?.setBackgroundColor(androidColor)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
companion object {
|
|
55
|
+
const val NAME = "RnStoryEditorView"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#ifndef RnStoryEditorViewNativeComponent_h
|
|
5
|
+
#define RnStoryEditorViewNativeComponent_h
|
|
6
|
+
|
|
7
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
+
|
|
9
|
+
@interface RnStoryEditorView : RCTViewComponentView
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_END
|
|
13
|
+
|
|
14
|
+
#endif /* RnStoryEditorViewNativeComponent_h */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#import "RnStoryEditorView.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTConversions.h>
|
|
4
|
+
|
|
5
|
+
#import <react/renderer/components/RnStoryEditorViewSpec/ComponentDescriptors.h>
|
|
6
|
+
#import <react/renderer/components/RnStoryEditorViewSpec/Props.h>
|
|
7
|
+
#import <react/renderer/components/RnStoryEditorViewSpec/RCTComponentViewHelpers.h>
|
|
8
|
+
|
|
9
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react;
|
|
12
|
+
|
|
13
|
+
@implementation RnStoryEditorView {
|
|
14
|
+
UIView * _view;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
18
|
+
{
|
|
19
|
+
return concreteComponentDescriptorProvider<RnStoryEditorViewComponentDescriptor>();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
23
|
+
{
|
|
24
|
+
if (self = [super initWithFrame:frame]) {
|
|
25
|
+
static const auto defaultProps = std::make_shared<const RnStoryEditorViewProps>();
|
|
26
|
+
_props = defaultProps;
|
|
27
|
+
|
|
28
|
+
_view = [[UIView alloc] init];
|
|
29
|
+
|
|
30
|
+
self.contentView = _view;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
37
|
+
{
|
|
38
|
+
const auto &oldViewProps = *std::static_pointer_cast<RnStoryEditorViewProps const>(_props);
|
|
39
|
+
const auto &newViewProps = *std::static_pointer_cast<RnStoryEditorViewProps const>(props);
|
|
40
|
+
|
|
41
|
+
if (oldViewProps.color != newViewProps.color) {
|
|
42
|
+
[_view setBackgroundColor: RCTUIColorFromSharedColor(newViewProps.color)];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[super updateProps:props oldProps:oldProps];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
interface NativeProps extends ViewProps {
|
|
8
|
+
color?: ColorValue;
|
|
9
|
+
colorString?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default codegenNativeComponent<NativeProps>('RnStoryEditorView');
|
|
13
|
+
|
|
14
|
+
// Export the component with proper types
|
|
15
|
+
export type { NativeProps };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { requireNativeComponent, UIManager, findNodeHandle } from 'react-native';
|
|
4
|
+
const COMPONENT_NAME = 'RnStoryEditorView';
|
|
5
|
+
|
|
6
|
+
// Type definition for view manager commands
|
|
7
|
+
|
|
8
|
+
export const StoryEditorView = requireNativeComponent(COMPONENT_NAME);
|
|
9
|
+
|
|
10
|
+
// Commands
|
|
11
|
+
export const StoryEditorCommands = {
|
|
12
|
+
exportImage: ref => {
|
|
13
|
+
const viewManagerConfig = UIManager.getViewManagerConfig(COMPONENT_NAME);
|
|
14
|
+
if (viewManagerConfig?.Commands?.exportImage) {
|
|
15
|
+
const nodeHandle = findNodeHandle(ref);
|
|
16
|
+
if (nodeHandle != null) {
|
|
17
|
+
UIManager.dispatchViewManagerCommand(nodeHandle, viewManagerConfig.Commands.exportImage, []);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
showTextInput: ref => {
|
|
22
|
+
const viewManagerConfig = UIManager.getViewManagerConfig(COMPONENT_NAME);
|
|
23
|
+
if (viewManagerConfig?.Commands?.showTextInput) {
|
|
24
|
+
const nodeHandle = findNodeHandle(ref);
|
|
25
|
+
if (nodeHandle != null) {
|
|
26
|
+
UIManager.dispatchViewManagerCommand(nodeHandle, viewManagerConfig.Commands.showTextInput, []);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["requireNativeComponent","UIManager","findNodeHandle","COMPONENT_NAME","StoryEditorView","StoryEditorCommands","exportImage","ref","viewManagerConfig","getViewManagerConfig","Commands","nodeHandle","dispatchViewManagerCommand","showTextInput"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,sBAAsB,EAAEC,SAAS,EAAEC,cAAc,QAAQ,cAAc;AAGhF,MAAMC,cAAc,GAAG,mBAAmB;;AAE1C;;AAUA,OAAO,MAAMC,eAAe,GAAGJ,sBAAsB,CAAcG,cAAc,CAAC;;AAElF;AACA,OAAO,MAAME,mBAAmB,GAAG;EACjCC,WAAW,EAAGC,GAAQ,IAAK;IACzB,MAAMC,iBAAiB,GAAGP,SAAS,CAACQ,oBAAoB,CAACN,cAAc,CAA6B;IACpG,IAAIK,iBAAiB,EAAEE,QAAQ,EAAEJ,WAAW,EAAE;MAC5C,MAAMK,UAAU,GAAGT,cAAc,CAACK,GAAG,CAAC;MACtC,IAAII,UAAU,IAAI,IAAI,EAAE;QACtBV,SAAS,CAACW,0BAA0B,CAClCD,UAAU,EACVH,iBAAiB,CAACE,QAAQ,CAACJ,WAAW,EACtC,EACF,CAAC;MACH;IACF;EACF,CAAC;EAEDO,aAAa,EAAGN,GAAQ,IAAK;IAC3B,MAAMC,iBAAiB,GAAGP,SAAS,CAACQ,oBAAoB,CAACN,cAAc,CAA6B;IACpG,IAAIK,iBAAiB,EAAEE,QAAQ,EAAEG,aAAa,EAAE;MAC9C,MAAMF,UAAU,GAAGT,cAAc,CAACK,GAAG,CAAC;MACtC,IAAII,UAAU,IAAI,IAAI,EAAE;QACtBV,SAAS,CAACW,0BAA0B,CAClCD,UAAU,EACVH,iBAAiB,CAACE,QAAQ,CAACG,aAAa,EACxC,EACF,CAAC;MACH;IACF;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ColorValue, type ViewProps } from 'react-native';
|
|
2
|
+
interface NativeProps extends ViewProps {
|
|
3
|
+
color?: ColorValue;
|
|
4
|
+
colorString?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
7
|
+
export default _default;
|
|
8
|
+
export type { NativeProps };
|
|
9
|
+
//# sourceMappingURL=RnStoryEditorViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RnStoryEditorViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RnStoryEditorViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,UAAU,WAAY,SAAQ,SAAS;IACrC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;AAED,wBAAwE;AAGxE,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NativeProps } from './RnStoryEditorViewNativeComponent';
|
|
2
|
+
export declare const StoryEditorView: import("react-native").HostComponent<NativeProps>;
|
|
3
|
+
export declare const StoryEditorCommands: {
|
|
4
|
+
exportImage: (ref: any) => void;
|
|
5
|
+
showTextInput: (ref: any) => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AActE,eAAO,MAAM,eAAe,mDAAsD,CAAC;AAGnF,eAAO,MAAM,mBAAmB;uBACX,GAAG;yBAcD,GAAG;CAazB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-rn-story-editor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "This is library for the Editing tools ",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-rn-story-editor-example",
|
|
36
|
+
"example:android": "cd example && npx react-native run-android",
|
|
37
|
+
"example:ios": "cd example && npx react-native run-ios",
|
|
38
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
39
|
+
"prepare": "bob build",
|
|
40
|
+
"typecheck": "tsc",
|
|
41
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
42
|
+
"test": "jest",
|
|
43
|
+
"release": "release-it --only-version"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"react-native",
|
|
47
|
+
"ios",
|
|
48
|
+
"android"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/joshiidhaval/react-native-rn-story-editor.git"
|
|
53
|
+
},
|
|
54
|
+
"author": "Dhaval Joshi Pote <joshiidhaval@gmail.com> (https://github.com/joshiidhaval)",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/joshiidhaval/react-native-rn-story-editor/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/joshiidhaval/react-native-rn-story-editor#readme",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
65
|
+
"@eslint/compat": "^1.3.2",
|
|
66
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
67
|
+
"@eslint/js": "^9.35.0",
|
|
68
|
+
"@react-native-community/cli": "latest",
|
|
69
|
+
"@react-native/babel-preset": "0.83.0",
|
|
70
|
+
"@react-native/eslint-config": "0.83.0",
|
|
71
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
72
|
+
"@testing-library/jest-native": "^5.4.3",
|
|
73
|
+
"@testing-library/react-native": "^13.3.3",
|
|
74
|
+
"@types/jest": "^29.5.14",
|
|
75
|
+
"@types/react": "^19.2.0",
|
|
76
|
+
"@types/react-test-renderer": "^19",
|
|
77
|
+
"commitlint": "^19.8.1",
|
|
78
|
+
"del-cli": "^6.0.0",
|
|
79
|
+
"eslint": "^8.57.0",
|
|
80
|
+
"eslint-config-prettier": "^9.1.0",
|
|
81
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
82
|
+
"jest": "^29.7.0",
|
|
83
|
+
"lefthook": "^2.0.3",
|
|
84
|
+
"prettier": "^3.2.5",
|
|
85
|
+
"react": "19.2.0",
|
|
86
|
+
"react-native": "0.83.0",
|
|
87
|
+
"react-native-builder-bob": "^0.40.18",
|
|
88
|
+
"react-test-renderer": "19.2.0",
|
|
89
|
+
"release-it": "^19.0.4",
|
|
90
|
+
"turbo": "^2.5.6",
|
|
91
|
+
"typescript": "^5.9.2"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"react": "*",
|
|
95
|
+
"react-native": "*"
|
|
96
|
+
},
|
|
97
|
+
"workspaces": [
|
|
98
|
+
"example"
|
|
99
|
+
],
|
|
100
|
+
"packageManager": "yarn@4.11.0",
|
|
101
|
+
"react-native-builder-bob": {
|
|
102
|
+
"source": "src",
|
|
103
|
+
"output": "lib",
|
|
104
|
+
"targets": [
|
|
105
|
+
[
|
|
106
|
+
"module",
|
|
107
|
+
{
|
|
108
|
+
"esm": true
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"typescript",
|
|
113
|
+
{
|
|
114
|
+
"project": "tsconfig.build.json"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"codegenConfig": {
|
|
120
|
+
"name": "RnStoryEditorViewSpec",
|
|
121
|
+
"type": "all",
|
|
122
|
+
"jsSrcsDir": "src",
|
|
123
|
+
"android": {
|
|
124
|
+
"javaPackageName": "com.rnstoryeditor"
|
|
125
|
+
},
|
|
126
|
+
"ios": {
|
|
127
|
+
"components": {
|
|
128
|
+
"RnStoryEditorView": {
|
|
129
|
+
"className": "RnStoryEditorView"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"prettier": {
|
|
135
|
+
"quoteProps": "consistent",
|
|
136
|
+
"singleQuote": true,
|
|
137
|
+
"tabWidth": 2,
|
|
138
|
+
"trailingComma": "es5",
|
|
139
|
+
"useTabs": false
|
|
140
|
+
},
|
|
141
|
+
"jest": {
|
|
142
|
+
"preset": "react-native",
|
|
143
|
+
"modulePathIgnorePatterns": [
|
|
144
|
+
"<rootDir>/example/node_modules",
|
|
145
|
+
"<rootDir>/lib/"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"commitlint": {
|
|
149
|
+
"extends": [
|
|
150
|
+
"@commitlint/config-conventional"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
"release-it": {
|
|
154
|
+
"git": {
|
|
155
|
+
"commitMessage": "chore: release ${version}",
|
|
156
|
+
"tagName": "v${version}"
|
|
157
|
+
},
|
|
158
|
+
"npm": {
|
|
159
|
+
"publish": true
|
|
160
|
+
},
|
|
161
|
+
"github": {
|
|
162
|
+
"release": true
|
|
163
|
+
},
|
|
164
|
+
"plugins": {
|
|
165
|
+
"@release-it/conventional-changelog": {
|
|
166
|
+
"preset": {
|
|
167
|
+
"name": "angular"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"create-react-native-library": {
|
|
173
|
+
"type": "fabric-view",
|
|
174
|
+
"languages": "kotlin-objc",
|
|
175
|
+
"tools": [
|
|
176
|
+
"eslint",
|
|
177
|
+
"jest",
|
|
178
|
+
"lefthook",
|
|
179
|
+
"release-it"
|
|
180
|
+
],
|
|
181
|
+
"version": "0.57.2"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
interface NativeProps extends ViewProps {
|
|
8
|
+
color?: ColorValue;
|
|
9
|
+
colorString?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default codegenNativeComponent<NativeProps>('RnStoryEditorView');
|
|
13
|
+
|
|
14
|
+
// Export the component with proper types
|
|
15
|
+
export type { NativeProps };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { requireNativeComponent, UIManager, findNodeHandle } from 'react-native';
|
|
2
|
+
import type { NativeProps } from './RnStoryEditorViewNativeComponent';
|
|
3
|
+
|
|
4
|
+
const COMPONENT_NAME = 'RnStoryEditorView';
|
|
5
|
+
|
|
6
|
+
// Type definition for view manager commands
|
|
7
|
+
interface ViewManagerCommands {
|
|
8
|
+
exportImage: number;
|
|
9
|
+
showTextInput: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ViewManagerConfig {
|
|
13
|
+
Commands?: ViewManagerCommands;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const StoryEditorView = requireNativeComponent<NativeProps>(COMPONENT_NAME);
|
|
17
|
+
|
|
18
|
+
// Commands
|
|
19
|
+
export const StoryEditorCommands = {
|
|
20
|
+
exportImage: (ref: any) => {
|
|
21
|
+
const viewManagerConfig = UIManager.getViewManagerConfig(COMPONENT_NAME) as ViewManagerConfig | null;
|
|
22
|
+
if (viewManagerConfig?.Commands?.exportImage) {
|
|
23
|
+
const nodeHandle = findNodeHandle(ref);
|
|
24
|
+
if (nodeHandle != null) {
|
|
25
|
+
UIManager.dispatchViewManagerCommand(
|
|
26
|
+
nodeHandle,
|
|
27
|
+
viewManagerConfig.Commands.exportImage,
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
showTextInput: (ref: any) => {
|
|
35
|
+
const viewManagerConfig = UIManager.getViewManagerConfig(COMPONENT_NAME) as ViewManagerConfig | null;
|
|
36
|
+
if (viewManagerConfig?.Commands?.showTextInput) {
|
|
37
|
+
const nodeHandle = findNodeHandle(ref);
|
|
38
|
+
if (nodeHandle != null) {
|
|
39
|
+
UIManager.dispatchViewManagerCommand(
|
|
40
|
+
nodeHandle,
|
|
41
|
+
viewManagerConfig.Commands.showTextInput,
|
|
42
|
+
[]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|