@mirrormedia/lilith-draft-editor 3.0.6 → 3.0.8-beta.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/lib/draft-js/draft-converter/index.js +2 -0
- package/lib/website/mirrordaily/selector/video-selector.js +1 -1
- package/lib/website/mirrordaily/selector/video-uploader.js +4 -1
- package/lib/website/mirrormedia/draft-editor.js +351 -330
- package/lib/website/readr/draft-editor.js +16 -0
- package/package.json +1 -1
|
@@ -346,7 +346,7 @@ function VideoSelector(props) {
|
|
|
346
346
|
width: "narrow"
|
|
347
347
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(CustomButton, {
|
|
348
348
|
onClick: () => setShowVideoUploader(true)
|
|
349
|
-
}, "\u4E0A\u50B3\
|
|
349
|
+
}, "\u4E0A\u50B3\u5F71\u7247"), /*#__PURE__*/_react.default.createElement(VideoSearchBox, {
|
|
350
350
|
onChange: onSearchBoxChange
|
|
351
351
|
}), /*#__PURE__*/_react.default.createElement(VideoSelectionWrapper, null, /*#__PURE__*/_react.default.createElement("div", null, searchResult), !!selected.length && /*#__PURE__*/_react.default.createElement(SeparationLine, null), /*#__PURE__*/_react.default.createElement(VideoMetaGrids, {
|
|
352
352
|
videoMetas: selected,
|
|
@@ -67,6 +67,9 @@ const Video = _styledComponents.default.video`
|
|
|
67
67
|
aspect-ratio: 2;
|
|
68
68
|
object-fit: contain;
|
|
69
69
|
`;
|
|
70
|
+
const VideoName = _styledComponents.default.p`
|
|
71
|
+
text-align: center;
|
|
72
|
+
`;
|
|
70
73
|
const Label = _styledComponents.default.label`
|
|
71
74
|
display: block;
|
|
72
75
|
margin: 10px 0;
|
|
@@ -181,5 +184,5 @@ function VideoUploader({
|
|
|
181
184
|
type: "text",
|
|
182
185
|
defaultValue: file.name,
|
|
183
186
|
onChange: _lodash.default.debounce(onVideoNameChange)
|
|
184
|
-
})), uploadLoading && /*#__PURE__*/_react.default.createElement(HintWrapper, null, "loading"), uploadError && /*#__PURE__*/_react.default.createElement(HintWrapper, null, uploadError.message))));
|
|
187
|
+
}), /*#__PURE__*/_react.default.createElement(VideoName, null, file.name)), uploadLoading && /*#__PURE__*/_react.default.createElement(HintWrapper, null, "loading"), uploadError && /*#__PURE__*/_react.default.createElement(HintWrapper, null, uploadError.message))));
|
|
185
188
|
}
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
11
|
|
|
12
|
-
var _theme =
|
|
12
|
+
var _theme = _interopRequireWildcard(require("./theme"));
|
|
13
13
|
|
|
14
14
|
var _draftJs = require("draft-js");
|
|
15
15
|
|
|
@@ -69,6 +69,8 @@ var _audioSelector = require("./selector/audio-selector");
|
|
|
69
69
|
|
|
70
70
|
var _sharedStyle = require("./shared-style");
|
|
71
71
|
|
|
72
|
+
var _hooks = require("../../hooks");
|
|
73
|
+
|
|
72
74
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
73
75
|
|
|
74
76
|
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); }
|
|
@@ -349,6 +351,7 @@ const DraftEditorControlsWrapper = _styledComponents.default.div`
|
|
|
349
351
|
flex-direction: row;
|
|
350
352
|
flex-wrap: wrap;
|
|
351
353
|
padding-right: 45px;
|
|
354
|
+
column-gap: 5px;
|
|
352
355
|
`;
|
|
353
356
|
const TextEditorWrapper = _styledComponents.default.div`
|
|
354
357
|
/* Rich-editor default setting (.RichEditor-editor)*/
|
|
@@ -436,7 +439,6 @@ const DraftEditorContainer = _styledComponents.default.div`
|
|
|
436
439
|
`;
|
|
437
440
|
const ButtonGroup = _styledComponents.default.div`
|
|
438
441
|
margin: 0 10px 0 0;
|
|
439
|
-
|
|
440
442
|
${({
|
|
441
443
|
isDisabled
|
|
442
444
|
}) => isDisabled ? (0, _styledComponents.css)`
|
|
@@ -449,60 +451,70 @@ const EnlargeButtonWrapper = _styledComponents.default.div`
|
|
|
449
451
|
right: 0;
|
|
450
452
|
margin: 0;
|
|
451
453
|
`;
|
|
454
|
+
const MOBILE_BOUNDARY = _theme.mediaSize.md;
|
|
452
455
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
CODE: {
|
|
463
|
-
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
464
|
-
fontFamily: '"Inconsolata", "Menlo", "Consolas", monospace',
|
|
465
|
-
fontSize: 16,
|
|
466
|
-
padding: 2
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
}
|
|
456
|
+
const RichTextEditor = ({
|
|
457
|
+
editorState: propEditorState,
|
|
458
|
+
onChange,
|
|
459
|
+
disabledButtons = [],
|
|
460
|
+
hideOnMobileButtons = []
|
|
461
|
+
}) => {
|
|
462
|
+
const [isEnlarged, setIsEnlarged] = _react.default.useState(false);
|
|
463
|
+
|
|
464
|
+
const [readOnly, setReadOnly] = _react.default.useState(false);
|
|
470
465
|
|
|
471
|
-
|
|
472
|
-
|
|
466
|
+
const editorRef = _react.default.useRef(null);
|
|
467
|
+
|
|
468
|
+
const checkIsDisabled = (0, _hooks.useButtonDisabledChecker)({
|
|
469
|
+
mobileBoundary: MOBILE_BOUNDARY,
|
|
470
|
+
disabledButtons,
|
|
471
|
+
hideOnMobileButtons
|
|
472
|
+
}); // Custom overrides for "code" style.
|
|
473
|
+
|
|
474
|
+
const customStyleMap = {
|
|
475
|
+
CODE: {
|
|
476
|
+
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
477
|
+
fontFamily: '"Inconsolata", "Menlo", "Consolas", monospace',
|
|
478
|
+
fontSize: 16,
|
|
479
|
+
padding: 2
|
|
480
|
+
}
|
|
473
481
|
};
|
|
474
|
-
|
|
482
|
+
let editorState = propEditorState;
|
|
483
|
+
|
|
484
|
+
if (!(editorState instanceof _draftJs.EditorState)) {
|
|
485
|
+
editorState = _draftJs.EditorState.createEmpty(_entityDecorator.default);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const handleKeyCommand = (command, editorState) => {
|
|
475
489
|
const newState = _draftJs.RichUtils.handleKeyCommand(editorState, command);
|
|
476
490
|
|
|
477
491
|
if (newState) {
|
|
478
|
-
|
|
492
|
+
onChange(newState);
|
|
479
493
|
return 'handled';
|
|
480
494
|
}
|
|
481
495
|
|
|
482
496
|
return 'not-handled';
|
|
483
497
|
};
|
|
484
|
-
|
|
498
|
+
|
|
499
|
+
const handleReturn = event => {
|
|
485
500
|
if (_draftJs.KeyBindingUtil.isSoftNewlineEvent(event)) {
|
|
486
|
-
const {
|
|
487
|
-
onChange,
|
|
488
|
-
editorState
|
|
489
|
-
} = this.props;
|
|
490
501
|
onChange(_draftJs.RichUtils.insertSoftNewline(editorState));
|
|
491
502
|
return 'handled';
|
|
492
503
|
}
|
|
493
504
|
|
|
494
505
|
return 'not-handled';
|
|
495
506
|
};
|
|
496
|
-
|
|
507
|
+
|
|
508
|
+
const mapKeyToEditorCommand = e => {
|
|
497
509
|
if (e.keyCode === 9
|
|
498
510
|
/* TAB */
|
|
499
511
|
) {
|
|
500
|
-
const newEditorState = _draftJs.RichUtils.onTab(e,
|
|
512
|
+
const newEditorState = _draftJs.RichUtils.onTab(e, editorState, 4
|
|
501
513
|
/* maxDepth */
|
|
502
514
|
);
|
|
503
515
|
|
|
504
|
-
if (newEditorState !==
|
|
505
|
-
|
|
516
|
+
if (newEditorState !== editorState) {
|
|
517
|
+
onChange(newEditorState);
|
|
506
518
|
}
|
|
507
519
|
|
|
508
520
|
return null;
|
|
@@ -510,13 +522,16 @@ class RichTextEditor extends _react.default.Component {
|
|
|
510
522
|
|
|
511
523
|
return (0, _draftJs.getDefaultKeyBinding)(e);
|
|
512
524
|
};
|
|
513
|
-
|
|
514
|
-
|
|
525
|
+
|
|
526
|
+
const toggleBlockType = blockType => {
|
|
527
|
+
onChange(_draftJs.RichUtils.toggleBlockType(editorState, blockType));
|
|
515
528
|
};
|
|
516
|
-
|
|
517
|
-
|
|
529
|
+
|
|
530
|
+
const toggleInlineStyle = inlineStyle => {
|
|
531
|
+
onChange(_draftJs.RichUtils.toggleInlineStyle(editorState, inlineStyle));
|
|
518
532
|
};
|
|
519
|
-
|
|
533
|
+
|
|
534
|
+
const getEntityType = editorState => {
|
|
520
535
|
const contentState = editorState.getCurrentContent();
|
|
521
536
|
const selection = editorState.getSelection();
|
|
522
537
|
const startOffset = selection.getStartOffset();
|
|
@@ -543,8 +558,9 @@ class RichTextEditor extends _react.default.Component {
|
|
|
543
558
|
|
|
544
559
|
return entityType;
|
|
545
560
|
};
|
|
546
|
-
|
|
547
|
-
|
|
561
|
+
|
|
562
|
+
const getCustomStyle = style => {
|
|
563
|
+
return style.reduce((styles = {}, styleName) => {
|
|
548
564
|
if (styleName !== null && styleName !== void 0 && styleName.startsWith(_const.CUSTOM_STYLE_PREFIX_FONT_COLOR)) {
|
|
549
565
|
styles['color'] = styleName.split(_const.CUSTOM_STYLE_PREFIX_FONT_COLOR)[1];
|
|
550
566
|
}
|
|
@@ -556,21 +572,18 @@ class RichTextEditor extends _react.default.Component {
|
|
|
556
572
|
return styles;
|
|
557
573
|
}, {});
|
|
558
574
|
};
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
575
|
+
|
|
576
|
+
const customStyleFn = style => {
|
|
577
|
+
return getCustomStyle(style);
|
|
563
578
|
};
|
|
564
|
-
|
|
565
|
-
|
|
579
|
+
|
|
580
|
+
const toggleEnlarge = () => {
|
|
581
|
+
setIsEnlarged(!isEnlarged);
|
|
566
582
|
};
|
|
567
583
|
|
|
568
|
-
blockStyleFn
|
|
584
|
+
const blockStyleFn = block => {
|
|
569
585
|
var _entity$getData;
|
|
570
586
|
|
|
571
|
-
const {
|
|
572
|
-
editorState
|
|
573
|
-
} = this.props;
|
|
574
587
|
const entityKey = block.getEntityAt(0);
|
|
575
588
|
const entity = entityKey ? editorState.getCurrentContent().getEntity(entityKey) : null;
|
|
576
589
|
let result = '';
|
|
@@ -607,25 +620,30 @@ class RichTextEditor extends _react.default.Component {
|
|
|
607
620
|
}
|
|
608
621
|
|
|
609
622
|
return result;
|
|
610
|
-
}
|
|
623
|
+
};
|
|
611
624
|
|
|
612
|
-
|
|
625
|
+
const renderBasicEditor = propsOfBasicEditor => {
|
|
626
|
+
return /*#__PURE__*/_react.default.createElement(RichTextEditor, _extends({}, propsOfBasicEditor, {
|
|
627
|
+
disabledButtons: disabledButtonsOnBasicEditor,
|
|
628
|
+
hideOnMobileButtons: hideOnMobileButtons
|
|
629
|
+
}));
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
const blockRendererFn = block => {
|
|
613
633
|
const atomicBlockObj = (0, _blockRendererFn.atomicBlockRenderer)(block);
|
|
614
634
|
|
|
615
635
|
if (atomicBlockObj) {
|
|
616
636
|
const onEditStart = () => {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
readOnly: true
|
|
628
|
-
});
|
|
637
|
+
// If custom block renderer requires mouse interaction,
|
|
638
|
+
// [Draft.js document](https://draftjs.org/docs/advanced-topics-block-components#recommendations-and-other-notes)
|
|
639
|
+
// suggests that we should temporarily set Editor
|
|
640
|
+
// to readOnly={true} during the interaction.
|
|
641
|
+
// In readOnly={true} condition, the user does not
|
|
642
|
+
// trigger any selection changes within the editor
|
|
643
|
+
// while interacting with custom block.
|
|
644
|
+
// If we don't set readOnly={true},
|
|
645
|
+
// it will cause some subtle bugs in InfoBox button.
|
|
646
|
+
setReadOnly(true);
|
|
629
647
|
};
|
|
630
648
|
|
|
631
649
|
const onEditFinish = ({
|
|
@@ -633,9 +651,9 @@ class RichTextEditor extends _react.default.Component {
|
|
|
633
651
|
entityData
|
|
634
652
|
}) => {
|
|
635
653
|
if (entityKey && entityData) {
|
|
636
|
-
const oldContentState =
|
|
654
|
+
const oldContentState = editorState.getCurrentContent();
|
|
637
655
|
const newContentState = oldContentState.replaceEntityData(entityKey, entityData);
|
|
638
|
-
|
|
656
|
+
onChange(_draftJs.EditorState.set(editorState, {
|
|
639
657
|
currentContent: newContentState
|
|
640
658
|
}));
|
|
641
659
|
} // Custom block interaction is finished.
|
|
@@ -643,9 +661,7 @@ class RichTextEditor extends _react.default.Component {
|
|
|
643
661
|
// make editor editable.
|
|
644
662
|
|
|
645
663
|
|
|
646
|
-
|
|
647
|
-
readOnly: false
|
|
648
|
-
});
|
|
664
|
+
setReadOnly(false);
|
|
649
665
|
}; // `onEditStart` and `onEditFinish` will be passed
|
|
650
666
|
// into custom block component.
|
|
651
667
|
// We can get them via `props.blockProps.onEditStart`
|
|
@@ -656,12 +672,8 @@ class RichTextEditor extends _react.default.Component {
|
|
|
656
672
|
props: {
|
|
657
673
|
onEditStart,
|
|
658
674
|
onEditFinish,
|
|
659
|
-
getMainEditorReadOnly: () =>
|
|
660
|
-
renderBasicEditor:
|
|
661
|
-
return /*#__PURE__*/_react.default.createElement(RichTextEditor, _extends({}, propsOfBasicEditor, {
|
|
662
|
-
disabledButtons: disabledButtonsOnBasicEditor
|
|
663
|
-
}));
|
|
664
|
-
}
|
|
675
|
+
getMainEditorReadOnly: () => readOnly,
|
|
676
|
+
renderBasicEditor: renderBasicEditor
|
|
665
677
|
}
|
|
666
678
|
});
|
|
667
679
|
return extendedAtomicBlockObj;
|
|
@@ -670,290 +682,288 @@ class RichTextEditor extends _react.default.Component {
|
|
|
670
682
|
}
|
|
671
683
|
};
|
|
672
684
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
685
|
+
const entityType = getEntityType(editorState);
|
|
686
|
+
const customStyle = getCustomStyle(editorState.getCurrentInlineStyle());
|
|
687
|
+
return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
688
|
+
theme: _theme.default
|
|
689
|
+
}, /*#__PURE__*/_react.default.createElement(DraftEditorContainer, {
|
|
690
|
+
isEnlarged: Boolean(isEnlarged)
|
|
691
|
+
}, /*#__PURE__*/_react.default.createElement(DraftEditorWrapper, null, /*#__PURE__*/_react.default.createElement("link", {
|
|
692
|
+
href: "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css",
|
|
693
|
+
rel: "stylesheet",
|
|
694
|
+
type: "text/css"
|
|
695
|
+
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
696
|
+
href: "https://cdnjs.cloudflare.com/ajax/libs/draft-js/0.11.7/Draft.css",
|
|
697
|
+
rel: "stylesheet",
|
|
698
|
+
type: "text/css"
|
|
699
|
+
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
700
|
+
href: "https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css",
|
|
701
|
+
rel: "stylesheet",
|
|
702
|
+
type: "text/css"
|
|
703
|
+
}), /*#__PURE__*/_react.default.createElement(DraftEditorControls, null, /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(BlockStyleControls, {
|
|
704
|
+
readOnly: readOnly,
|
|
705
|
+
disabledButtons: disabledButtons,
|
|
706
|
+
hideOnMobileButtons: hideOnMobileButtons,
|
|
707
|
+
editorState: editorState,
|
|
708
|
+
onToggle: toggleBlockType
|
|
709
|
+
}), /*#__PURE__*/_react.default.createElement(InlineStyleControls, {
|
|
710
|
+
readOnly: readOnly,
|
|
711
|
+
disabledButtons: disabledButtons,
|
|
712
|
+
hideOnMobileButtons: hideOnMobileButtons,
|
|
713
|
+
editorState: editorState,
|
|
714
|
+
onToggle: toggleInlineStyle
|
|
715
|
+
}), /*#__PURE__*/_react.default.createElement(EnlargeButtonWrapper, null, /*#__PURE__*/_react.default.createElement(CustomEnlargeButton, {
|
|
716
|
+
onToggle: toggleEnlarge,
|
|
717
|
+
isEnlarged: isEnlarged
|
|
718
|
+
}))), /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
719
|
+
isDisabled: disabledButtons.includes(buttonNames.link)
|
|
720
|
+
}, /*#__PURE__*/_react.default.createElement(CustomLinkButton, {
|
|
721
|
+
isDisabled: checkIsDisabled(buttonNames.link),
|
|
722
|
+
isActive: entityType === 'LINK',
|
|
723
|
+
readOnly: readOnly,
|
|
724
|
+
editorState: editorState,
|
|
725
|
+
onChange: onChange
|
|
726
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
727
|
+
isDisabled: disabledButtons.includes(buttonNames.fontColor)
|
|
728
|
+
}, /*#__PURE__*/_react.default.createElement(CustomFontColorButton, {
|
|
729
|
+
isDisabled: checkIsDisabled(buttonNames.fontColor),
|
|
730
|
+
isActive: Object.prototype.hasOwnProperty.call(customStyle, 'color'),
|
|
731
|
+
readOnly: readOnly,
|
|
732
|
+
editorState: editorState,
|
|
733
|
+
onChange: onChange
|
|
734
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
735
|
+
isDisabled: disabledButtons.includes(buttonNames.divider)
|
|
736
|
+
}, /*#__PURE__*/_react.default.createElement(CustomDividerButton, {
|
|
737
|
+
isDisabled: checkIsDisabled(buttonNames.divider),
|
|
738
|
+
editorState: editorState,
|
|
739
|
+
onChange: onChange
|
|
740
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
741
|
+
isDisabled: disabledButtons.includes(buttonNames.annotation)
|
|
742
|
+
}, /*#__PURE__*/_react.default.createElement(CustomAnnotationButton, {
|
|
743
|
+
isDisabled: checkIsDisabled(buttonNames.annotation),
|
|
744
|
+
isActive: entityType === 'ANNOTATION',
|
|
745
|
+
readOnly: readOnly,
|
|
746
|
+
editorState: editorState,
|
|
747
|
+
onChange: onChange,
|
|
748
|
+
renderBasicEditor: renderBasicEditor,
|
|
749
|
+
decorators: _entityDecorator.default
|
|
750
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
751
|
+
isDisabled: disabledButtons.includes(buttonNames.image)
|
|
752
|
+
}, /*#__PURE__*/_react.default.createElement(CustomImageButton, {
|
|
753
|
+
isDisabled: checkIsDisabled(buttonNames.image),
|
|
754
|
+
readOnly: readOnly,
|
|
755
|
+
editorState: editorState,
|
|
756
|
+
onChange: onChange,
|
|
757
|
+
ImageSelector: _imageSelector.ImageSelector
|
|
758
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
759
|
+
isDisabled: disabledButtons.includes(buttonNames.video)
|
|
760
|
+
}, /*#__PURE__*/_react.default.createElement(CustomVideoButton, {
|
|
761
|
+
isDisabled: checkIsDisabled(buttonNames.video),
|
|
762
|
+
readOnly: readOnly,
|
|
763
|
+
editorState: editorState,
|
|
764
|
+
onChange: onChange,
|
|
765
|
+
VideoSelector: _videoSelector.VideoSelector
|
|
766
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
767
|
+
isDisabled: disabledButtons.includes(buttonNames.youtube)
|
|
768
|
+
}, /*#__PURE__*/_react.default.createElement(CustomYoutubeButton, {
|
|
769
|
+
isDisabled: checkIsDisabled(buttonNames.youtube),
|
|
770
|
+
readOnly: readOnly,
|
|
771
|
+
editorState: editorState,
|
|
772
|
+
onChange: onChange
|
|
773
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
774
|
+
isDisabled: disabledButtons.includes(buttonNames.audio)
|
|
775
|
+
}, /*#__PURE__*/_react.default.createElement(CustomAudioButton, {
|
|
776
|
+
isDisabled: checkIsDisabled(buttonNames.audio),
|
|
777
|
+
readOnly: readOnly,
|
|
778
|
+
editorState: editorState,
|
|
779
|
+
onChange: onChange,
|
|
780
|
+
AudioSelector: _audioSelector.AudioSelector
|
|
781
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
782
|
+
isDisabled: disabledButtons.includes(buttonNames.slideshow)
|
|
783
|
+
}, /*#__PURE__*/_react.default.createElement(CustomSlideshowButton, {
|
|
784
|
+
isDisabled: checkIsDisabled(buttonNames.slideshow),
|
|
785
|
+
readOnly: readOnly,
|
|
786
|
+
editorState: editorState,
|
|
787
|
+
onChange: onChange,
|
|
788
|
+
ImageSelector: _imageSelector.ImageSelector
|
|
789
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
790
|
+
isDisabled: disabledButtons.includes(buttonNames.infoBox)
|
|
791
|
+
}, /*#__PURE__*/_react.default.createElement(CustomInfoBoxButton, {
|
|
792
|
+
isDisabled: checkIsDisabled(buttonNames.infoBox),
|
|
793
|
+
readOnly: readOnly,
|
|
794
|
+
editorState: editorState,
|
|
795
|
+
onChange: onChange,
|
|
796
|
+
renderBasicEditor: renderBasicEditor // decorators={decorators}
|
|
797
|
+
|
|
798
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
799
|
+
isDisabled: disabledButtons.includes(buttonNames.embed)
|
|
800
|
+
}, /*#__PURE__*/_react.default.createElement(CustomEmbeddedCodeButton, {
|
|
801
|
+
isDisabled: checkIsDisabled(buttonNames.embed),
|
|
802
|
+
readOnly: readOnly,
|
|
803
|
+
editorState: editorState,
|
|
804
|
+
onChange: onChange
|
|
805
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
806
|
+
isDisabled: disabledButtons.includes(buttonNames.table)
|
|
807
|
+
}, /*#__PURE__*/_react.default.createElement(CustomTableButton, {
|
|
808
|
+
isDisabled: checkIsDisabled(buttonNames.table),
|
|
809
|
+
readOnly: readOnly,
|
|
810
|
+
editorState: editorState,
|
|
811
|
+
onChange: onChange
|
|
812
|
+
}))), /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
813
|
+
isDisabled: disabledButtons.includes(buttonNames.textAlign)
|
|
814
|
+
}, /*#__PURE__*/_react.default.createElement(CustomAlignLeftButton, {
|
|
815
|
+
isDisabled: checkIsDisabled(buttonNames.textAlign),
|
|
816
|
+
isActive: (0, _textAlign.getSelectionBlockData)(editorState, 'textAlign') === 'left',
|
|
817
|
+
readOnly: readOnly,
|
|
818
|
+
editorState: editorState,
|
|
819
|
+
onChange: onChange
|
|
820
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
821
|
+
isDisabled: disabledButtons.includes(buttonNames.textAlign)
|
|
822
|
+
}, /*#__PURE__*/_react.default.createElement(CustomAlignCenterButton, {
|
|
823
|
+
isDisabled: checkIsDisabled(buttonNames.textAlign),
|
|
824
|
+
isActive: (0, _textAlign.getSelectionBlockData)(editorState, 'textAlign') === 'center',
|
|
825
|
+
readOnly: readOnly,
|
|
826
|
+
editorState: editorState,
|
|
827
|
+
onChange: onChange
|
|
828
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
829
|
+
isDisabled: disabledButtons.includes(buttonNames.colorBox)
|
|
830
|
+
}, /*#__PURE__*/_react.default.createElement(CustomColorBoxButton, {
|
|
831
|
+
isDisabled: checkIsDisabled(buttonNames.colorBox),
|
|
832
|
+
readOnly: readOnly,
|
|
833
|
+
editorState: editorState,
|
|
834
|
+
onChange: onChange,
|
|
835
|
+
renderBasicEditor: renderBasicEditor // decorators={decorators}
|
|
836
|
+
|
|
837
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
838
|
+
isDisabled: disabledButtons.includes(buttonNames.backgroundColor)
|
|
839
|
+
}, /*#__PURE__*/_react.default.createElement(CustomBackgroundColorButton, {
|
|
840
|
+
isDisabled: checkIsDisabled(buttonNames.backgroundColor),
|
|
841
|
+
isActive: Object.prototype.hasOwnProperty.call(customStyle, 'backgroundColor'),
|
|
842
|
+
readOnly: readOnly,
|
|
843
|
+
editorState: editorState,
|
|
844
|
+
onChange: onChange
|
|
845
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
846
|
+
isDisabled: disabledButtons.includes(buttonNames.backgroundImage)
|
|
847
|
+
}, /*#__PURE__*/_react.default.createElement(CustomBGImageButton, {
|
|
848
|
+
isDisabled: checkIsDisabled(buttonNames.backgroundImage),
|
|
849
|
+
readOnly: readOnly,
|
|
850
|
+
editorState: editorState,
|
|
851
|
+
onChange: onChange,
|
|
852
|
+
ImageSelector: _imageSelector.ImageSelector,
|
|
853
|
+
renderBasicEditor: renderBasicEditor,
|
|
854
|
+
decorators: _entityDecorator.default
|
|
855
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
856
|
+
isDisabled: disabledButtons.includes(buttonNames.backgroundVideo)
|
|
857
|
+
}, /*#__PURE__*/_react.default.createElement(CustomBGVideoButton, {
|
|
858
|
+
isDisabled: checkIsDisabled(buttonNames.backgroundVideo),
|
|
859
|
+
readOnly: readOnly,
|
|
860
|
+
editorState: editorState,
|
|
861
|
+
onChange: onChange,
|
|
862
|
+
VideoSelector: _videoSelector.VideoSelector,
|
|
863
|
+
renderBasicEditor: renderBasicEditor,
|
|
864
|
+
decorators: _entityDecorator.default
|
|
865
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
866
|
+
isDisabled: disabledButtons.includes(buttonNames.relatedPost)
|
|
867
|
+
}, /*#__PURE__*/_react.default.createElement(CustomRelatedPostButton, {
|
|
868
|
+
isDisabled: checkIsDisabled(buttonNames.relatedPost),
|
|
869
|
+
readOnly: readOnly,
|
|
870
|
+
editorState: editorState,
|
|
871
|
+
onChange: onChange,
|
|
872
|
+
PostSelector: _postSelector.PostSelector
|
|
873
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
874
|
+
isDisabled: disabledButtons.includes(buttonNames.sideIndex)
|
|
875
|
+
}, /*#__PURE__*/_react.default.createElement(CustomSideIndexButton, {
|
|
876
|
+
isDisabled: checkIsDisabled(buttonNames.sideIndex),
|
|
877
|
+
readOnly: readOnly,
|
|
878
|
+
editorState: editorState,
|
|
879
|
+
onChange: onChange
|
|
880
|
+
})))), /*#__PURE__*/_react.default.createElement(TextEditorWrapper, {
|
|
881
|
+
onClick: () => {
|
|
882
|
+
var _editorRef$current;
|
|
883
|
+
|
|
884
|
+
(_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.focus();
|
|
683
885
|
}
|
|
886
|
+
}, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
|
|
887
|
+
blockStyleFn: blockStyleFn,
|
|
888
|
+
blockRendererFn: blockRendererFn,
|
|
889
|
+
customStyleMap: customStyleMap,
|
|
890
|
+
customStyleFn: customStyleFn,
|
|
891
|
+
editorState: editorState,
|
|
892
|
+
handleKeyCommand: handleKeyCommand,
|
|
893
|
+
handleReturn: handleReturn,
|
|
894
|
+
keyBindingFn: mapKeyToEditorCommand,
|
|
895
|
+
onChange: onChange,
|
|
896
|
+
placeholder: "Tell a story...",
|
|
897
|
+
ref: editorRef,
|
|
898
|
+
spellCheck: true,
|
|
899
|
+
readOnly: readOnly
|
|
900
|
+
})))));
|
|
901
|
+
};
|
|
684
902
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
readOnly
|
|
688
|
-
} = this.state;
|
|
689
|
-
const entityType = this.getEntityType(editorState);
|
|
690
|
-
const customStyle = this.getCustomStyle(editorState.getCurrentInlineStyle());
|
|
691
|
-
|
|
692
|
-
const renderBasicEditor = propsOfBasicEditor => {
|
|
693
|
-
return /*#__PURE__*/_react.default.createElement(RichTextEditor, _extends({}, propsOfBasicEditor, {
|
|
694
|
-
disabledButtons: disabledButtonsOnBasicEditor
|
|
695
|
-
}));
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
699
|
-
theme: _theme.default
|
|
700
|
-
}, /*#__PURE__*/_react.default.createElement(DraftEditorContainer, {
|
|
701
|
-
isEnlarged: Boolean(isEnlarged)
|
|
702
|
-
}, /*#__PURE__*/_react.default.createElement(DraftEditorWrapper, null, /*#__PURE__*/_react.default.createElement("link", {
|
|
703
|
-
href: "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css",
|
|
704
|
-
rel: "stylesheet",
|
|
705
|
-
type: "text/css"
|
|
706
|
-
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
707
|
-
href: "https://cdnjs.cloudflare.com/ajax/libs/draft-js/0.11.7/Draft.css",
|
|
708
|
-
rel: "stylesheet",
|
|
709
|
-
type: "text/css"
|
|
710
|
-
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
711
|
-
href: "https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css",
|
|
712
|
-
rel: "stylesheet",
|
|
713
|
-
type: "text/css"
|
|
714
|
-
}), /*#__PURE__*/_react.default.createElement(DraftEditorControls, null, /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(ButtonGroup, null, /*#__PURE__*/_react.default.createElement(BlockStyleControls, {
|
|
715
|
-
readOnly: readOnly,
|
|
716
|
-
disabledButtons: disabledButtons,
|
|
717
|
-
editorState: editorState,
|
|
718
|
-
onToggle: this.toggleBlockType
|
|
719
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, null, /*#__PURE__*/_react.default.createElement(InlineStyleControls, {
|
|
720
|
-
readOnly: readOnly,
|
|
721
|
-
disabledButtons: disabledButtons,
|
|
722
|
-
editorState: editorState,
|
|
723
|
-
onToggle: this.toggleInlineStyle
|
|
724
|
-
})), /*#__PURE__*/_react.default.createElement(EnlargeButtonWrapper, null, /*#__PURE__*/_react.default.createElement(CustomEnlargeButton, {
|
|
725
|
-
onToggle: this.toggleEnlarge,
|
|
726
|
-
isEnlarged: isEnlarged
|
|
727
|
-
}))), /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
728
|
-
isDisabled: disabledButtons.includes(buttonNames.link)
|
|
729
|
-
}, /*#__PURE__*/_react.default.createElement(CustomLinkButton, {
|
|
730
|
-
isActive: entityType === 'LINK',
|
|
731
|
-
readOnly: readOnly,
|
|
732
|
-
editorState: editorState,
|
|
733
|
-
onChange: this.onChange
|
|
734
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
735
|
-
isDisabled: disabledButtons.includes(buttonNames.fontColor)
|
|
736
|
-
}, /*#__PURE__*/_react.default.createElement(CustomFontColorButton, {
|
|
737
|
-
isActive: Object.prototype.hasOwnProperty.call(customStyle, 'color'),
|
|
738
|
-
readOnly: readOnly,
|
|
739
|
-
editorState: editorState,
|
|
740
|
-
onChange: this.onChange
|
|
741
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
742
|
-
isDisabled: disabledButtons.includes(buttonNames.divider)
|
|
743
|
-
}, /*#__PURE__*/_react.default.createElement(CustomDividerButton, {
|
|
744
|
-
editorState: editorState,
|
|
745
|
-
onChange: this.onChange
|
|
746
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
747
|
-
isDisabled: disabledButtons.includes(buttonNames.annotation)
|
|
748
|
-
}, /*#__PURE__*/_react.default.createElement(CustomAnnotationButton, {
|
|
749
|
-
isActive: entityType === 'ANNOTATION',
|
|
750
|
-
readOnly: readOnly,
|
|
751
|
-
editorState: editorState,
|
|
752
|
-
onChange: this.onChange,
|
|
753
|
-
renderBasicEditor: renderBasicEditor,
|
|
754
|
-
decorators: _entityDecorator.default
|
|
755
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
756
|
-
isDisabled: disabledButtons.includes(buttonNames.image)
|
|
757
|
-
}, /*#__PURE__*/_react.default.createElement(CustomImageButton, {
|
|
758
|
-
readOnly: readOnly,
|
|
759
|
-
editorState: editorState,
|
|
760
|
-
onChange: this.onChange,
|
|
761
|
-
ImageSelector: _imageSelector.ImageSelector
|
|
762
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
763
|
-
isDisabled: disabledButtons.includes(buttonNames.video)
|
|
764
|
-
}, /*#__PURE__*/_react.default.createElement(CustomVideoButton, {
|
|
765
|
-
readOnly: readOnly,
|
|
766
|
-
editorState: editorState,
|
|
767
|
-
onChange: this.onChange,
|
|
768
|
-
VideoSelector: _videoSelector.VideoSelector
|
|
769
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
770
|
-
isDisabled: disabledButtons.includes(buttonNames.youtube)
|
|
771
|
-
}, /*#__PURE__*/_react.default.createElement(CustomYoutubeButton, {
|
|
772
|
-
readOnly: readOnly,
|
|
773
|
-
editorState: editorState,
|
|
774
|
-
onChange: this.onChange
|
|
775
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
776
|
-
isDisabled: disabledButtons.includes(buttonNames.audio)
|
|
777
|
-
}, /*#__PURE__*/_react.default.createElement(CustomAudioButton, {
|
|
778
|
-
readOnly: readOnly,
|
|
779
|
-
editorState: editorState,
|
|
780
|
-
onChange: this.onChange,
|
|
781
|
-
AudioSelector: _audioSelector.AudioSelector
|
|
782
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
783
|
-
isDisabled: disabledButtons.includes(buttonNames.slideshow)
|
|
784
|
-
}, /*#__PURE__*/_react.default.createElement(CustomSlideshowButton, {
|
|
785
|
-
readOnly: readOnly,
|
|
786
|
-
editorState: editorState,
|
|
787
|
-
onChange: this.onChange,
|
|
788
|
-
ImageSelector: _imageSelector.ImageSelector
|
|
789
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
790
|
-
isDisabled: disabledButtons.includes(buttonNames.infoBox)
|
|
791
|
-
}, /*#__PURE__*/_react.default.createElement(CustomInfoBoxButton, {
|
|
792
|
-
readOnly: readOnly,
|
|
793
|
-
editorState: editorState,
|
|
794
|
-
onChange: this.onChange,
|
|
795
|
-
renderBasicEditor: renderBasicEditor // decorators={decorators}
|
|
796
|
-
|
|
797
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
798
|
-
isDisabled: disabledButtons.includes(buttonNames.embed)
|
|
799
|
-
}, /*#__PURE__*/_react.default.createElement(CustomEmbeddedCodeButton, {
|
|
800
|
-
readOnly: readOnly,
|
|
801
|
-
editorState: editorState,
|
|
802
|
-
onChange: this.onChange
|
|
803
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
804
|
-
isDisabled: disabledButtons.includes(buttonNames.table)
|
|
805
|
-
}, /*#__PURE__*/_react.default.createElement(CustomTableButton, {
|
|
806
|
-
readOnly: readOnly,
|
|
807
|
-
editorState: editorState,
|
|
808
|
-
onChange: this.onChange
|
|
809
|
-
}))), /*#__PURE__*/_react.default.createElement(DraftEditorControlsWrapper, null, /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
810
|
-
isDisabled: disabledButtons.includes(buttonNames.textAlign)
|
|
811
|
-
}, /*#__PURE__*/_react.default.createElement(CustomAlignLeftButton, {
|
|
812
|
-
isActive: (0, _textAlign.getSelectionBlockData)(editorState, 'textAlign') === 'left',
|
|
813
|
-
readOnly: readOnly,
|
|
814
|
-
editorState: editorState,
|
|
815
|
-
onChange: this.onChange
|
|
816
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
817
|
-
isDisabled: disabledButtons.includes(buttonNames.textAlign)
|
|
818
|
-
}, /*#__PURE__*/_react.default.createElement(CustomAlignCenterButton, {
|
|
819
|
-
isActive: (0, _textAlign.getSelectionBlockData)(editorState, 'textAlign') === 'center',
|
|
820
|
-
readOnly: readOnly,
|
|
821
|
-
editorState: editorState,
|
|
822
|
-
onChange: this.onChange
|
|
823
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
824
|
-
isDisabled: disabledButtons.includes(buttonNames.colorBox)
|
|
825
|
-
}, /*#__PURE__*/_react.default.createElement(CustomColorBoxButton, {
|
|
826
|
-
readOnly: readOnly,
|
|
827
|
-
editorState: editorState,
|
|
828
|
-
onChange: this.onChange,
|
|
829
|
-
renderBasicEditor: renderBasicEditor // decorators={decorators}
|
|
830
|
-
|
|
831
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
832
|
-
isDisabled: disabledButtons.includes(buttonNames.backgroundColor)
|
|
833
|
-
}, /*#__PURE__*/_react.default.createElement(CustomBackgroundColorButton, {
|
|
834
|
-
isActive: Object.prototype.hasOwnProperty.call(customStyle, 'backgroundColor'),
|
|
835
|
-
readOnly: readOnly,
|
|
836
|
-
editorState: editorState,
|
|
837
|
-
onChange: this.onChange
|
|
838
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
839
|
-
isDisabled: disabledButtons.includes(buttonNames.backgroundImage)
|
|
840
|
-
}, /*#__PURE__*/_react.default.createElement(CustomBGImageButton, {
|
|
841
|
-
readOnly: readOnly,
|
|
842
|
-
editorState: editorState,
|
|
843
|
-
onChange: this.onChange,
|
|
844
|
-
ImageSelector: _imageSelector.ImageSelector,
|
|
845
|
-
renderBasicEditor: renderBasicEditor,
|
|
846
|
-
decorators: _entityDecorator.default
|
|
847
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
848
|
-
isDisabled: disabledButtons.includes(buttonNames.backgroundVideo)
|
|
849
|
-
}, /*#__PURE__*/_react.default.createElement(CustomBGVideoButton, {
|
|
850
|
-
readOnly: readOnly,
|
|
851
|
-
editorState: editorState,
|
|
852
|
-
onChange: this.onChange,
|
|
853
|
-
VideoSelector: _videoSelector.VideoSelector,
|
|
854
|
-
renderBasicEditor: renderBasicEditor,
|
|
855
|
-
decorators: _entityDecorator.default
|
|
856
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
857
|
-
isDisabled: disabledButtons.includes(buttonNames.relatedPost)
|
|
858
|
-
}, /*#__PURE__*/_react.default.createElement(CustomRelatedPostButton, {
|
|
859
|
-
readOnly: readOnly,
|
|
860
|
-
editorState: editorState,
|
|
861
|
-
onChange: this.onChange,
|
|
862
|
-
PostSelector: _postSelector.PostSelector
|
|
863
|
-
})), /*#__PURE__*/_react.default.createElement(ButtonGroup, {
|
|
864
|
-
isDisabled: disabledButtons.includes(buttonNames.sideIndex)
|
|
865
|
-
}, /*#__PURE__*/_react.default.createElement(CustomSideIndexButton, {
|
|
866
|
-
readOnly: readOnly,
|
|
867
|
-
editorState: editorState,
|
|
868
|
-
onChange: this.onChange
|
|
869
|
-
})))), /*#__PURE__*/_react.default.createElement(TextEditorWrapper, {
|
|
870
|
-
onClick: () => {
|
|
871
|
-
var _this$refs$editor;
|
|
872
|
-
|
|
873
|
-
// eslint-disable-next-line prettier/prettier
|
|
874
|
-
(_this$refs$editor = this.refs.editor) === null || _this$refs$editor === void 0 ? void 0 : _this$refs$editor.focus();
|
|
875
|
-
}
|
|
876
|
-
}, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
|
|
877
|
-
blockStyleFn: this.blockStyleFn.bind(this),
|
|
878
|
-
blockRendererFn: this.blockRendererFn,
|
|
879
|
-
customStyleMap: this.customStyleMap,
|
|
880
|
-
customStyleFn: this.customStyleFn,
|
|
881
|
-
editorState: editorState,
|
|
882
|
-
handleKeyCommand: this.handleKeyCommand,
|
|
883
|
-
handleReturn: this.handleReturn,
|
|
884
|
-
keyBindingFn: this.mapKeyToEditorCommand,
|
|
885
|
-
onChange: this.onChange,
|
|
886
|
-
placeholder: "Tell a story...",
|
|
887
|
-
ref: "editor",
|
|
888
|
-
spellCheck: true,
|
|
889
|
-
readOnly: readOnly
|
|
890
|
-
})))));
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
class StyleButton extends _react.default.Component {
|
|
896
|
-
onToggle = e => {
|
|
903
|
+
const StyleButton = props => {
|
|
904
|
+
const onToggle = e => {
|
|
897
905
|
e.preventDefault();
|
|
898
|
-
|
|
906
|
+
props.onToggle(props.style);
|
|
899
907
|
};
|
|
900
908
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
}
|
|
909
|
+
return /*#__PURE__*/_react.default.createElement(CustomButton, {
|
|
910
|
+
isDisabled: props.isDisabled,
|
|
911
|
+
isActive: props.isActive,
|
|
912
|
+
onMouseDown: onToggle,
|
|
913
|
+
readOnly: props.readOnly
|
|
914
|
+
}, props.icon && /*#__PURE__*/_react.default.createElement("i", {
|
|
915
|
+
className: props.icon
|
|
916
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, !props.icon ? props.label : ''));
|
|
917
|
+
};
|
|
913
918
|
|
|
914
919
|
const blockStyles = [{
|
|
915
920
|
label: 'H2',
|
|
916
|
-
style:
|
|
921
|
+
style: buttonNames.h2,
|
|
917
922
|
icon: ''
|
|
918
923
|
}, {
|
|
919
924
|
label: 'H3',
|
|
920
|
-
style:
|
|
925
|
+
style: buttonNames.h3,
|
|
921
926
|
icon: ''
|
|
922
927
|
}, {
|
|
923
928
|
label: 'H4',
|
|
924
|
-
style:
|
|
929
|
+
style: buttonNames.h4,
|
|
925
930
|
icon: ''
|
|
926
931
|
}, {
|
|
927
932
|
label: 'Blockquote',
|
|
928
|
-
style:
|
|
933
|
+
style: buttonNames.blockquote,
|
|
929
934
|
icon: 'fas fa-quote-right'
|
|
930
935
|
}, {
|
|
931
936
|
label: 'UL',
|
|
932
|
-
style:
|
|
937
|
+
style: buttonNames.ul,
|
|
933
938
|
icon: 'fas fa-list-ul'
|
|
934
939
|
}, {
|
|
935
940
|
label: 'OL',
|
|
936
|
-
style:
|
|
941
|
+
style: buttonNames.ol,
|
|
937
942
|
icon: 'fas fa-list-ol'
|
|
938
943
|
}, {
|
|
939
944
|
label: 'Code Block',
|
|
940
|
-
style:
|
|
945
|
+
style: buttonNames.codeBlock,
|
|
941
946
|
icon: 'fas fa-code'
|
|
942
947
|
}];
|
|
943
948
|
|
|
944
|
-
const BlockStyleControls =
|
|
945
|
-
|
|
946
|
-
|
|
949
|
+
const BlockStyleControls = ({
|
|
950
|
+
editorState,
|
|
951
|
+
disabledButtons,
|
|
952
|
+
hideOnMobileButtons,
|
|
953
|
+
onToggle,
|
|
954
|
+
readOnly
|
|
955
|
+
}) => {
|
|
956
|
+
const checkIsDisabled = (0, _hooks.useButtonDisabledChecker)({
|
|
957
|
+
mobileBoundary: MOBILE_BOUNDARY,
|
|
947
958
|
disabledButtons,
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
} = props;
|
|
959
|
+
hideOnMobileButtons
|
|
960
|
+
});
|
|
951
961
|
const selection = editorState.getSelection();
|
|
952
962
|
const blockType = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
|
|
953
963
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, blockStyles.map(type => /*#__PURE__*/_react.default.createElement(StyleButton, {
|
|
954
|
-
isDisabled:
|
|
964
|
+
isDisabled: checkIsDisabled(type.style),
|
|
955
965
|
key: type.label,
|
|
956
|
-
|
|
966
|
+
isActive: type.style === blockType,
|
|
957
967
|
label: type.label,
|
|
958
968
|
onToggle: onToggle,
|
|
959
969
|
style: type.style,
|
|
@@ -980,17 +990,28 @@ const inlineStyles = [{
|
|
|
980
990
|
icon: 'fas fa-terminal'
|
|
981
991
|
}];
|
|
982
992
|
|
|
983
|
-
const InlineStyleControls =
|
|
984
|
-
|
|
993
|
+
const InlineStyleControls = ({
|
|
994
|
+
editorState,
|
|
995
|
+
disabledButtons,
|
|
996
|
+
hideOnMobileButtons,
|
|
997
|
+
onToggle,
|
|
998
|
+
readOnly
|
|
999
|
+
}) => {
|
|
1000
|
+
const checkIsDisabled = (0, _hooks.useButtonDisabledChecker)({
|
|
1001
|
+
mobileBoundary: MOBILE_BOUNDARY,
|
|
1002
|
+
disabledButtons,
|
|
1003
|
+
hideOnMobileButtons
|
|
1004
|
+
});
|
|
1005
|
+
const currentStyle = editorState.getCurrentInlineStyle();
|
|
985
1006
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, inlineStyles.map(type => /*#__PURE__*/_react.default.createElement(StyleButton, {
|
|
986
|
-
isDisabled:
|
|
1007
|
+
isDisabled: checkIsDisabled(type.style.toLowerCase()),
|
|
987
1008
|
key: type.label,
|
|
988
|
-
|
|
1009
|
+
isActive: currentStyle.has(type.style),
|
|
989
1010
|
label: type.label,
|
|
990
|
-
onToggle:
|
|
1011
|
+
onToggle: onToggle,
|
|
991
1012
|
style: type.style,
|
|
992
1013
|
icon: type.icon,
|
|
993
|
-
readOnly:
|
|
1014
|
+
readOnly: readOnly
|
|
994
1015
|
})));
|
|
995
1016
|
};
|
|
996
1017
|
|
|
@@ -77,6 +77,8 @@ const buttonNames = {
|
|
|
77
77
|
// inline styles
|
|
78
78
|
bold: 'bold',
|
|
79
79
|
italic: 'italic',
|
|
80
|
+
sup: 'sup',
|
|
81
|
+
sub: 'sub',
|
|
80
82
|
underline: 'underline',
|
|
81
83
|
code: 'code',
|
|
82
84
|
// block styles
|
|
@@ -439,6 +441,12 @@ class RichTextEditor extends _react.default.Component {
|
|
|
439
441
|
fontFamily: '"Inconsolata", "Menlo", "Consolas", monospace',
|
|
440
442
|
fontSize: 16,
|
|
441
443
|
padding: 2
|
|
444
|
+
},
|
|
445
|
+
SUP: {
|
|
446
|
+
verticalAlign: 'super'
|
|
447
|
+
},
|
|
448
|
+
SUB: {
|
|
449
|
+
verticalAlign: 'sub'
|
|
442
450
|
}
|
|
443
451
|
};
|
|
444
452
|
}
|
|
@@ -920,6 +928,14 @@ const inlineStyles = [{
|
|
|
920
928
|
label: 'Italic',
|
|
921
929
|
style: 'ITALIC',
|
|
922
930
|
icon: 'fas fa-italic'
|
|
931
|
+
}, {
|
|
932
|
+
label: 'Superscript',
|
|
933
|
+
style: 'SUP',
|
|
934
|
+
icon: 'fas fa-superscript'
|
|
935
|
+
}, {
|
|
936
|
+
label: 'Subscript',
|
|
937
|
+
style: 'SUB',
|
|
938
|
+
icon: 'fas fa-subscript'
|
|
923
939
|
}, {
|
|
924
940
|
label: 'Underline',
|
|
925
941
|
style: 'UNDERLINE',
|