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

❓ How to change tool order? #2040

Open
AlbinoGeek opened this issue Apr 30, 2022 · 8 comments
Open

❓ How to change tool order? #2040

AlbinoGeek opened this issue Apr 30, 2022 · 8 comments

Comments

@AlbinoGeek
Copy link

AlbinoGeek commented Apr 30, 2022

Question

How do I change the order of tools?

Context

For some reason, every tool is listed AFTER "Text" EXCEPT "Link".

So, there clearly is some way to change the order of tools.

But it's not documented in the Tool Options:

https://editorjs.io/getting-started#available-tools-options

What I've tried

  1. Changing the order of tools as defined does not effect the rendered order.
  2. Changing the name of the tools does not effect the order (it's not alphabetical.)
@neSpecc
Copy link
Member

neSpecc commented May 1, 2022

Please, add more details. Are you talking about Block Tools or Inline Tools? Or Block Tunes? Maybe your configuration and some screenshots will help

@neSpecc neSpecc removed the discussion label May 1, 2022
@AlbinoGeek
Copy link
Author

Please, add more details. Are you talking about Block Tools or Inline Tools? Or Block Tunes? Maybe your configuration and some screenshots will help

Porque no los dos? (meme that poorly translates to "why not both?")

But yes, let's start with Block Tunes.

image

It's "sort of alphabetical but not really, because Link is always first and followed by Text."

Here's my tool configuration:

      {
        header: {
          class:         Header,
          inlineToolbar: ['link'],
          tunes:         ['alignmentTune']
        },
        paragraph: {
          class:         Paragraph,
          inlineToolbar: true,
          tunes:         ['alignmentTune']
        },
        list: {
          class:         NestedChecklist,
          inlineToolbar: true,
          tunes:         ['alignmentTune']
        },
        link: {
          class:  LinkTool,
          tunes:  ['alignmentTune'],
          config: {
            endpoint: '/api/fetchUrl',
          }
        },
        image: {
          class:         Image,
          inlineToolbar: ['link'],
          tunes:         ['alignmentTune']
        },
        embed: {
          class:         Embed,
          inlineToolbar: true
        },
        table: {
          class:  Table,
          config: {
            rows: 2,
            cols: 3,
          },
          inlineToolbar: true
        },
        alignmentTune: {
          class:  AlignmentTuneTool,
          config: {
            blocks: {
              header: 'center',
              image:  'center',
            }
          },
        }
      }

@theleonwei
Copy link

theleonwei commented Jan 18, 2023

Any update on this?

@CKylinMC
Copy link

I have the same problem.

@tskalczynski
Copy link

Use (array-map ...) instead of a normal map { ... } to define tools:

It respects the order :).

...
			:tools (array-map
				:paragraph {
				      :class 			js/Paragraph
				      :inlineToolbar 	true
				      :tunes 			["blocktune" "textVariant"]
				}
                                ...
                                )

@AlbinoGeek
Copy link
Author

Use (array-map ...) instead of a normal map { ... } to define tools:

It respects the order :).

...
			:tools (array-map
				:paragraph {
				      :class 			js/Paragraph
				      :inlineToolbar 	true
				      :tunes 			["blocktune" "textVariant"]
				}
                                ...
                                )

That's... not Javascript, how would someone even go about using that?

@tskalczynski
Copy link

Ooops, you are right. I'm doing this in Clojurescript. There, it works perfectly with (array-map ...).

@tskalczynski
Copy link

Maybe you can use a Map() instead of a simple JS object?

Instead of:

{
        header: {
          class:         Header,
          inlineToolbar: ['link'],
          tunes:         ['alignmentTune']
        },
        paragraph: {
          class:         Paragraph,
          inlineToolbar: true,
          tunes:         ['alignmentTune']
        },
...

something like this:

new Map(
  [
        [ 'header', {
          class:         Header,
          inlineToolbar: ['link'],
          tunes:         ['alignmentTune']
        }],
        [ 'paragraph', {
          class:         Paragraph,
          inlineToolbar: true,
          tunes:         ['alignmentTune']
        } ],
...
  ])

Here they say Map() keeps the keys order:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

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

5 participants