Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icon for the block and the format type #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dist/mathml-block.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { SVG, Path } = wp.primitives;

export default (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M 5 19.355 L 12.755 12.209 L 5.157 4.464 L 5.157 4 L 18.28 4 L 18.28 8.405 L 17.821 8.405 C 17.701 7.046 17.275 6.125 16.543 5.642 C 15.773 5.181 14.754 4.959 13.484 4.974 L 8.553 4.974 L 14.772 11.677 L 8.115 17.769 L 16.498 17.769 C 17.111 17.754 17.507 17.501 17.686 17.011 C 17.843 16.543 17.921 16.041 17.921 15.505 L 18.381 15.505 L 18.381 20 L 5 20 L 5 19.355 Z" />
</SVG>
);
3 changes: 2 additions & 1 deletion src/mathml-block.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { v4 as uuid } from 'uuid';
import icon from './icon';

const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
Expand All @@ -11,7 +12,7 @@ const renderMathML = ( id ) => {

registerBlockType( 'mathml/mathmlblock', {
title: 'MathML',
icon: 'list-view',
icon,
category: 'common',
attributes: {
formula: {
Expand Down
2 changes: 2 additions & 0 deletions src/mathml-inline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import icon from './icon';
const { createElement, Fragment } = window.wp.element;
const { registerFormatType, toggleFormat } = window.wp.richText;
const { RichTextToolbarButton, RichTextShortcut } = window.wp.blockEditor;
Expand Down Expand Up @@ -34,6 +35,7 @@ import './mathml-block.css';
} ),
createElement( RichTextToolbarButton, {
title,
icon,
onClick: onToggle,
isActive,
shortcutType: 'primary',
Expand Down