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

[Feature Request] Add GitHub-flavored Markdown function "collapsible section" to editor #67

Open
schlagmichdoch opened this issue Dec 12, 2021 · 1 comment

Comments

@schlagmichdoch
Copy link

As Wikipages can be quite long and messy, it would be great to have a possibility to collapse some longer text or section.
Wikipages would seem tidied up.

This would e.g. help create a FAQ and a accordion like funcionality

Fantastically, this feature is implemented right here in GitHub by extending Markup to GitHub-flavored Markup (more Information here):

This is collapsible section

This is hidden and can be a very long paragraph

This is bold

This is a header

This is hidden and can be a very long paragraph


I have found your discussion and decission not to implement html tags in the editor: here, here and your overview page here

I think those github-flavored markdown functions would be worth it. As I understood your stand point, wiki is mainly about uniformity and tidyness. I personally think these traits would rather be enhanced by including collapsible sections.

Other benefits:

  • Every GitHub user knows how to use them
  • standard html tag makes it already usable by every browser.
  • Collapsible sections are even easier to implement than e.g. Todo Lists, which are part of github-flavored markdown as well.

Implementation:
I think we just needed to add a new schema to prosemirror similar to that of the <hr> tag.

ProseMirrors Website gives some useful examples.

By playing around with this example, I could verify the possibility to add a details tag:

In the referenced Glitch project: Just change line 16 to 27 from:

  toDOM: node => ["img", {"dino-type": node.attrs.type,
                          src: "/img/dino/" + node.attrs.type + ".png",
                          title: node.attrs.type,
                          class: "dinosaur"}],
  // When parsing, such an image, if its type matches one of the known
  // types, is converted to a dino node.
  parseDOM: [{
    tag: "img[dino-type]",
    getAttrs: dom => {
      let type = dom.getAttribute("dino-type")
      return dinos.indexOf(type) > -1 ? {type} : false
    }
  }]

to:

  toDOM: node => ["details", "this is a content is hidden"],
  // When parsing, such an image, if its type matches one of the known
  // types, is converted to a dino node.
  parseDOM: [{
    tag: "details",
  }]

Afterwards try it out by clicking on insert and any of the dinosaurs.


If this sounds promising to you too, I'd love to help implementing this quickly.

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

2 participants