文件
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

82 行
2.1 KiB
TypeScript

import * as React from 'react';
import CommandService from '@joplin/lib/services/CommandService';
import ToolbarBase from '../../../ToolbarBase';
import { utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
import { connect } from 'react-redux';
import { AppState } from '../../../../app.reducer';
import ToolbarButtonUtils, { ToolbarItem } from '@joplin/lib/services/commands/ToolbarButtonUtils';
import stateToWhenClauseContext from '../../../../services/commands/stateToWhenClauseContext';
import { _ } from '@joplin/lib/locale';
import { buildStyle } from '@joplin/lib/theme';
interface ToolbarProps {
themeId: number;
toolbarButtonInfos: ToolbarItem[];
disabled?: boolean;
}
function styles_(props: ToolbarProps) {
return buildStyle('CodeMirrorToolbar', props.themeId, () => {
return {
root: {
flex: 1,
marginBottom: 0,
},
};
});
}
const toolbarButtonUtils = new ToolbarButtonUtils(CommandService.instance());
function Toolbar(props: ToolbarProps) {
const styles = styles_(props);
return (
<ToolbarBase
id="CodeMirrorToolbar"
style={styles.root}
scrollable={true}
items={props.toolbarButtonInfos}
disabled={!!props.disabled}
aria-label={_('Editor actions')}
/>
);
}
interface ConnectProps {
windowId: string;
}
const mapStateToProps = (state: AppState, connectProps: ConnectProps) => {
const whenClauseContext = stateToWhenClauseContext(state, { windowId: connectProps.windowId });
const commandNames = [
'historyBackward',
'historyForward',
'toggleExternalEditing',
'-',
'textBold',
'textItalic',
'-',
'textLink',
'linkToNote',
'textCode',
'attachFile',
'-',
'textBulletedList',
'textNumberedList',
'textCheckbox',
'textHeading',
'textHorizontalRule',
'textBlockQuote',
'editor.textTable',
'insertDateTime',
'toggleEditors',
].concat(pluginUtils.commandNamesFromViews(state.pluginService.plugins, 'editorToolbar'));
return {
toolbarButtonInfos: toolbarButtonUtils.commandsToToolbarButtons(commandNames, whenClauseContext),
};
};
export default connect(mapStateToProps)(Toolbar);