Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show TextAngular toolbar only when editor is in focus for multiple editors with 1 toolbar

I have multiple editors with one toolbar. Initially I have just one editor and add say second and third based on the click of a button in the toolbar. The toolbar is on the top of the 1st editor and the subsequent editors that gets added are stacked one below the other.

The problems I have are:

  1. How do I show the toolbar when any of the editor is in focus?

  2. How do I move the toolbar on top of the editor in focus?

like image 528
Naveen Avatar asked Dec 05 '25 12:12

Naveen


2 Answers

To fix problem 1, add some custom CSS Like this:

.ta-toolbar{
  display: none;
}
.ta-toolbar.focussed{
  display: block;
}

The focussed class is added to the toolbar when any of it's linked editors are focussed into.

To fix problem 2 is probably a little more tricky and will require some extra work. The steps are:

  1. Watch for a focus on any of the editors.
  2. When this happens, change the position of the toolbar to relative to the current editor - at this point both will have the focussed class (use absolute positioning probably).
like image 169
Simeon Cheeseman Avatar answered Dec 07 '25 03:12

Simeon Cheeseman


If someone needs an example for a simpler scenario. To put the toolbar somewhere else one can use something like:

<div text-angular-toolbar class="toolbar" name="toolbar" ta-toolbar="[['h1', 'h2', 'p', 'pre', 'quote', 'bold', 'italics', 'underline', 'ul', 'ol', 'justifyLeft', 'justifyCenter', 'justifyRight', 'indent', 'outdent', 'insertImage']]"></div>
<div style="overflow: auto; width: 100%; height: 100%; max-width: 700px; max-height: 750px; background-color: #FFFFFF;">
    <div text-angular ta-target-toolbars="toolbar" ng-model="htmlContent"></div>
</div>

Perhaps for someone this comes in handy.

like image 34
timtos Avatar answered Dec 07 '25 03:12

timtos