@kids-reporter/draft-editor 0.4.1 → 0.4.2

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.
@@ -5,35 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BlockquoteButton = BlockquoteButton;
7
7
  exports.BlockquoteInput = BlockquoteInput;
8
-
9
8
  var _react = _interopRequireWildcard(require("react"));
10
-
11
9
  var _draftJs = require("draft-js");
12
-
13
10
  var _modals = require("@keystone-ui/modals");
14
-
15
11
  var _select = require("./select");
16
-
17
12
  var _fields = require("@keystone-ui/fields");
18
-
19
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
-
21
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
-
23
- var BlockquoteTypeEnum;
24
-
25
- (function (BlockquoteTypeEnum) {
15
+ var BlockquoteTypeEnum = /*#__PURE__*/function (BlockquoteTypeEnum) {
26
16
  BlockquoteTypeEnum["borderLeft"] = "border_left";
27
17
  BlockquoteTypeEnum["quoteLeft"] = "quote_left";
28
- })(BlockquoteTypeEnum || (BlockquoteTypeEnum = {}));
29
-
30
- var BlockquoteLabelEnum;
31
-
32
- (function (BlockquoteLabelEnum) {
18
+ return BlockquoteTypeEnum;
19
+ }(BlockquoteTypeEnum || {});
20
+ var BlockquoteLabelEnum = /*#__PURE__*/function (BlockquoteLabelEnum) {
33
21
  BlockquoteLabelEnum["borderLeft"] = "\u5DE6\u908A\u6846";
34
22
  BlockquoteLabelEnum["quoteLeft"] = "\u5DE6\u5F15\u865F";
35
- })(BlockquoteLabelEnum || (BlockquoteLabelEnum = {}));
36
-
23
+ return BlockquoteLabelEnum;
24
+ }(BlockquoteLabelEnum || {});
37
25
  function BlockquoteInput({
38
26
  isOpen,
39
27
  onConfirm,
@@ -41,15 +29,14 @@ function BlockquoteInput({
41
29
  inputValue
42
30
  }) {
43
31
  const [inputValueState, setInputValueState] = (0, _react.useState)(inputValue);
44
-
45
32
  const confirmInput = () => {
46
33
  onConfirm(inputValueState);
47
34
  };
48
-
49
35
  return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
50
36
  isOpen: isOpen
51
37
  }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
52
- title: `Insert Embedded Code` //isOpen={toShowInput}
38
+ title: `Insert Embedded Code`
39
+ //isOpen={toShowInput}
53
40
  ,
54
41
  actions: {
55
42
  cancel: {
@@ -90,7 +77,6 @@ function BlockquoteInput({
90
77
  }
91
78
  })));
92
79
  }
93
-
94
80
  function BlockquoteButton(props) {
95
81
  const {
96
82
  editorState,
@@ -98,30 +84,25 @@ function BlockquoteButton(props) {
98
84
  className
99
85
  } = props;
100
86
  const [isInputOpen, setIsInputOpen] = (0, _react.useState)(false);
101
-
102
87
  const promptForInput = () => {
103
88
  setIsInputOpen(true);
104
89
  };
105
-
106
90
  const onInputChange = inputValue => {
107
91
  const contentState = editorState.getCurrentContent();
108
92
  const contentStateWithEntity = contentState.createEntity('BLOCKQUOTE', 'IMMUTABLE', inputValue);
109
93
  const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
110
-
111
94
  const newEditorState = _draftJs.EditorState.set(editorState, {
112
95
  currentContent: contentStateWithEntity
113
- }); // The third parameter here is a space string, not an empty string
114
- // If you set an empty string, you will get an error: Unknown DraftEntity key: null
115
-
96
+ });
116
97
 
98
+ // The third parameter here is a space string, not an empty string
99
+ // If you set an empty string, you will get an error: Unknown DraftEntity key: null
117
100
  onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
118
101
  setIsInputOpen(false);
119
102
  };
120
-
121
103
  const onInputCancel = () => {
122
104
  setIsInputOpen(false);
123
105
  };
