Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 56329e5

Browse files
committed
update source file location and copy config for android
1 parent 5f71e5a commit 56329e5

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

copyHtml.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ext {
2+
copyEditorHtmlToAppAssets = { dir ->
3+
def fromF = new File(dir, '/draftjs-html-source/draftjs-source.html');
4+
def toF = new File(projectDir, '/src/main/assets/');
5+
println ('Copying Draft js html asset file from ' + fromF.toString() + ' to ' + toF.toString());
6+
7+
copy {
8+
from fromF
9+
into toF
10+
}
11+
}
12+
}

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { Component } from "react";
2-
import { ViewPropTypes } from "react-native";
2+
import { ViewPropTypes, Platform } from "react-native";
33
import WebView from "react-native-webview";
44
import PropTypes from "prop-types";
55

6-
const draftJsHtml = require("./draftjs-html-source/index.html");
6+
const draftJsHtml = require("./draftjs-html-source/draftjs-source.html");
77

88
class RNDraftView extends Component {
99
static propTypes = {
@@ -66,7 +66,6 @@ class RNDraftView extends Component {
6666
blockRenderMap,
6767
onEditorReady = () => null
6868
} = this.props;
69-
onEditorReady();
7069
if (defaultValue) {
7170
this.executeScript("setDefaultValue", defaultValue);
7271
}
@@ -93,6 +92,7 @@ class RNDraftView extends Component {
9392
console.error(e);
9493
}
9594
}
95+
onEditorReady();
9696
};
9797

9898
focus = () => {
@@ -109,7 +109,14 @@ class RNDraftView extends Component {
109109
<WebView
110110
ref={this._webViewRef}
111111
style={style}
112-
source={draftJsHtml}
112+
source={
113+
Platform.OS === "ios"
114+
? draftJsHtml
115+
: { uri: "file:///android_asset/draftjs-source.html" }
116+
}
117+
useWebKit={true}
118+
keyboardDisplayRequiresUserAction={false}
119+
originWhitelist={["*"]}
113120
onMessage={this._onMessage}
114121
/>
115122
);

0 commit comments

Comments
 (0)