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

Toolbar button for inserting a horizontal rule #1378

Open
papandreou opened this issue May 24, 2018 · 7 comments
Open

Toolbar button for inserting a horizontal rule #1378

papandreou opened this issue May 24, 2018 · 7 comments

Comments

@papandreou
Copy link
Contributor

papandreou commented May 24, 2018

- Do you want to request a feature or report a bug?

feature

- What is the current behavior?

There is no way to add a horizontal rule (---) using the markdown widget in rich text mode, except by implementing it as a custom editor widget. I would like to have that so I can use it as a structural divider for some content that I'm managing via netlify-cms.

The editor does have good support for the horizontal rule as soon as it's there, though. It's rendered as a horizontal line that goes all the way across the editor, and it compiles to an <hr> element.

- What is the expected behavior?

That there is a toolbar button with an "—" icon or similar that inserts a --- on an empty line into the markdown.

It seems like slate.js does not have this built in, but we could probably upstream that.

@erquhart
Copy link
Contributor

Agreed. Related to #1324.

@PaulEibensteiner
Copy link

Hi, agreed too.
(did you build the custom editor widget, and if yes, could you provide the code? thx in advance)

@papandreou
Copy link
Contributor Author

@PaulEibensteiner, sure. I'm not too proud of it:

CMS.registerEditorComponent({
  id: 'separator',
  label: '---',
  // A bogus field so that the component doesn't look weird when rendered:
  fields: [{ label: 'Separator', widget: 'select', options: ['---'], default: '---' }],
  // Never match anything so that the separator will be recognized as a horizontal rule when the document is reloaded:
  pattern: /.^/,
  toBlock(obj) {
    return '---';
  },
  toPreview(obj) {
    return '<hr>';
  }
});

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Oct 29, 2019
@Lester016
Copy link

is this still not available? I'm looking for this kind of feature.

@jboolean
Copy link

Would love to see this. It seems to recognize thematic breaks, but can't create them.

@erezrokah
Copy link
Contributor

We would happily accept a contribution for this

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

No branches or pull requests

8 participants