@hero-design/rn 7.20.0 → 7.20.1
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/.turbo/turbo-build.log +2 -2
- package/es/index.js +40 -48
- package/lib/index.js +40 -48
- package/package.json +2 -2
- package/src/components/RichTextEditor/EditorToolbar.tsx +19 -18
- package/src/components/RichTextEditor/RichTextEditor.tsx +7 -2
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -2
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +7 -4
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -10
- package/src/components/RichTextEditor/constants.ts +0 -11
- package/src/components/RichTextEditor/index.tsx +0 -3
- package/src/components/RichTextEditor/types.ts +9 -0
- package/src/types.ts +0 -2
- package/types/components/RichTextEditor/EditorToolbar.d.ts +1 -1
- package/types/components/RichTextEditor/RichTextEditor.d.ts +4 -0
- package/types/components/RichTextEditor/constants.d.ts +0 -10
- package/types/components/RichTextEditor/index.d.ts +0 -2
- package/types/components/RichTextEditor/types.d.ts +1 -0
- package/types/types.d.ts +1 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
[32m@hero-design/rn:build[0m: cache hit, replaying output [
|
|
1
|
+
[32m@hero-design/rn:build[0m: cache hit, replaying output [2m1b069a9172aa77c0[0m
|
|
2
2
|
[32m@hero-design/rn:build: [0m$ yarn build:js && yarn build:types
|
|
3
3
|
[32m@hero-design/rn:build: [0m$ rollup -c
|
|
4
4
|
[32m@hero-design/rn:build: [0m[36m
|
|
5
5
|
[32m@hero-design/rn:build: [0m[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
6
6
|
[32m@hero-design/rn:build: [0m[1m[33m(!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
7
7
|
[32m@hero-design/rn:build: [0m[1m[33m(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
8
|
-
[32m@hero-design/rn:build: [0m[32mcreated [1mlib/index.js, es/index.js[22m in [
|
|
8
|
+
[32m@hero-design/rn:build: [0m[32mcreated [1mlib/index.js, es/index.js[22m in [1m23.1s[22m[39m
|
|
9
9
|
[32m@hero-design/rn:build: [0m$ tsc --noEmit false --emitDeclarationOnly
|
package/es/index.js
CHANGED
|
@@ -22780,19 +22780,6 @@ var ToolbarEvents;
|
|
|
22780
22780
|
ToolbarEvents["HeadingTwo"] = "heading-two";
|
|
22781
22781
|
})(ToolbarEvents || (ToolbarEvents = {}));
|
|
22782
22782
|
|
|
22783
|
-
var ToolbarButtonName;
|
|
22784
|
-
|
|
22785
|
-
(function (ToolbarButtonName) {
|
|
22786
|
-
ToolbarButtonName["Bold"] = "bold";
|
|
22787
|
-
ToolbarButtonName["Italic"] = "italic";
|
|
22788
|
-
ToolbarButtonName["Underline"] = "underline";
|
|
22789
|
-
ToolbarButtonName["BulletedList"] = "bulletedList";
|
|
22790
|
-
ToolbarButtonName["NumberedList"] = "numberedList";
|
|
22791
|
-
ToolbarButtonName["HeadingOne"] = "headingOne";
|
|
22792
|
-
ToolbarButtonName["HeadingTwo"] = "headingTwo";
|
|
22793
|
-
ToolbarButtonName["Seperator"] = "|";
|
|
22794
|
-
})(ToolbarButtonName || (ToolbarButtonName = {}));
|
|
22795
|
-
|
|
22796
22783
|
var emitter = new EventEmitter();
|
|
22797
22784
|
emitter.setMaxListeners(20);
|
|
22798
22785
|
|
|
@@ -22840,8 +22827,6 @@ var on = function on(emitter, eventName, listener) {
|
|
|
22840
22827
|
};
|
|
22841
22828
|
};
|
|
22842
22829
|
|
|
22843
|
-
var _buttonConfigs;
|
|
22844
|
-
|
|
22845
22830
|
var ToolbarButton = function ToolbarButton(_ref) {
|
|
22846
22831
|
var icon = _ref.icon,
|
|
22847
22832
|
onPress = _ref.onPress,
|
|
@@ -22857,33 +22842,41 @@ var ToolbarButton = function ToolbarButton(_ref) {
|
|
|
22857
22842
|
}));
|
|
22858
22843
|
};
|
|
22859
22844
|
|
|
22860
|
-
var buttonConfigs =
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
}
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22845
|
+
var buttonConfigs = {
|
|
22846
|
+
bold: {
|
|
22847
|
+
icon: 'format-bold',
|
|
22848
|
+
eventName: ToolbarEvents.Bold
|
|
22849
|
+
},
|
|
22850
|
+
italic: {
|
|
22851
|
+
icon: 'format-italic',
|
|
22852
|
+
eventName: ToolbarEvents.Italic
|
|
22853
|
+
},
|
|
22854
|
+
underline: {
|
|
22855
|
+
icon: 'format-underlined',
|
|
22856
|
+
eventName: ToolbarEvents.Underline
|
|
22857
|
+
},
|
|
22858
|
+
bulletedList: {
|
|
22859
|
+
icon: 'format-list-bulleted',
|
|
22860
|
+
eventName: ToolbarEvents.BulletedList,
|
|
22861
|
+
standalone: true
|
|
22862
|
+
},
|
|
22863
|
+
numberedList: {
|
|
22864
|
+
icon: 'format-list-numbered',
|
|
22865
|
+
eventName: ToolbarEvents.NumberedList,
|
|
22866
|
+
standalone: true
|
|
22867
|
+
},
|
|
22868
|
+
headingOne: {
|
|
22869
|
+
icon: 'format-heading1',
|
|
22870
|
+
eventName: ToolbarEvents.HeadingOne,
|
|
22871
|
+
standalone: true
|
|
22872
|
+
},
|
|
22873
|
+
headingTwo: {
|
|
22874
|
+
icon: 'format-heading2',
|
|
22875
|
+
eventName: ToolbarEvents.HeadingTwo,
|
|
22876
|
+
standalone: true
|
|
22877
|
+
}
|
|
22878
|
+
};
|
|
22879
|
+
var defaultButtons = ['bold', 'italic', 'underline', '|', 'bulletedList', 'numberedList', '|', 'headingOne', 'headingTwo'];
|
|
22887
22880
|
|
|
22888
22881
|
var EditorToolbar = function EditorToolbar(_ref2) {
|
|
22889
22882
|
var name = _ref2.name,
|
|
@@ -22947,7 +22940,7 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
22947
22940
|
}, []);
|
|
22948
22941
|
var toolbarButtons = useMemo(function () {
|
|
22949
22942
|
return toolbarButtonArray.map(function (button) {
|
|
22950
|
-
if (button.buttonName ===
|
|
22943
|
+
if (button.buttonName === '|') {
|
|
22951
22944
|
return /*#__PURE__*/React.createElement(StyledSeparator, {
|
|
22952
22945
|
key: button.id
|
|
22953
22946
|
});
|
|
@@ -40798,8 +40791,6 @@ var StyledWebView = index$7(WebView)(function (_ref2) {
|
|
|
40798
40791
|
backgroundColor: 'transparent',
|
|
40799
40792
|
textAlignVertical: 'center',
|
|
40800
40793
|
fontSize: theme.__hd__.textInput.fontSizes.text,
|
|
40801
|
-
alignSelf: 'stretch',
|
|
40802
|
-
flexGrow: 2,
|
|
40803
40794
|
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
40804
40795
|
};
|
|
40805
40796
|
});
|
|
@@ -40825,7 +40816,9 @@ var defaultValue = [{
|
|
|
40825
40816
|
}];
|
|
40826
40817
|
|
|
40827
40818
|
var RichTextEditor = function RichTextEditor(_ref) {
|
|
40828
|
-
var
|
|
40819
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
40820
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
40821
|
+
name = _ref.name,
|
|
40829
40822
|
_ref$placeholder = _ref.placeholder,
|
|
40830
40823
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
40831
40824
|
_ref$onChange = _ref.onChange,
|
|
@@ -40899,7 +40892,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
40899
40892
|
}, []);
|
|
40900
40893
|
var html = useMemo(function () {
|
|
40901
40894
|
var initialValueString = JSON.stringify(value);
|
|
40902
|
-
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus:
|
|
40895
|
+
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus: ").concat(autoFocus, ",\n style: {\n padding: '0 !important',\n fontSize: ").concat(theme.__hd__.richTextEditor.fontSizes.editor, "\n }\n };\n ").concat(heroEditorApp, "\n </script>\n </body>\n </html>\n ");
|
|
40903
40896
|
}, []);
|
|
40904
40897
|
var requestBlur = useCallback(function () {
|
|
40905
40898
|
if (webview.current) {
|
|
@@ -40985,7 +40978,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
40985
40978
|
}
|
|
40986
40979
|
}, []);
|
|
40987
40980
|
return /*#__PURE__*/React.createElement(StyledContainer$3, {
|
|
40988
|
-
style: style,
|
|
40989
40981
|
testID: testID
|
|
40990
40982
|
}, /*#__PURE__*/React.createElement(StyledTextInputContainer, null, /*#__PURE__*/React.createElement(StyledBorderBackDrop, {
|
|
40991
40983
|
themeVariant: variant
|
package/lib/index.js
CHANGED
|
@@ -22808,19 +22808,6 @@ var ToolbarEvents;
|
|
|
22808
22808
|
ToolbarEvents["HeadingTwo"] = "heading-two";
|
|
22809
22809
|
})(ToolbarEvents || (ToolbarEvents = {}));
|
|
22810
22810
|
|
|
22811
|
-
var ToolbarButtonName;
|
|
22812
|
-
|
|
22813
|
-
(function (ToolbarButtonName) {
|
|
22814
|
-
ToolbarButtonName["Bold"] = "bold";
|
|
22815
|
-
ToolbarButtonName["Italic"] = "italic";
|
|
22816
|
-
ToolbarButtonName["Underline"] = "underline";
|
|
22817
|
-
ToolbarButtonName["BulletedList"] = "bulletedList";
|
|
22818
|
-
ToolbarButtonName["NumberedList"] = "numberedList";
|
|
22819
|
-
ToolbarButtonName["HeadingOne"] = "headingOne";
|
|
22820
|
-
ToolbarButtonName["HeadingTwo"] = "headingTwo";
|
|
22821
|
-
ToolbarButtonName["Seperator"] = "|";
|
|
22822
|
-
})(ToolbarButtonName || (ToolbarButtonName = {}));
|
|
22823
|
-
|
|
22824
22811
|
var emitter = new events.EventEmitter();
|
|
22825
22812
|
emitter.setMaxListeners(20);
|
|
22826
22813
|
|
|
@@ -22868,8 +22855,6 @@ var on = function on(emitter, eventName, listener) {
|
|
|
22868
22855
|
};
|
|
22869
22856
|
};
|
|
22870
22857
|
|
|
22871
|
-
var _buttonConfigs;
|
|
22872
|
-
|
|
22873
22858
|
var ToolbarButton = function ToolbarButton(_ref) {
|
|
22874
22859
|
var icon = _ref.icon,
|
|
22875
22860
|
onPress = _ref.onPress,
|
|
@@ -22885,33 +22870,41 @@ var ToolbarButton = function ToolbarButton(_ref) {
|
|
|
22885
22870
|
}));
|
|
22886
22871
|
};
|
|
22887
22872
|
|
|
22888
|
-
var buttonConfigs =
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
|
|
22897
|
-
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
}
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22873
|
+
var buttonConfigs = {
|
|
22874
|
+
bold: {
|
|
22875
|
+
icon: 'format-bold',
|
|
22876
|
+
eventName: ToolbarEvents.Bold
|
|
22877
|
+
},
|
|
22878
|
+
italic: {
|
|
22879
|
+
icon: 'format-italic',
|
|
22880
|
+
eventName: ToolbarEvents.Italic
|
|
22881
|
+
},
|
|
22882
|
+
underline: {
|
|
22883
|
+
icon: 'format-underlined',
|
|
22884
|
+
eventName: ToolbarEvents.Underline
|
|
22885
|
+
},
|
|
22886
|
+
bulletedList: {
|
|
22887
|
+
icon: 'format-list-bulleted',
|
|
22888
|
+
eventName: ToolbarEvents.BulletedList,
|
|
22889
|
+
standalone: true
|
|
22890
|
+
},
|
|
22891
|
+
numberedList: {
|
|
22892
|
+
icon: 'format-list-numbered',
|
|
22893
|
+
eventName: ToolbarEvents.NumberedList,
|
|
22894
|
+
standalone: true
|
|
22895
|
+
},
|
|
22896
|
+
headingOne: {
|
|
22897
|
+
icon: 'format-heading1',
|
|
22898
|
+
eventName: ToolbarEvents.HeadingOne,
|
|
22899
|
+
standalone: true
|
|
22900
|
+
},
|
|
22901
|
+
headingTwo: {
|
|
22902
|
+
icon: 'format-heading2',
|
|
22903
|
+
eventName: ToolbarEvents.HeadingTwo,
|
|
22904
|
+
standalone: true
|
|
22905
|
+
}
|
|
22906
|
+
};
|
|
22907
|
+
var defaultButtons = ['bold', 'italic', 'underline', '|', 'bulletedList', 'numberedList', '|', 'headingOne', 'headingTwo'];
|
|
22915
22908
|
|
|
22916
22909
|
var EditorToolbar = function EditorToolbar(_ref2) {
|
|
22917
22910
|
var name = _ref2.name,
|
|
@@ -22975,7 +22968,7 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
22975
22968
|
}, []);
|
|
22976
22969
|
var toolbarButtons = React.useMemo(function () {
|
|
22977
22970
|
return toolbarButtonArray.map(function (button) {
|
|
22978
|
-
if (button.buttonName ===
|
|
22971
|
+
if (button.buttonName === '|') {
|
|
22979
22972
|
return /*#__PURE__*/React__default["default"].createElement(StyledSeparator, {
|
|
22980
22973
|
key: button.id
|
|
22981
22974
|
});
|
|
@@ -40826,8 +40819,6 @@ var StyledWebView = index$7(reactNativeWebview.WebView)(function (_ref2) {
|
|
|
40826
40819
|
backgroundColor: 'transparent',
|
|
40827
40820
|
textAlignVertical: 'center',
|
|
40828
40821
|
fontSize: theme.__hd__.textInput.fontSizes.text,
|
|
40829
|
-
alignSelf: 'stretch',
|
|
40830
|
-
flexGrow: 2,
|
|
40831
40822
|
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
40832
40823
|
};
|
|
40833
40824
|
});
|
|
@@ -40853,7 +40844,9 @@ var defaultValue = [{
|
|
|
40853
40844
|
}];
|
|
40854
40845
|
|
|
40855
40846
|
var RichTextEditor = function RichTextEditor(_ref) {
|
|
40856
|
-
var
|
|
40847
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
40848
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
40849
|
+
name = _ref.name,
|
|
40857
40850
|
_ref$placeholder = _ref.placeholder,
|
|
40858
40851
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
40859
40852
|
_ref$onChange = _ref.onChange,
|
|
@@ -40927,7 +40920,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
40927
40920
|
}, []);
|
|
40928
40921
|
var html = React.useMemo(function () {
|
|
40929
40922
|
var initialValueString = JSON.stringify(value);
|
|
40930
|
-
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus:
|
|
40923
|
+
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus: ").concat(autoFocus, ",\n style: {\n padding: '0 !important',\n fontSize: ").concat(theme.__hd__.richTextEditor.fontSizes.editor, "\n }\n };\n ").concat(heroEditorApp, "\n </script>\n </body>\n </html>\n ");
|
|
40931
40924
|
}, []);
|
|
40932
40925
|
var requestBlur = React.useCallback(function () {
|
|
40933
40926
|
if (webview.current) {
|
|
@@ -41013,7 +41006,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
41013
41006
|
}
|
|
41014
41007
|
}, []);
|
|
41015
41008
|
return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
|
|
41016
|
-
style: style,
|
|
41017
41009
|
testID: testID
|
|
41018
41010
|
}, /*#__PURE__*/React__default["default"].createElement(StyledTextInputContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledBorderBackDrop, {
|
|
41019
41011
|
themeVariant: variant
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@emotion/native": "^11.9.3",
|
|
22
22
|
"@emotion/react": "^11.9.3",
|
|
23
|
-
"@hero-design/colors": "7.20.
|
|
23
|
+
"@hero-design/colors": "7.20.1",
|
|
24
24
|
"date-fns": "^2.16.1",
|
|
25
25
|
"events": "^3.2.0",
|
|
26
26
|
"hero-editor": "^1.9.9"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import Icon from '../Icon';
|
|
4
|
-
import {
|
|
4
|
+
import { ToolbarEvents } from './constants';
|
|
5
5
|
import { emitter } from './EditorEvent';
|
|
6
6
|
import {
|
|
7
7
|
StyledSeparator,
|
|
8
8
|
StyledToolbar,
|
|
9
9
|
StyledToolbarButton,
|
|
10
10
|
} from './StyledToolbar';
|
|
11
|
+
import { ToolbarButtonName } from './types';
|
|
11
12
|
import * as Events from './utils/events';
|
|
12
13
|
import type { IconProps } from '../Icon';
|
|
13
14
|
|
|
@@ -35,34 +36,34 @@ interface ButtonConfig {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
|
|
38
|
-
|
|
39
|
+
bold: {
|
|
39
40
|
icon: 'format-bold',
|
|
40
41
|
eventName: ToolbarEvents.Bold,
|
|
41
42
|
},
|
|
42
|
-
|
|
43
|
+
italic: {
|
|
43
44
|
icon: 'format-italic',
|
|
44
45
|
eventName: ToolbarEvents.Italic,
|
|
45
46
|
},
|
|
46
|
-
|
|
47
|
+
underline: {
|
|
47
48
|
icon: 'format-underlined',
|
|
48
49
|
eventName: ToolbarEvents.Underline,
|
|
49
50
|
},
|
|
50
|
-
|
|
51
|
+
bulletedList: {
|
|
51
52
|
icon: 'format-list-bulleted',
|
|
52
53
|
eventName: ToolbarEvents.BulletedList,
|
|
53
54
|
standalone: true,
|
|
54
55
|
},
|
|
55
|
-
|
|
56
|
+
numberedList: {
|
|
56
57
|
icon: 'format-list-numbered',
|
|
57
58
|
eventName: ToolbarEvents.NumberedList,
|
|
58
59
|
standalone: true,
|
|
59
60
|
},
|
|
60
|
-
|
|
61
|
+
headingOne: {
|
|
61
62
|
icon: 'format-heading1',
|
|
62
63
|
eventName: ToolbarEvents.HeadingOne,
|
|
63
64
|
standalone: true,
|
|
64
65
|
},
|
|
65
|
-
|
|
66
|
+
headingTwo: {
|
|
66
67
|
icon: 'format-heading2',
|
|
67
68
|
eventName: ToolbarEvents.HeadingTwo,
|
|
68
69
|
standalone: true,
|
|
@@ -70,15 +71,15 @@ const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
const defaultButtons: ToolbarButtonName[] = [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
'bold',
|
|
75
|
+
'italic',
|
|
76
|
+
'underline',
|
|
77
|
+
'|',
|
|
78
|
+
'bulletedList',
|
|
79
|
+
'numberedList',
|
|
80
|
+
'|',
|
|
81
|
+
'headingOne',
|
|
82
|
+
'headingTwo',
|
|
82
83
|
];
|
|
83
84
|
|
|
84
85
|
export interface EditorToolbarProps {
|
|
@@ -180,7 +181,7 @@ const EditorToolbar = ({
|
|
|
180
181
|
const toolbarButtons = useMemo(
|
|
181
182
|
() =>
|
|
182
183
|
toolbarButtonArray.map(button => {
|
|
183
|
-
if (button.buttonName ===
|
|
184
|
+
if (button.buttonName === '|') {
|
|
184
185
|
return <StyledSeparator key={button.id} />;
|
|
185
186
|
}
|
|
186
187
|
const config = buttonConfigs[button.buttonName];
|
|
@@ -51,6 +51,10 @@ export type EditorValue = {
|
|
|
51
51
|
}[];
|
|
52
52
|
|
|
53
53
|
export interface RichTextEditorProps {
|
|
54
|
+
/**
|
|
55
|
+
* If true, the editor will be focused when the user enters the screen
|
|
56
|
+
*/
|
|
57
|
+
autoFocus?: boolean;
|
|
54
58
|
/**
|
|
55
59
|
* Error message
|
|
56
60
|
*/
|
|
@@ -110,6 +114,7 @@ const defaultValue: EditorValue = [
|
|
|
110
114
|
];
|
|
111
115
|
|
|
112
116
|
const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
117
|
+
autoFocus = true,
|
|
113
118
|
name,
|
|
114
119
|
placeholder = '',
|
|
115
120
|
onChange = noop,
|
|
@@ -191,7 +196,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
191
196
|
placeholder: "${placeholder}",
|
|
192
197
|
initialValue: ${initialValueString},
|
|
193
198
|
isAndroid: ${isAndroid ? 'true' : 'false'},
|
|
194
|
-
autoFocus:
|
|
199
|
+
autoFocus: ${autoFocus},
|
|
195
200
|
style: {
|
|
196
201
|
padding: '0 !important',
|
|
197
202
|
fontSize: ${theme.__hd__.richTextEditor.fontSizes.editor}
|
|
@@ -305,7 +310,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
305
310
|
);
|
|
306
311
|
|
|
307
312
|
return (
|
|
308
|
-
<StyledContainer
|
|
313
|
+
<StyledContainer testID={testID}>
|
|
309
314
|
<StyledTextInputContainer>
|
|
310
315
|
<StyledBorderBackDrop themeVariant={variant} />
|
|
311
316
|
{(isFocused || (label && !isEmptyValue)) && (
|
|
@@ -14,7 +14,5 @@ export const StyledWebView = styled(WebView)<{
|
|
|
14
14
|
backgroundColor: 'transparent',
|
|
15
15
|
textAlignVertical: 'center',
|
|
16
16
|
fontSize: theme.__hd__.textInput.fontSizes.text,
|
|
17
|
-
alignSelf: 'stretch',
|
|
18
|
-
flexGrow: 2,
|
|
19
17
|
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin,
|
|
20
18
|
}));
|
|
@@ -94,10 +94,13 @@ describe('RichTextEditor', () => {
|
|
|
94
94
|
Events.on(EditorEventEmitter, 'rich-text-editor/editor-focus', () => {
|
|
95
95
|
emittedEvents.push('called');
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
|
|
98
|
+
act(() => {
|
|
99
|
+
onMessageOfLatestRendering({
|
|
100
|
+
nativeEvent: {
|
|
101
|
+
data: '{"type": "@hero-editor/webview/editor-focus", "data" : {}}',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
101
104
|
});
|
|
102
105
|
expect(emittedEvents).toMatchObject(['called']);
|
|
103
106
|
});
|
|
@@ -8,9 +8,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
8
8
|
"marginVertical": 8,
|
|
9
9
|
"width": "100%",
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
"backgroundColor": "yellow",
|
|
13
|
-
},
|
|
11
|
+
undefined,
|
|
14
12
|
]
|
|
15
13
|
}
|
|
16
14
|
>
|
|
@@ -163,9 +161,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
163
161
|
style={
|
|
164
162
|
Array [
|
|
165
163
|
Object {
|
|
166
|
-
"alignSelf": "stretch",
|
|
167
164
|
"backgroundColor": "transparent",
|
|
168
|
-
"flexGrow": 2,
|
|
169
165
|
"fontSize": 14,
|
|
170
166
|
"height": 480,
|
|
171
167
|
"marginHorizontal": 8,
|
|
@@ -272,9 +268,7 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
272
268
|
"marginVertical": 8,
|
|
273
269
|
"width": "100%",
|
|
274
270
|
},
|
|
275
|
-
|
|
276
|
-
"backgroundColor": "yellow",
|
|
277
|
-
},
|
|
271
|
+
undefined,
|
|
278
272
|
]
|
|
279
273
|
}
|
|
280
274
|
>
|
|
@@ -426,9 +420,7 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
426
420
|
style={
|
|
427
421
|
Array [
|
|
428
422
|
Object {
|
|
429
|
-
"alignSelf": "stretch",
|
|
430
423
|
"backgroundColor": "transparent",
|
|
431
|
-
"flexGrow": 2,
|
|
432
424
|
"fontSize": 14,
|
|
433
425
|
"height": undefined,
|
|
434
426
|
"marginHorizontal": 8,
|
|
@@ -7,14 +7,3 @@ export enum ToolbarEvents {
|
|
|
7
7
|
HeadingOne = 'heading-one',
|
|
8
8
|
HeadingTwo = 'heading-two',
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
export enum ToolbarButtonName {
|
|
12
|
-
Bold = 'bold',
|
|
13
|
-
Italic = 'italic',
|
|
14
|
-
Underline = 'underline',
|
|
15
|
-
BulletedList = 'bulletedList',
|
|
16
|
-
NumberedList = 'numberedList',
|
|
17
|
-
HeadingOne = 'headingOne',
|
|
18
|
-
HeadingTwo = 'headingTwo',
|
|
19
|
-
Seperator = '|',
|
|
20
|
-
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ToolbarButtonName } from './constants';
|
|
2
1
|
import Toolbar from './EditorToolbar';
|
|
3
2
|
import MentionList from './MentionList';
|
|
4
3
|
import RichTextEditor from './RichTextEditor';
|
|
@@ -6,8 +5,6 @@ import type { RichTextEditorProps, RichTextEditorRef } from './RichTextEditor';
|
|
|
6
5
|
|
|
7
6
|
export type { RichTextEditorProps, RichTextEditorRef };
|
|
8
7
|
|
|
9
|
-
export { ToolbarButtonName };
|
|
10
|
-
|
|
11
8
|
export default Object.assign(RichTextEditor, {
|
|
12
9
|
MentionList,
|
|
13
10
|
Toolbar,
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ToolbarButtonName } from './components/RichTextEditor';
|
|
2
1
|
import type { BottomNavigationTabType } from './components/BottomNavigation';
|
|
3
2
|
import type { IconName } from './components/Icon';
|
|
4
3
|
import type { SingleSelectProps, MultiSelectProps } from './components/Select';
|
|
@@ -26,5 +25,4 @@ export type {
|
|
|
26
25
|
TabType,
|
|
27
26
|
TextInputProps,
|
|
28
27
|
Theme,
|
|
29
|
-
ToolbarButtonName,
|
|
30
28
|
};
|
|
@@ -7,13 +7,3 @@ export declare enum ToolbarEvents {
|
|
|
7
7
|
HeadingOne = "heading-one",
|
|
8
8
|
HeadingTwo = "heading-two"
|
|
9
9
|
}
|
|
10
|
-
export declare enum ToolbarButtonName {
|
|
11
|
-
Bold = "bold",
|
|
12
|
-
Italic = "italic",
|
|
13
|
-
Underline = "underline",
|
|
14
|
-
BulletedList = "bulletedList",
|
|
15
|
-
NumberedList = "numberedList",
|
|
16
|
-
HeadingOne = "headingOne",
|
|
17
|
-
HeadingTwo = "headingTwo",
|
|
18
|
-
Seperator = "|"
|
|
19
|
-
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ToolbarButtonName } from './constants';
|
|
2
1
|
import type { RichTextEditorProps, RichTextEditorRef } from './RichTextEditor';
|
|
3
2
|
export type { RichTextEditorProps, RichTextEditorRef };
|
|
4
|
-
export { ToolbarButtonName };
|
|
5
3
|
declare const _default: import("react").ForwardRefExoticComponent<Omit<RichTextEditorProps, "forwardedRef"> & import("react").RefAttributes<RichTextEditorRef>> & {
|
|
6
4
|
MentionList: ({ name: eventPrefix, render }: import("./MentionList").MentionListProps) => JSX.Element;
|
|
7
5
|
Toolbar: ({ name, buttons, testID, }: import("./EditorToolbar").EditorToolbarProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ToolbarButtonName = 'bold' | 'italic' | 'underline' | 'bulletedList' | 'numberedList' | 'headingOne' | 'headingTwo' | '|';
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ToolbarButtonName } from './components/RichTextEditor';
|
|
2
1
|
import type { BottomNavigationTabType } from './components/BottomNavigation';
|
|
3
2
|
import type { IconName } from './components/Icon';
|
|
4
3
|
import type { SingleSelectProps, MultiSelectProps } from './components/Select';
|
|
@@ -7,4 +6,4 @@ import type { TextInputProps } from './components/TextInput';
|
|
|
7
6
|
import type { RichTextEditorRef, RichTextEditorProps } from './components/RichTextEditor';
|
|
8
7
|
import type { Theme } from './theme';
|
|
9
8
|
import type { ListRenderOptionInfo, SectionListRenderOptionInfo } from './components/Select/types';
|
|
10
|
-
export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, Theme,
|
|
9
|
+
export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, Theme, };
|