|
|
@@ -1,5 +1,6 @@
|
|
|
-import { type JSX, useCallback, useState } from 'react';
|
|
|
-import { Collapse } from 'reactstrap';
|
|
|
+import { type JSX, useCallback, useId, useState } from 'react';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
+import { Collapse, UncontrolledTooltip } from 'reactstrap';
|
|
|
|
|
|
import type { GlobalCodeMirrorEditorKey } from '../../../../consts';
|
|
|
import { useCodeMirrorEditorIsolated } from '../../../stores/codemirror-editor';
|
|
|
@@ -16,16 +17,24 @@ type TogglarProps = {
|
|
|
const TextFormatToolsToggler = (props: TogglarProps): JSX.Element => {
|
|
|
const { isOpen, onClick } = props;
|
|
|
|
|
|
+ const id = useId();
|
|
|
+ const { t } = useTranslation('translation');
|
|
|
const activeClass = isOpen ? 'active' : '';
|
|
|
|
|
|
return (
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className={`btn btn-toolbar-button ${btnTextFormatToolsTogglerClass} ${activeClass}`}
|
|
|
- onClick={onClick}
|
|
|
- >
|
|
|
- <span className="material-symbols-outlined fs-3">match_case</span>
|
|
|
- </button>
|
|
|
+ <>
|
|
|
+ <button
|
|
|
+ id={id}
|
|
|
+ type="button"
|
|
|
+ className={`btn btn-toolbar-button ${btnTextFormatToolsTogglerClass} ${activeClass}`}
|
|
|
+ onClick={onClick}
|
|
|
+ >
|
|
|
+ <span className="material-symbols-outlined fs-3">match_case</span>
|
|
|
+ </button>
|
|
|
+ <UncontrolledTooltip placement="top" target={CSS.escape(id)}>
|
|
|
+ {t('toolbar.text_formatting')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|
|
|
@@ -37,6 +46,8 @@ type TextFormatToolsType = {
|
|
|
export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
const { editorKey, onTextFormatToolsCollapseChange } = props;
|
|
|
const [isOpen, setOpen] = useState(false);
|
|
|
+ const baseId = useId();
|
|
|
+ const { t } = useTranslation('translation');
|
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey);
|
|
|
|
|
|
const toggle = useCallback(() => {
|
|
|
@@ -66,13 +77,21 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
>
|
|
|
<div className="d-flex px-1 gap-1" style={{ width: '220px' }}>
|
|
|
<button
|
|
|
+ id={`${baseId}-bold`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertMarkdownElements('**', '**')}
|
|
|
>
|
|
|
<span className="material-symbols-outlined fs-5">format_bold</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-bold`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.bold')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-italic`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertMarkdownElements('*', '*')}
|
|
|
@@ -81,7 +100,14 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
format_italic
|
|
|
</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-italic`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.italic')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-strikethrough`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertMarkdownElements('~', '~')}
|
|
|
@@ -90,7 +116,14 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
format_strikethrough
|
|
|
</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-strikethrough`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.strikethrough')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-heading`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertPrefix('#', true)}
|
|
|
@@ -98,14 +131,28 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
{/* TODO: chack and fix font-size. see: https://redmine.weseek.co.jp/issues/143015 */}
|
|
|
<span className="growi-custom-icons">header</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-heading`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.heading')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-code`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertMarkdownElements('`', '`')}
|
|
|
>
|
|
|
<span className="material-symbols-outlined fs-5">code</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-code`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.code')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-bullet-list`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertPrefix('-')}
|
|
|
@@ -114,7 +161,14 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
format_list_bulleted
|
|
|
</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-bullet-list`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.bullet_list')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-numbered-list`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertPrefix('1.')}
|
|
|
@@ -123,7 +177,14 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
format_list_numbered
|
|
|
</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-numbered-list`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.numbered_list')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-quote`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertPrefix('>')}
|
|
|
@@ -131,13 +192,26 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
|
|
|
{/* TODO: chack and fix font-size. see: https://redmine.weseek.co.jp/issues/143015 */}
|
|
|
<span className="growi-custom-icons">format_quote</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-quote`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.quote')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
<button
|
|
|
+ id={`${baseId}-checklist`}
|
|
|
type="button"
|
|
|
className="btn btn-toolbar-button"
|
|
|
onClick={() => onClickInsertPrefix('- [ ]')}
|
|
|
>
|
|
|
<span className="material-symbols-outlined fs-5">checklist</span>
|
|
|
</button>
|
|
|
+ <UncontrolledTooltip
|
|
|
+ placement="top"
|
|
|
+ target={CSS.escape(`${baseId}-checklist`)}
|
|
|
+ >
|
|
|
+ {t('toolbar.checklist')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
</div>
|
|
|
</Collapse>
|
|
|
</div>
|