Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const resizeBase64Image = (src, options) => {
function CompactRichTextEditor({
wrapperClassName = 'ms-compact-text-editor',
toolbarOptions,
linkModalDirection = "auto",
...props
}) {

Expand Down Expand Up @@ -92,7 +93,9 @@ function CompactRichTextEditor({
inDropdown: false,
showOpenOptionOnHover: true,
defaultTargetOption: '_self',
options: ['link', 'unlink']
options: ['link', 'unlink'],
// popupClassName added to fix dropdown menu overflow when open link text widget. ref: https://github.com/jpuri/react-draft-wysiwyg/issues/664#issuecomment-511354161
popupClassName: linkModalDirection === 'left' ? 'popup-left-link-in-text-editor' : ''
},
blockType: {
inDropdown: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@ describe('CompactRichTextEditor component', () => {
const uploadImgInput = document.querySelector(".rdw-image-modal-upload-option");
expect(uploadImgInput).toBeTruthy();
});
it('test rendering TextEditor with linkModalDirection set to left', () => {
ReactDOM.render(
<CompactRichTextEditor linkModalDirection="left" />,
document.getElementById("container")
);
const textEditorContainer = document.querySelector(".ms-compact-text-editor.rdw-editor-wrapper");
expect(textEditorContainer).toBeTruthy();
const linkWidget = document.querySelector(".rdw-link-wrapper .rdw-option-wrapper");
TestUtils.act(() => {
TestUtils.Simulate.click(linkWidget);
});
const linkModal = document.querySelector(".rdw-link-modal");
expect(linkModal).toBeTruthy();
// Check that modal is positioned to the left
expect(linkModal.classList.contains('popup-left-link-in-text-editor')).toBeTruthy();
});
});
4 changes: 3 additions & 1 deletion web/client/components/widgets/builder/wizard/TextWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const Wizard = wizardHandlers(WizardContainer);
export default ({
onChange = () => {}, onFinish = () => {}, setPage = () => {},
step = 0,
editorData = {}
editorData = {},
linkModalDirection = "auto"
} = {}) => (
<Wizard
step={step}
Expand All @@ -29,6 +30,7 @@ export default ({
key="widget-options"
data={editorData}
onChange={onChange}
linkModalDirection={linkModalDirection}
/>
</Wizard>
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DescriptorEditor = withDebounceOnCallback(
"editorState"
)(CompactRichTextEditor);

function TextOptions({ data = {}, onChange = () => {} }) {
function TextOptions({ data = {}, onChange = () => {}, linkModalDirection = "auto" }) {
const [editorState, setEditorState] = useState(
htmlToDraftJSEditorState(data.text || "")
);
Expand All @@ -48,6 +48,7 @@ function TextOptions({ data = {}, onChange = () => {} }) {
</Form>
</Col>
<DescriptorEditor
linkModalDirection={linkModalDirection}
uploadEnabled
editorState={editorState}
onEditorStateChange={(newEditorState) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function AnnotationsFields({
</ControlLabel>}
{isEditable
? <DescriptionEditor
linkModalDirection={'left'}
editorState={editorState[field.name]}
onEditorStateChange={(newEditorState) => {
const previousHTML = draftJSEditorStateToHtml(editorState[field.name]);
Expand Down
1 change: 1 addition & 0 deletions web/client/plugins/DashboardEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class DashboardEditorComponent extends React.Component {
enabled={this.props.editing}
onClose={() => this.props.setEditing(false)}
catalog={this.props.catalog}
linkModalDirection={"left"}
/>
</div>
: false;
Expand Down
4 changes: 2 additions & 2 deletions web/client/plugins/widgetbuilder/TextBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const Builder = connect(
wizardStateToProps
)(TextWizardComp);

export default ({ enabled, onClose = () => {}} = {}) =>
export default ({ enabled, onClose = () => {}, linkModalDirection = "auto"} = {}) =>
(<BorderLayout
header={<BuilderHeader onClose={onClose}><Toolbar /></BuilderHeader>}
>
{enabled ? <Builder /> : null}
{enabled ? <Builder linkModalDirection={linkModalDirection} /> : null}
</BorderLayout>);
6 changes: 6 additions & 0 deletions web/client/themes/default/less/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ div#sync-popover.popover {
font-style: italic;
}
}
.rdw-editor-wrapper{
.popup-left-link-in-text-editor{
left: initial !important;
right: 5px;
}
}


.DraftEditor-editorContainer, // selector editor
Expand Down
Loading