Issue #921πŸ’¬ AnsweredOpened March 2, 2018by dmmprog1 reactions

Select and focus an html element from a panel button

Quick answerby artf❀ 1

If for focus you mean scrolling the view to the component, unfortunately, there is no such a method, but you can actually implement it by relying on editor.Canvas.getBody().scrollTop

Read full answer below ↓

Question

Hi everyone, Is it possible to set focus in a section html with Grapes, like as an anchor? I have a panel button and it just select the section that I want but not focus to element. Here is the code: panel.addButton('options', [{ id: 'link', className: 'fa fa-th-list', command: function linkChap(e) { editor.DomComponents.getWrapper().find('section').forEach(model => { const current = model.getAttributes()['id'] || ''; if(current == "chap10"){ editor.select(model); //Here just select the section, but not set focus } }); } Thanks in advance. Regards.

Answers (3)

artfβ€’ March 4, 2018

If for focus you mean scrolling the view to the component, unfortunately, there is no such a method, but you can actually implement it by relying on editor.Canvas.getBody().scrollTop

Amir2828β€’ June 18, 2019

Did you manage to make it work?

lock[bot]β€’ June 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.