|
|
@@ -1,5 +1,8 @@
|
|
|
import React from 'react';
|
|
|
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
+
|
|
|
+
|
|
|
export const ExternalLinkIcon = () => {
|
|
|
return (
|
|
|
<svg
|
|
|
@@ -36,17 +39,16 @@ const GuideRow = ({
|
|
|
code: string;
|
|
|
preview: React.ReactNode;
|
|
|
}) => {
|
|
|
+ const { t } = useTranslation();
|
|
|
const handleCopy = async () => {
|
|
|
await navigator.clipboard.writeText(code);
|
|
|
- alert('コピーしました!');
|
|
|
+ alert(t('editor_guide.textstyle.copy_done'));
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
<section className={title !== '' ? 'mt-4 mb-1' : 'mb-1'}>
|
|
|
{title !== '' && <h3 className="h6 fw-bold mb-2">{title}</h3>}
|
|
|
- {/* flex-nowrap を追加して、全体が縦に並ばないように強制します */}
|
|
|
<div className="d-flex flex-row align-items-center gap-3 py-1 flex-nowrap">
|
|
|
- {/* flex-shrink-0 を追加して、コード枠が右側のテキストに押しつぶされないようにします */}
|
|
|
<div onClick={handleCopy} style={{ cursor: 'pointer' }} className="flex-shrink-0">
|
|
|
<div
|
|
|
className="bg-dark text-light p-2 ps-2 pe-4 rounded position-relative"
|
|
|
@@ -63,8 +65,6 @@ const GuideRow = ({
|
|
|
</small>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- {/* whiteSpace: 'nowrap' を追加して、右側のプレビューが勝手に改行されるのを防ぎます */}
|
|
|
<div className="flex-grow-1" style={{ whiteSpace: 'nowrap' }}>
|
|
|
<div className="wiki-content small">
|
|
|
{preview}
|
|
|
@@ -75,117 +75,130 @@ const GuideRow = ({
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const TEXT_STYLE_GUIDES = [
|
|
|
- {
|
|
|
- id: 'bold',
|
|
|
- title: '太字',
|
|
|
- code: 'これは **太字** です\nこれは __太字__ です',
|
|
|
- preview: <div className="lh-base">これは <strong>太字</strong> です<br />これは <strong>太字</strong> です</div>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'italic',
|
|
|
- title: '斜体',
|
|
|
- code: 'これは *斜体* です\nこれは _斜体_ です',
|
|
|
- preview: <div className="lh-base">これは <em>斜体</em> です<br />これは <em>斜体</em> です</div>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'strikethrough',
|
|
|
- title: '取り消し線',
|
|
|
- code: '~~取り消します~~',
|
|
|
- preview: <del>取り消します</del>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'inline-code',
|
|
|
- title: 'インラインコード',
|
|
|
- code: '`インラインコード` \n~~~インラインコード~~~',
|
|
|
- preview: (
|
|
|
- <div className="d-flex flex-column gap-2">
|
|
|
- <code
|
|
|
- className="rounded px-1"
|
|
|
- style={{
|
|
|
- width: 'fit-content',
|
|
|
- color: '#D63384', // 文字の色
|
|
|
- border: '1px solid #D63384', // 枠線の色(太さ1px、実線、指定の色)
|
|
|
- backgroundColor: 'transparent', // 背景を透明にする場合(必要に応じて)
|
|
|
- }}
|
|
|
- >
|
|
|
- インラインコード
|
|
|
- </code>
|
|
|
- <code
|
|
|
- className="rounded px-1"
|
|
|
- style={{
|
|
|
- width: 'fit-content',
|
|
|
- color: '#D63384', // 文字の色
|
|
|
- border: '1px solid #D63384', // 枠線の色
|
|
|
- backgroundColor: 'transparent',
|
|
|
- }}
|
|
|
- >
|
|
|
- インラインコード
|
|
|
- </code>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'bold-italic',
|
|
|
- title: '全体が太字か斜体',
|
|
|
- code: '***このテキストはすべて\n重要です***',
|
|
|
- preview: <strong><u>このテキストはすべて重要です</u></strong>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'emoji',
|
|
|
- title: '絵文字',
|
|
|
- code: ':+1:\n:white_check_mark:\n:lock:',
|
|
|
- preview: <span style={{ fontSize: '1.2rem' }}>👍✅🔒</span>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'sub',
|
|
|
- title: '下付き・上付き',
|
|
|
- code: 'これは<sub>下付き</sub>です',
|
|
|
- preview: <span>これは<sub>下付き</sub>テキストです</span>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'sup',
|
|
|
- title: '',
|
|
|
- code: 'これは<sup>上付き</sup>です',
|
|
|
- preview: <span>これは<sup>上付き</sup>テキストです</span>,
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'link-docs',
|
|
|
- title: 'ラベル付きリンク',
|
|
|
- code: '[GROWI ドキュメント](https://docs.growi.org/ja/g)',
|
|
|
- preview: (
|
|
|
- <a
|
|
|
- href="https://docs.growi.org/ja/g"
|
|
|
- target="_blank"
|
|
|
- rel="noreferrer"
|
|
|
- className="text-secondary text-decoration-underline"
|
|
|
- style={{ color: '#777570' }}
|
|
|
- onClick={e => e.stopPropagation()}
|
|
|
- >
|
|
|
- GROWI のリンク
|
|
|
- <ExternalLinkIcon />
|
|
|
- </a>
|
|
|
- ),
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'link-sandbox',
|
|
|
- title: '',
|
|
|
- code: '[砂場ページはこちら](/Sandbox)',
|
|
|
- preview: (
|
|
|
- <a
|
|
|
- href="/Sandbox"
|
|
|
- className="text-secondary text-decoration-underline"
|
|
|
- style={{ color: '#777570' }}
|
|
|
- onClick={e => e.stopPropagation()}
|
|
|
- >
|
|
|
- 砂場ページはこちら
|
|
|
- <ExternalLinkIcon />
|
|
|
- </a>
|
|
|
- ),
|
|
|
- },
|
|
|
-];
|
|
|
|
|
|
export const TextStyleTab: React.FC = () => {
|
|
|
+ const { t } = useTranslation();
|
|
|
+ const ts = 'editor_guide.textstyle';
|
|
|
+
|
|
|
+ const TEXT_STYLE_GUIDES = [
|
|
|
+ {
|
|
|
+ id: 'bold',
|
|
|
+ title: t(`${ts}.bold`),
|
|
|
+ code: `${t(`${ts}.is_text`, { val: `**${t(`${ts}.bold`)}**` })}\n${t(`${ts}.is_text`, { val: `__${t(`${ts}.bold`)}__` })}`,
|
|
|
+ preview: (
|
|
|
+ <div className="lh-base">
|
|
|
+ {t(`${ts}.this`)} <strong>{t(`${ts}.bold`)}</strong> {t(`${ts}.is`)}<br />
|
|
|
+ {t(`${ts}.this`)} <strong>{t(`${ts}.bold`)}</strong> {t(`${ts}.is`)}
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'italic',
|
|
|
+ title: t(`${ts}.italic`),
|
|
|
+ code: `${t(`${ts}.this`)} *${t(`${ts}.italic`)}* ${t(`${ts}.is`)}\n${t(`${ts}.this`)} _${t(`${ts}.italic`)}_ ${t(`${ts}.is`)}`,
|
|
|
+ preview: (
|
|
|
+ <div className="lh-base">
|
|
|
+ {t(`${ts}.this`)} <em>{t(`${ts}.italic`)}</em> {t(`${ts}.is`)}<br />
|
|
|
+ {t(`${ts}.this`)} <em>{t(`${ts}.italic`)}</em> {t(`${ts}.is`)}
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'strikethrough',
|
|
|
+ title: t(`${ts}.strikethrough`),
|
|
|
+ code: `~~${t(`${ts}.strikethrough`)}~~`,
|
|
|
+ preview: <del>{t(`${ts}.strikethrough`)}</del>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'inline-code',
|
|
|
+ title: t(`${ts}.inline_code`),
|
|
|
+ code: `\`${t(`${ts}.inline_code`)}\` \n~~~${t(`${ts}.inline_code`)}~~~`,
|
|
|
+ preview: (
|
|
|
+ <div className="d-flex flex-column gap-2">
|
|
|
+ <code
|
|
|
+ className="rounded px-1"
|
|
|
+ style={{
|
|
|
+ width: 'fit-content',
|
|
|
+ color: '#D63384', // 文字の色
|
|
|
+ border: '1px solid #D63384', // 枠線の色(太さ1px、実線、指定の色)
|
|
|
+ backgroundColor: 'transparent', // 背景を透明にする場合(必要に応じて)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {t(`${ts}.inline_code`)}
|
|
|
+ </code>
|
|
|
+ <code
|
|
|
+ className="rounded px-1"
|
|
|
+ style={{
|
|
|
+ width: 'fit-content',
|
|
|
+ color: '#D63384', // 文字の色
|
|
|
+ border: '1px solid #D63384', // 枠線の色
|
|
|
+ backgroundColor: 'transparent',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {t(`${ts}.inline_code`)}
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'bold-italic',
|
|
|
+ title: t(`${ts}.bold_italic`),
|
|
|
+ code: `***${t(`${ts}.all_important`)}***`,
|
|
|
+ preview: <strong><u>{t(`${ts}.all_important`).replace('\n', '')}</u></strong>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'emoji',
|
|
|
+ title: t(`${ts}.emoji`),
|
|
|
+ code: ':+1:\n:white_check_mark:\n:lock:',
|
|
|
+ preview: <span style={{ fontSize: '1.2rem' }}>👍✅🔒</span>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'sub',
|
|
|
+ title: t(`${ts}.sub_sup`),
|
|
|
+ code: t(`${ts}.is_text`, { val: `<sub>${t(`${ts}.sub_text`)}</sub>` }),
|
|
|
+ preview: <span>{t(`${ts}.this`)} <sub>{t(`${ts}.sub_text`)}</sub> {t(`${ts}.is`)}</span>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'sup',
|
|
|
+ title: '',
|
|
|
+ code: t(`${ts}.is_text`, { val: `<sup>${t(`${ts}.sup_text`)}</sup>` }),
|
|
|
+ preview: <span>{t(`${ts}.this`)} <sup>{t(`${ts}.sup_text`)}</sup> {t(`${ts}.is`)}</span>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'link-docs',
|
|
|
+ title: t(`${ts}.link_label`),
|
|
|
+ code: `[${t(`${ts}.link_docs`)}](https://docs.growi.org/ja/g)`,
|
|
|
+ preview: (
|
|
|
+ <a
|
|
|
+ href="https://docs.growi.org/ja/g"
|
|
|
+ target="_blank"
|
|
|
+ rel="noreferrer"
|
|
|
+ className="text-secondary text-decoration-underline"
|
|
|
+ style={{ color: '#777570' }}
|
|
|
+ onClick={e => e.stopPropagation()}
|
|
|
+ >
|
|
|
+ {t(`${ts}.link_growi`)}
|
|
|
+ <ExternalLinkIcon />
|
|
|
+ </a>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'link-sandbox',
|
|
|
+ title: '',
|
|
|
+ code: `[${t(`${ts}.link_sandbox`)}](/Sandbox)`,
|
|
|
+ preview: (
|
|
|
+ <a
|
|
|
+ href="/Sandbox"
|
|
|
+ className="text-secondary text-decoration-underline"
|
|
|
+ style={{ color: '#777570' }}
|
|
|
+ onClick={e => e.stopPropagation()}
|
|
|
+ >
|
|
|
+ {t(`${ts}.link_sandbox`)}
|
|
|
+ <ExternalLinkIcon />
|
|
|
+ </a>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
return (
|
|
|
<div className="px-4 py-2 overflow-y-auto" style={{ maxHeight: '80vh' }}>
|
|
|
{TEXT_STYLE_GUIDES.map(item => (
|