Skip to content

Customize the text selection floating toolbar ​

Customizing the floating toolbar takes two steps: create a custom controller for the tool logic, then add or edit the tool in fragments.

Example: custom controller and fragment configuration ​

Sample code is in /examples/UIExtension/custom-text-selection-tool.

Logic helpers used by the floating toolbar ​

When customizing the toolbar, you will often add a controller. A typical pattern:

js
var tooltipLayer = this.component.getClosestComponentByType('tooltip-layer');
var textSelectionTool = tooltipLayer.getCurrentSelectionTool();
textSelectionTool.getSelectionInfo().then((selectionInfo) => {
});
textSelectionTool.pageRender /The current rendering page object
  • getClosestComponentByType() returns the matching tooltip layer.

  • getCurrentSelectionTool() returns the text selection tool.

  • getSelectionInfo() returns the selected text and the current page render object. The selection info includes:

  • page — PDF page object

  • text — selected text

  • rectArray — text blocks (unit: point)

Floating toolbar component names ​

Component nameDescription
fv--text-selection-tooltipFloating toolbar layer
fv--text-selection-tooltip-copyCopy tool
fv--text-selection-tooltip-create-highlightHighlight tool
fv--text-selection-tooltip-create-strikeoutStrikeout tool
fv--text-selection-tooltip-create-underlineUnderline tool