rn-rich-text-editor 1.0.7 → 1.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/package.json +1 -1
- package/src/Editor.js +4 -1
- package/src/Toolbar.js +1 -1
- package/src/editor/createHTML.js +10 -6
package/package.json
CHANGED
package/src/Editor.js
CHANGED
|
@@ -115,7 +115,7 @@ export default class Editor extends Component {
|
|
|
115
115
|
})),
|
|
116
116
|
},
|
|
117
117
|
keyboardHeight: 0,
|
|
118
|
-
height: initialHeight > 0 ? initialHeight : DEFAULT_EDITOR_HEIGHT,
|
|
118
|
+
height: readOnly ? 1 : (initialHeight > 0 ? initialHeight : DEFAULT_EDITOR_HEIGHT),
|
|
119
119
|
};
|
|
120
120
|
that.focusListeners = [];
|
|
121
121
|
}
|
|
@@ -215,6 +215,9 @@ export default class Editor extends Component {
|
|
|
215
215
|
onInput?.(data);
|
|
216
216
|
break;
|
|
217
217
|
case messages.OFFSET_HEIGHT:
|
|
218
|
+
if (that.props.readOnly) {
|
|
219
|
+
that.setState({ height: Number(data) || 1 });
|
|
220
|
+
}
|
|
218
221
|
that.setWebHeight(data);
|
|
219
222
|
break;
|
|
220
223
|
case messages.OFFSET_Y:
|
package/src/Toolbar.js
CHANGED
|
@@ -465,7 +465,7 @@ export default class Toolbar extends Component {
|
|
|
465
465
|
const disabledStyle = disabled ? { backgroundColor: '#C9CED7' } : {};
|
|
466
466
|
const vStyle = [styles.barContainer, disabledStyle, style, disabled && this._getButtonDisabledStyle()];
|
|
467
467
|
const barBg = (style && style.backgroundColor) || (disabled && '#C9CED7') || TOOLBAR_BG;
|
|
468
|
-
const showFades = horizontal;
|
|
468
|
+
const showFades = horizontal && !disabled;
|
|
469
469
|
return (
|
|
470
470
|
<View style={vStyle}>
|
|
471
471
|
<View style={styles.scrollWrapper} onLayout={showFades ? this._onLayout : undefined}>
|
package/src/editor/createHTML.js
CHANGED
|
@@ -772,7 +772,7 @@ function escapeForScript(s) {
|
|
|
772
772
|
}
|
|
773
773
|
|
|
774
774
|
/**
|
|
775
|
-
* Creates minimal HTML for read-only display: content
|
|
775
|
+
* Creates minimal HTML for read-only display: content expands to full height, no scroll.
|
|
776
776
|
* No editor, no toolbar. Content is escaped and embedded in the template.
|
|
777
777
|
*/
|
|
778
778
|
function createReadOnlyHTML(options = {}) {
|
|
@@ -793,12 +793,9 @@ function createReadOnlyHTML(options = {}) {
|
|
|
793
793
|
<style>
|
|
794
794
|
${initialCSSText}
|
|
795
795
|
* { outline: 0; -webkit-tap-highlight-color: rgba(0,0,0,0); box-sizing: border-box; }
|
|
796
|
-
html, body { margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size: 1em;
|
|
796
|
+
html, body { margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size: 1em; }
|
|
797
797
|
body { background-color: ${backgroundColor}; color: ${color}; }
|
|
798
798
|
.readonly-container {
|
|
799
|
-
height: 100%;
|
|
800
|
-
overflow-y: auto;
|
|
801
|
-
-webkit-overflow-scrolling: touch;
|
|
802
799
|
padding: 0;
|
|
803
800
|
${contentCSSText}
|
|
804
801
|
}
|
|
@@ -814,9 +811,16 @@ function createReadOnlyHTML(options = {}) {
|
|
|
814
811
|
var el = document.getElementById('readonly-content');
|
|
815
812
|
if (el) {
|
|
816
813
|
el.innerHTML = content;
|
|
814
|
+
var sendHeight = function() {
|
|
815
|
+
var h = document.body.scrollHeight;
|
|
816
|
+
if (window.ReactNativeWebView) {
|
|
817
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({type: 'OFFSET_HEIGHT', data: h}));
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
setTimeout(sendHeight, 0);
|
|
817
821
|
}
|
|
818
822
|
})();
|
|
819
|
-
|
|
823
|
+
<\/script>
|
|
820
824
|
</body>
|
|
821
825
|
</html>
|
|
822
826
|
`;
|