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

Export HeadingID function to JavaScript #362

Closed
88250 opened this issue May 5, 2020 · 6 comments
Closed

Export HeadingID function to JavaScript #362

88250 opened this issue May 5, 2020 · 6 comments
Assignees
Milestone

Comments

@88250
Copy link
Collaborator

88250 commented May 5, 2020

@88250 One last thing, How can I get the text of HeadingID at javascript.

Originally posted by @jakekwak in #350 (comment)

@88250 88250 added this to the 3.1.0 milestone May 5, 2020
@88250 88250 self-assigned this May 5, 2020
@jakekwak
Copy link
Contributor

jakekwak commented May 5, 2020

How about passing the template string in custom rendering and processing it?
I think I don't need the this option. It can not solve the problem. (The Scalability)

@88250
Copy link
Collaborator Author

88250 commented May 5, 2020

I am not sure what do you want 😂

@jakekwak
Copy link
Contributor

jakekwak commented May 5, 2020

I am suggesting new custom rendering for scalibilty.
if not, I will modify the lute after learning the Go.

@88250 88250 removed the 改进功能 label May 5, 2020
@88250 88250 removed this from the 3.1.0 milestone May 5, 2020
@88250
Copy link
Collaborator Author

88250 commented May 5, 2020

Could you give me an example? I think the current design of the renderer extension is good enough.

@Vanessa219
Copy link
Owner

Vanessa219 commented May 5, 2020

I think you can provide getId method

renderers: {
        renderHeading: (node, entering) => {
          if (entering) {
            const id = Lute.GetHeadingID(node)
            return [`<h${node.__internal_object__.HeadingLevel} id="${id}" class="vditor__heading">
<a id="vditorAnchor-${id}" class="vditor-anchor" href="#${id}"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>
<span class="prefix"></span><span>`,
              Lute.WalkContinue]
          } else {
            return [`</span></h${node.__internal_object__.HeadingLevel}>`, Lute.WalkContinue]
          }
        },
      }

@jakekwak
Copy link
Contributor

jakekwak commented May 5, 2020

I think that one is good. Thanks.

@88250 88250 added this to the 3.1.0 milestone May 5, 2020
Vanessa219 added a commit that referenced this issue May 5, 2020
88250 added a commit to 88250/lute that referenced this issue May 5, 2020
Export HeadingID function to JavaScript
Fix Vanessa219/vditor#362
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

3 participants