Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: update markdown editor interaction and style #853

Merged
merged 3 commits into from
Aug 5, 2021
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
11 changes: 5 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 36 additions & 12 deletions shell/app/common/components/markdown-editor/index.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
.markdown-editor {
.markdown-editor-content {
display: block;

.rc-md-editor {
border-radius: $radius;
padding-bottom: 42px;

.sec-md .input:focus {
outline: 1px solid $color-active-border;
.navigation-nav.left {
min-width: 120px;
}
}

&.show-btn {
.rc-md-editor {
padding-bottom: 50px;
.editor-container {
padding: $p8;
> .section > .section-container {
padding: $p4;
padding-top: 0;
}
.sec-md {
.input {
padding: $p8;
border: 1px solid $color-border;
border-radius: $radius-lg;
background-color: $whitesmoke;

&:focus {
border-color: $color-active-border;
box-shadow: rgb(106 84 158 / 30%) 0 0 0 3px;
background-color: $white;
}
}
}

.sec-html {
border-bottom: 1px solid $color-border;
}
}

.tool-bar {
display: none;
}
}

.md-content {
padding: 0;
}
}

.disable-edit {
.rc-md-navigation .right {
pointer-events: none;

.button {
color: $color-disabled;
}
visibility: hidden;
}
}

Expand Down
38 changes: 16 additions & 22 deletions shell/app/common/components/markdown-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ interface IProps {
value?: string | null;
placeholder?: string;
maxLength?: number;
isShowRate: boolean;
score: number;
defaultMode?: 'md' | 'html' | 'both';
isShowRate?: boolean;
score?: number;
defaultMode?: 'md' | 'html';
extraRight?: ReactElement | ReactElement[];
btnText?: string;
readOnly?: boolean;
Expand Down Expand Up @@ -71,8 +71,8 @@ export default class MarkdownEditor extends PureComponent<IProps, IState> {
tempContent: props.value || '',
score: props.score || 0,
view: {
md: defaultMode === 'md' || defaultMode === 'both',
html: defaultMode === 'html' || defaultMode === 'both',
md: defaultMode === 'md',
html: defaultMode === 'html',
menu: true,
},
};
Expand Down Expand Up @@ -140,16 +140,12 @@ export default class MarkdownEditor extends PureComponent<IProps, IState> {
};

renderButton() {
const { onSubmit, onCancel, btnText, onSetLS } = this.props;
const btns: JSX.Element[] = [];

if (onSubmit) {
btns.push(
<Button key="md-editor-submit-btn" className="my8 mr8" type="primary" onClick={this.onSubmit}>
{btnText || i18n.t('common:submit')}
</Button>,
);
}
const { onCancel, btnText, onSetLS } = this.props;
const btns: JSX.Element[] = [
<Button key="md-editor-submit-btn" className="my8 mr8" type="primary" onClick={this.onSubmit}>
{btnText || i18n.t('common:submit')}
</Button>,
];

if (onSetLS) {
btns.push(
Expand All @@ -161,8 +157,8 @@ export default class MarkdownEditor extends PureComponent<IProps, IState> {

if (onCancel) {
btns.push(
<Button key="md-editor-cancel-btn" className="mx-2 mr-2" onClick={onCancel}>
{i18n.t('common:cancel')}
<Button key="md-editor-cancel-btn" className="mx-2 mr-2" onClick={() => onCancel()}>
{i18n.t('restore')}
</Button>,
);
}
Expand Down Expand Up @@ -223,11 +219,9 @@ export default class MarkdownEditor extends PureComponent<IProps, IState> {
<Rate allowHalf onChange={this.onRateChange} value={this.state.score} />
</div>
</IF>
{view.md ? (
<div className="absolute left-2 " style={{ top: height - 42 }}>
{this.renderButton()}
</div>
) : null}
<div className="absolute left-2 " style={{ top: height - 42 }}>
{this.renderButton()}
</div>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const IssueCommentBox = (props: IProps) => {
onChange={(val: any) => {
updater.content(val);
}}
style={{ height: '140px' }}
style={{ height: '200px' }}
maxLength={3000}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"@babel/runtime": "^7.12.5",
"@erda-ui/dashboard-configurator": "1.0.24",
"@erda-ui/react-markdown-editor-lite": "^1.4.3",
"@erda-ui/react-markdown-editor-lite": "^1.4.4",
"@icon-park/react": "^1.3.3",
"ace-builds": "^1.4.7",
"ansi_up": "^5.0.1",
Expand Down