124
-
125
106
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isInputOpen && /*#__PURE__*/_react.default.createElement(BlockquoteInput, {
126
107
  isOpen: isInputOpen,
127
108
  onConfirm: onInputChange,
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EmbeddedCodeButton = EmbeddedCodeButton;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _draftJs = require("draft-js");
11
-
12
9
  var _modals = require("@keystone-ui/modals");
13
-
14
10
  var _fields = require("@keystone-ui/fields");
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  function EmbeddedCodeButton(props) {
21
14
  const {
22
15
  editorState,
@@ -28,7 +21,6 @@ function EmbeddedCodeButton(props) {
28
21
  caption: '',
29
22
  embeddedCode: ''
30
23
  });
31
-
32
24
  const promptForInput = () => {
33
25
  setToShowInput(true);
34
26
  setInputValue({
@@ -36,18 +28,16 @@ function EmbeddedCodeButton(props) {
36
28
  embeddedCode: ''
37
29
  });
38
30
  };
39
-
40
31
  const confirmInput = () => {
41
32
  const contentState = editorState.getCurrentContent();
42
33
  const contentStateWithEntity = contentState.createEntity('EMBEDDEDCODE', 'IMMUTABLE', inputValue);
43
34
  const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
44
-
45
35
  const newEditorState = _draftJs.EditorState.set(editorState, {
46
36
  currentContent: contentStateWithEntity
47
- }); // The third parameter here is a space string, not an empty string
48
- // If you set an empty string, you will get an error: Unknown DraftEntity key: null
49
-
37
+ });
50
38
 
39
+ // The third parameter here is a space string, not an empty string
40
+ // If you set an empty string, you will get an error: Unknown DraftEntity key: null
51
41
  onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
52
42
  setToShowInput(false);
53
43
  setInputValue({
@@ -55,11 +45,11 @@ function EmbeddedCodeButton(props) {
55
45
  embeddedCode: ''
56
46
  });
57
47
  };
58
-
59
48
  const input = /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
60
49
  isOpen: toShowInput
61
50
  }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
62
- title: `Insert Embedded Code` //isOpen={toShowInput}
51
+ title: `Insert Embedded Code`
52
+ //isOpen={toShowInput}
63
53
  ,
64
54
  actions: {
65
55
  cancel: {
@@ -97,7 +87,6 @@ function EmbeddedCodeButton(props) {
97
87
  marginBottom: '30px'
98
88
  }
99
89
  })));
