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

Redesigned Toolbar Custom Definition API #388

Open
jaywcjlove opened this issue May 21, 2022 · 3 comments
Open

Redesigned Toolbar Custom Definition API #388

jaywcjlove opened this issue May 21, 2022 · 3 comments

Comments

@jaywcjlove
Copy link
Member

There is no good way to define icon size.
Because there needs to be an easier way to define toolbars. Unless we redesign the toolbar definition API.

Similar to the API design below:

<MDEditor.Markdown 
  source="...."
  commands={
    <Command>
      <Title3 />
      <CommandGroup>
        <Title1 />
        <Title2 />
        <Title3 width="12" height="12" buttonProps={{ 'aria-label': 'Insert title'}} />
      </CommandGroup>
    </Command>
  }
/>

This one has more work and can be considered for expansion in the next version. The only solution so far is as follows:

const title1: ICommand = {
  ...commands.title1,
  icon: (
    <svg width="23" height="23" viewBox="0 0 520 520">
      <path fill="currentColor" d="M15.708333..." />
    </svg>
  ),
};

@jeepers3327

Originally posted by @jaywcjlove in #387 (comment)

@jaywcjlove
Copy link
Member Author

Ideas for the next version

import React from "react";
import MDEditor, { Command, Title3 } from '@uiw/react-md-editor';

export default function App() {
  const [value, setValue] = React.useState("**Hello world!!!**");
  return (
    <div className="container">
      <MDEditor value={value} onChange={setValue}>
        <Command>
          <Title3 name="title3" keyCommand="title3" />
          <Command>
            <Title1 />
            <Title2 />
            <Title3 name="title3" keyCommand="title3" width="12" height="12" buttonProps={{ 'aria-label': 'Insert title'}}>
              <Icon />
            </Title3>
          </Command>
        </Command>
      </MDEditor>

      <MDEditor.Markdown source={value} style={{ whiteSpace: 'pre-wrap' }} />
    </div>
  );
}

@am0029
Copy link

am0029 commented May 27, 2023

hello , this codes is for make bold work for persian language ?
i mean like this picture .
picture is look like this
333

bold B option in toolbar not working in my language .

u mean i add all of this code to make this works for me right ?

i add new toolbar ? and name it B ?

@jaywcjlove
Copy link
Member Author

@am0029 add new toolbar, can remove Blod

export {
title,
title1,
title2,
title3,
title4,
title5,
title6,
bold,
codeBlock,
comment,
italic,
strikethrough,
hr,
group,
divider,
link,
quote,
code,
image,
unorderedListCommand,
orderedListCommand,
checkedListCommand,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants