I am creating a book page with a block of table of contents on the top of the page, when people click on the table of contents ( block ) on the top of the page .  it will jump to the right section ( another block )which showing at the bottom of the page. please suggest how to create the  Anchor Link on the page, Thanks

Comments

If you are using TinyMCE then you can build a profile that includes this button:

I am using the default ckeditor, is there a way I can create the  Anchor Link ? Thanks

Switch to source

Add  id="anchor-link-name"  to whichever element you want it to be associated with.

Save or switch back, continue editing and save.

 

 

thanks, I added this into the html "<div id="anchor-link-name"> ...</div>
but the code gone after I save the block, seems ckeditor doesn't support this ?

Doesn't look like it out of the box, but if you add <div> to the list of Allowed HTML tags then it does work.

You can also add inside heading tags and paragraph tags or any other allowed tags.

I have added the <div> to the list of Allowed HTML tags . but still no luck, the <div> tag gone after I save the block, not sure what's the problem.

That's odd, it worked when I did it. Did you save the Text Format after adding. And you are using that text format in the editor for that content?

This was it in the Edit source

This is it in Inspect element on the saved page.

By the way, you have a lot of questions so why not come to Backdrop Live next week.  If there's a topic you want you can mention on the registration form. There is a link to register near the top of your original post.

I haven't used this module, but I assume it would solve the problem:

CKEditor Anchor Link

https://backdropcms.org/project/anchor_link

But there seems to be an unresolved issue with this module:

https://github.com/backdrop-contrib/anchor_link/issues

I personally prefer working with BUEditor and Full HTML text format. This gives complete freedom in formatting content, but requires at least basic knowledge of HTML.

https://backdropcms.org/project/bueditor

 

Given when that module was released, I think it is probably for CKEditor4 rather than CKEditor5.

Of course, I just didn't consider it, sorry.

It is not easier to create a Custom block, place HTML (use 'Raw html' format) and place on the desired page (pages) in a particular region. It will be a static element independent of content. Another option - use jQuery, attaching HTML to a specific element. And to use Ckeditor for this is very strange.