#299 add italic format button

This commit is contained in:
konstantin krivlenia
2019-04-14 11:18:14 +03:00
parent 4c5363835f
commit 2b68c8e8d3
4 changed files with 22 additions and 2 deletions
+2
View File
@@ -3,8 +3,10 @@ declare namespace JSX {
'markdown-toolbar': {
for: string;
children?: any;
className: string;
};
'md-bold': any;
'md-header': any;
'md-italic': any;
}
}
@@ -1,4 +1,4 @@
markdown-toolbar {
.input__toolbar {
display: block;
float: right;
}
@@ -0,0 +1,13 @@
/** @jsx h */
import { h } from 'preact';
export default function ItalicIcon() {
return (
<svg className="input__toolbar-icon" viewBox="0 0 6 16" version="1.1" width="6" height="16" aria-hidden="true">
<path
fill-rule="evenodd"
d="M2.81 5h1.98L3 14H1l1.81-9zm.36-2.7c0-.7.58-1.3 1.33-1.3.56 0 1.13.38 1.13 1.03 0 .75-.59 1.3-1.33 1.3-.58 0-1.13-.38-1.13-1.03z"
/>
</svg>
);
}
@@ -3,6 +3,7 @@ import { h, Component, RenderableProps } from 'preact';
import '@github/markdown-toolbar-element';
import BoldIcon from './markdown-toolbar-icons/bold-icon';
import HeaderIcon from './markdown-toolbar-icons/header-icon';
import ItalicIcon from './markdown-toolbar-icons/italic-icon';
interface Props {
textareaId: string;
@@ -10,11 +11,12 @@ interface Props {
const boldLabel = 'Add bold text <cmd-b>';
const headerLabel = 'Add header text';
const italicLabel = 'Add italic text <cmd-i>';
export default class MarkdownToolbar extends Component<Props> {
render(props: RenderableProps<Props>) {
return (
<markdown-toolbar for={props.textareaId}>
<markdown-toolbar className="input__toolbar" for={props.textareaId}>
<div className="input__toolbar-group">
<md-header className="input__toolbar-item" title={headerLabel} aria-label={headerLabel}>
<HeaderIcon />
@@ -22,6 +24,9 @@ export default class MarkdownToolbar extends Component<Props> {
<md-bold className="input__toolbar-item" title={boldLabel} aria-label={boldLabel}>
<BoldIcon />
</md-bold>
<md-italic className="input__toolbar-item" title={italicLabel} aria-label={italicLabel}>
<ItalicIcon />
</md-italic>
</div>
</markdown-toolbar>
);