100
-
101
90
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, input, /*#__PURE__*/_react.default.createElement("div", {
102
91
  onClick: () => {
103
92
  promptForInput();
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EnlargeButton = EnlargeButton;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  function EnlargeButton(props) {
13
10
  const {
14
11
  onToggle,
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ImageButton = ImageButton;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _draftJs = require("draft-js");
11
-
12
9
  var _imageSelector = require("./selector/image-selector");
13
-
14
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
12
  function ImageButton(props) {
19
13
  const {
20
14
  editorState,
@@ -23,36 +17,31 @@ function ImageButton(props) {
23
17
  ImageSelector = _imageSelector.ImageSelector
24
18
  } = props;
25
19
  const [toShowImageSelector, setToShowImageSelector] = (0, _react.useState)(false);
26
-
27
20
  const promptForImageSelector = () => {
28
21
  setToShowImageSelector(true);
29
22
  };
30
-
31
23
  const onImageSelectorChange = (selectedImagesWithMeta, align) => {
32
24
  const selected = selectedImagesWithMeta === null || selectedImagesWithMeta === void 0 ? void 0 : selectedImagesWithMeta[0];
33
-
34
25
  if (!selected) {
35
26
  setToShowImageSelector(false);
36
27
  return;
37
28
  }
38
-
39
29
  const contentState = editorState.getCurrentContent();
40
- const contentStateWithEntity = contentState.createEntity('IMAGE', 'IMMUTABLE', { ...(selected === null || selected === void 0 ? void 0 : selected.image),
30
+ const contentStateWithEntity = contentState.createEntity('IMAGE', 'IMMUTABLE', {
31
+ ...(selected === null || selected === void 0 ? void 0 : selected.image),
41
32
  desc: selected === null || selected === void 0 ? void 0 : selected.desc,
42
33
  alignment: align
43
34
  });
44
35
  const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
45
-
46
36
  const newEditorState = _draftJs.EditorState.set(editorState, {
47
37
  currentContent: contentStateWithEntity
48
- }); // The third parameter here is a space string, not an empty string
49
- // If you set an empty string, you will get an error: Unknown DraftEntity key: null
50
-
38
+ });
51
39
 
40
+ // The third parameter here is a space string, not an empty string
41
+ // If you set an empty string, you will get an error: Unknown DraftEntity key: null
52
42
  onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
53
43
  setToShowImageSelector(false);
54
44
  };
55
-
56
45
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowImageSelector && /*#__PURE__*/_react.default.createElement(ImageSelector, {
57
46
  onChange: onImageSelectorChange,
58
47
  enableCaption: true,
@@ -5,40 +5,27 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.InfoBoxInput = InfoBoxInput;
7
7
  exports.createInfoBoxButton = createInfoBoxButton;
8
-
9
8
  var _react = _interopRequireWildcard(require("react"));
10
-
11
9
  var _btNames = _interopRequireDefault(require("./bt-names"));
12
-
13
10
  var _draftJs = require("draft-js");
14
-
15
11
  var _modals = require("@keystone-ui/modals");
16
-
17
12
  var _select = require("./select");
18
-
19
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
-
23
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
-
25
16
  const disabledButtons = [_btNames.default.h2, _btNames.default.h3, _btNames.default.code, _btNames.default.codeBlock, _btNames.default.blockquote, _btNames.default.annotation, _btNames.default.embed, _btNames.default.infoBox, _btNames.default.slideshow];
26
- var InfoBoxTypeEnum;
27
-
28
- (function (InfoBoxTypeEnum) {
17
+ var InfoBoxTypeEnum = /*#__PURE__*/function (InfoBoxTypeEnum) {
29
18
  InfoBoxTypeEnum["newsChargeStation"] = "news-charge-station";
30
19
  InfoBoxTypeEnum["headerBorder"] = "header-border";
31
20
  InfoBoxTypeEnum["boxBorder"] = "box-border";
32
- })(InfoBoxTypeEnum || (InfoBoxTypeEnum = {}));
33
-
34
- var InfoBoxLabelEnum;
35
-
36
- (function (InfoBoxLabelEnum) {
21
+ return InfoBoxTypeEnum;
22
+ }(InfoBoxTypeEnum || {});
23
+ var InfoBoxLabelEnum = /*#__PURE__*/function (InfoBoxLabelEnum) {
37
24
  InfoBoxLabelEnum["newsChargeStation"] = "\u65B0\u805E\u5145\u96FB\u5668";
38
25
  InfoBoxLabelEnum["headerBorder"] = "\u7121\u7DDA\u6846\u7248";
39
26
  InfoBoxLabelEnum["boxBorder"] = "\u6709\u7DDA\u6846\u7248";
40
- })(InfoBoxLabelEnum || (InfoBoxLabelEnum = {}));
41
-
27
+ return InfoBoxLabelEnum;
28
+ }(InfoBoxLabelEnum || {});
42
29
  function InfoBoxInput(props) {
43
30
  const {
44
31
  isOpen,
@@ -104,7 +91,6 @@ function InfoBoxInput(props) {
104
91
  }
105
92
  })));
106
93
  }
107
-
108
94
  function createInfoBoxButton({
109
95
  InnerEditor,
110
96
  decorator
@@ -116,29 +102,27 @@ function createInfoBoxButton({
116
102
  editorState,
117
103
  onChange: onEditorStateChange
118
104
  } = props;
119
-
120
105
  const onChange = ({
121
106
  type,
122
107
  rawContentState
123
108
  }) => {
124
- const contentState = editorState.getCurrentContent(); // create an InfoBox entity
109
+ const contentState = editorState.getCurrentContent();
125
110
 
111
+ // create an InfoBox entity
126
112
  const contentStateWithEntity = contentState.createEntity('INFOBOX', 'IMMUTABLE', {
127
113
  type,
128
114
  rawContentState
129
115
  });
130
116
  const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
131
-
132
117
  const newEditorState = _draftJs.EditorState.set(editorState, {
133
118
  currentContent: contentStateWithEntity
134
- }); //The third parameter here is a space string, not an empty string
135
- //If you set an empty string, you will get an error: Unknown DraftEntity key: null
136
-
119
+ });
137
120
 
121
+ //The third parameter here is a space string, not an empty string
122
+ //If you set an empty string, you will get an error: Unknown DraftEntity key: null
138
123
  onEditorStateChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
139
124
  setToShowInput(false);
140
125
  };
141
-
142
126
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowInput && /*#__PURE__*/_react.default.createElement(InfoBoxInput, {
143
127
  Editor: InnerEditor,
144
128
  decorator: decorator,
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LinkButton = LinkButton;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _modals = require("@keystone-ui/modals");
11
-
12
9
  var _draftJs = require("draft-js");
13
-
14
10
  var _fields = require("@keystone-ui/fields");
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  const styles = {
21
14
  urlInput: {
22
15
  fontFamily: "'Georgia', serif",
@@ -24,7 +17,6 @@ const styles = {
24
17
  padding: 10
25
18
  }
26
19
  };
27
-
28
20
  function LinkButton(props) {
29
21
  const {
30
22
  isActive,
@@ -33,50 +25,40 @@ function LinkButton(props) {
33
25
  } = props;
34
26
  const [toShowUrlInput, setToShowUrlInput] = (0, _react.useState)(false);
35
27
  const [urlValue, setUrlValue] = (0, _react.useState)('');
36
-
37
28
  const promptForLink = e => {
38
29
  e.preventDefault();
39
30
  const selection = editorState.getSelection();
40
-
41
31
  if (!selection.isCollapsed()) {
42
32
  setToShowUrlInput(true);
43
33
  }
44
34
  };
45
-
46
35
  const confirmLink = () => {
47
36
  const contentState = editorState.getCurrentContent();
48
37
  const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {
49
38
  url: urlValue
50
39
  });
51
40
  const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
52
-
53
41
  const newEditorState = _draftJs.EditorState.set(editorState, {
54
42
  currentContent: contentStateWithEntity
55
43
  });
56
-
57
44
  onChange(_draftJs.RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
58
45
  setToShowUrlInput(false);
59
46
  setUrlValue('');
60
47
  };
61
-
62
48
  const onLinkInputKeyDown = e => {
63
49
  if (e.which === 13) {
64
50
  e.preventDefault();
65
51
  confirmLink();
66
52
  }
67
53
  };
68
-
69
54
  const removeLink = () => {
70
55
  const selection = editorState.getSelection();
71
-
72
56
  if (!selection.isCollapsed()) {
73
57
  onChange(_draftJs.RichUtils.toggleLink(editorState, selection, null));
74
58
  }
75
-
76
59
  setToShowUrlInput(false);
77
60
  setUrlValue('');
78
61
  };
79
-
80
62
  const urlInput = /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
81
63
  title: "Insert LINK",
82
64
  isOpen: toShowUrlInput,
@@ -97,7 +79,6 @@ function LinkButton(props) {
97
79
  value: urlValue,
98
80
  onKeyDown: onLinkInputKeyDown
99
81
  }));
100
-
101
82
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, urlInput, /*#__PURE__*/_react.default.createElement("div", {
102
83
  className: props.className,
103
84
  onMouseDown: isActive ? removeLink : promptForLink
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Select = Select;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
9
  var _fields = require("@keystone-ui/fields");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const TypeSelectBlock = _styledComponents.default.div`
17
12
  margin: 10px 0;
18
13
  `;
@@ -21,7 +16,6 @@ const Label = _styledComponents.default.label`
21
16
  margin: 10px 0;
22
17
  font-weight: 600;
23
18
  `;
24
-
25
19
  function Select({
26
20
  title,
27
21
  value,
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AlignSelector = AlignSelector;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
9
  var _fields = require("@keystone-ui/fields");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  const Label = _styledComponents.default.label`
21
14
  display: block;
22
15
  margin: 10px 0;
@@ -29,7 +22,6 @@ const AlignSelect = (0, _styledComponents.default)(_fields.Select)`
29
22
  return `margin-bottom: ${menuHeight}px;`;
30
23
  }}
31
24
  `;
32
-
33
25
  function AlignSelector(props) {
34
26
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
35
27
  const [menuHeight, setMenuHeight] = (0, _react.useState)(0);
@@ -41,7 +33,6 @@ function AlignSelector(props) {
41
33
  } = props;
42
34
  (0, _react.useEffect)(() => {
43
35
  const selectMenu = document.querySelector('.css-nabggt-menu');
44
-
45
36
  if (selectMenu) {
46
37
  const styles = window.getComputedStyle(selectMenu);
47
38
  const margin = parseFloat(styles['marginTop']) + parseFloat(styles['marginBottom']);
@@ -49,7 +40,6 @@ function AlignSelector(props) {
49
40
  } else {
50
41
  setMenuHeight(0);
51
42
  }
52
-
53
43
  if (isOpen && onOpen) {
54
44
  onOpen();
55
45
  }
@@ -57,7 +47,8 @@ function AlignSelector(props) {
57
47
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Label, {
58
48
  htmlFor: "alignment"
59
49
  }, "\u5C0D\u9F4A"), /*#__PURE__*/_react.default.createElement(AlignSelect, {
60
- id: "alignment" // default align === undefined
50
+ id: "alignment"
51
+ // default align === undefined
61
52
  ,
62
53
  value: options.find(option => option.value === align) || null,
63
54
  options: options,