这是indexloc提供的服务,不要输入任何密码
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
28 changes: 16 additions & 12 deletions console/src/components/Common/CustomInputTypes/JsonInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,25 @@ const JsonInput = props => {

const editor = editorType === JSONKEY ? getJsonEditor() : getNormalEditor();

const toggleIcon = (
<i
key="icon_json_editor"
className={
'fa ' +
styles.modeToggleButton +
(editorType === JSONKEY ? ' fa-compress' : ' fa-expand')
}
onClick={() => updateState(toggleEditorType)}
title={
(editorType === JSONKEY ? 'Collapse' : 'Expand') + ' (Ctrl + Space)'
}
/>
);

return (
<span className="json_input_editor">
<label>{editor}</label>
<i
key="icon_json_editor"
className={
'fa ' +
styles.modeToggleButton +
(editorType === JSONKEY ? ' fa-compress' : ' fa-expand')
}
onClick={() => updateState(toggleEditorType)}
title={
(editorType === JSONKEY ? 'Collapse' : 'Expand') + ' (Ctrl + Space)'
}
/>
{toggleIcon}
</span>
);
};
Expand Down
85 changes: 54 additions & 31 deletions console/src/components/Common/CustomInputTypes/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ const EDITORTYPES = [
];

// human readable editor names
const EDITORTYPENAMES = [
'single line input',
'multi-line text input',
'markdown',
'html',
];
// const EDITORTYPENAMES = [
// 'single line input',
// 'multi-line text input',
// 'markdown',
// 'html',
// ];

// short human readable editor names
// for the visible label
const SHORTEDITORTYPENAMES = ['', 'multi-line', 'markdown', 'html'];
// const SHORT_EDITOR_TYPE_NAMES = ['', 'multi-line', 'markdown', 'html'];

const NORMALKEY = 0;
const NORMAL_KEY = 0;
const MULTILINE_KEY = 1;

const createInitialState = data => {
const initialState = {
editorType: NORMALKEY,
editorType: NORMAL_KEY,
data: data,
};
return initialState;
Expand All @@ -57,7 +58,9 @@ const TextInput = props => {
};

const cycleEditorType = currentState => {
const nextEditorType = (currentState.editorType + 1) % EDITORTYPES.length;
// const nextEditorType = (currentState.editorType + 1) % EDITORTYPES.length;
const nextEditorType =
currentState.editorType === NORMAL_KEY ? MULTILINE_KEY : NORMAL_KEY;

return {
...currentState,
Expand Down Expand Up @@ -133,33 +136,53 @@ const TextInput = props => {
};

const editor =
editorType === NORMALKEY
editorType === NORMAL_KEY
? getNormalEditor()
: getAceEditor(EDITORTYPES[editorType]);

// const cycleIcon = (
// <span
// onClick={() => updateState(cycleEditorType)}
// title={
// 'Change to ' +
// EDITORTYPENAMES[(editorType + 1) % EDITORTYPES.length] +
// ' (Ctrl + Space)'
// }
// >
// <span className={styles.modeType}>
// {SHORT_EDITOR_TYPE_NAMES[editorType]}
// </span>
// <i
// key="icon_text_editor"
// className={
// 'fa ' +
// styles.modeToggleButton +
// (editorType === NORMAL_KEY ? ' fa-expand' : ' fa-chevron-right')
// }
// />
// </span>
// );

const cycleIcon = (
<i
key="icon_text_editor"
className={
'fa ' +
styles.modeToggleButton +
(editorType === MULTILINE_KEY ? ' fa-compress' : ' fa-expand')
}
onClick={() => updateState(cycleEditorType)}
title={
(editorType === MULTILINE_KEY ? 'Collapse' : 'Expand') +
' (Ctrl + Space)'
}
/>
);

return (
<span className="text_input_editor">
<label>{editor}</label>
<span
onClick={() => updateState(cycleEditorType)}
title={
'Change to ' +
EDITORTYPENAMES[(editorType + 1) % EDITORTYPES.length] +
' (Ctrl + Space)'
}
>
<span className={styles.modeType}>
{SHORTEDITORTYPENAMES[editorType]}
</span>
<i
key="icon_text_editor"
className={
'fa ' +
styles.modeToggleButton +
(editorType === NORMALKEY ? ' fa-expand' : ' fa-chevron-right')
}
/>
</span>
{cycleIcon}
</span>
);
};
Expand Down