Skip to content

Commit

Permalink
[Feature]support codeshow wrap-button (#2924)
Browse files Browse the repository at this point in the history
* support-code-show-wrap-button

* Spotless Apply

---------

Co-authored-by: Zzm0809 <Zzm0809@users.noreply.github.com>
  • Loading branch information
Zzm0809 and Zzm0809 authored Jan 6, 2024
1 parent 6bfe466 commit 40aa410
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion dinky-web/src/components/CustomEditor/CodeShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ const CodeShow = (props: CodeShowFormProps) => {
return URL.createObjectURL(blob);
};

const handleWrap = () => {
editorInstance?.current?.updateOptions({ wordWrap: 'on' });
};

/**
* editorDidMount
* @param {editor.IStandaloneCodeEditor} editor
Expand Down Expand Up @@ -200,7 +204,8 @@ const CodeShow = (props: CodeShowFormProps) => {
handleBackBottom,
handleUpScroll,
handleDownScroll,
handleDownloadLog
handleDownloadLog,
handleWrap
};

/**
Expand Down
10 changes: 9 additions & 1 deletion dinky-web/src/components/CustomEditor/EditorFloatBtn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { l } from '@/utils/intl';
import {
CloudDownloadOutlined,
DownCircleFilled,
EnterOutlined,
StopFilled,
SyncOutlined,
UpCircleFilled,
Expand All @@ -48,6 +49,7 @@ type EditFloatBtnProps = {
handleUpScroll?: () => void; // up scroll callback
handleDownScroll?: () => void; // down scroll callback
handleDownloadLog?: () => string; // download log callback
handleWrap?: () => void; // wrap callback
};
const EditorFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
/**
Expand All @@ -65,7 +67,8 @@ const EditorFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
handleBackBottom,
handleUpScroll,
handleDownScroll,
handleDownloadLog
handleDownloadLog,
handleWrap
} = props;

/**
Expand Down Expand Up @@ -121,6 +124,11 @@ const EditorFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
href={handleDownloadLog ? handleDownloadLog() : '123 '}
title={'Download'}
/>
<CircleBtn
icon={<EnterOutlined />}
onClick={() => handleWrap && handleWrap()}
title={l('button.wrap')}
/>
</Space>
</>
);
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/en-US/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
'button.backTop': 'Back Top',
'button.backBottom': 'Back Bottom',
'button.downScroll': 'Down Scroll',
'button.wrap': 'Wrap',
'button.upScroll': 'Up Scroll',
'button.stopRefresh': 'Stop Auto Refresh',
'button.startRefresh': 'Start Auto Refresh(5s/e)',
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/zh-CN/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
'button.backTop': '返回顶部',
'button.backBottom': '去底部',
'button.downScroll': '向下滚动',
'button.wrap': '换行',
'button.upScroll': '向上滚动',
'button.stopRefresh': '停止自动刷新',
'button.startRefresh': '开始自动刷新(5s/次)',
Expand Down

0 comments on commit 40aa410

Please sign in to comment.