* Open Block Settings pane * * @param targetBlock - near which Block we should open BlockSettings
(targetBlock: Block = this.Editor.BlockManager.currentBlock)
| 119 | * @param targetBlock - near which Block we should open BlockSettings |
| 120 | */ |
| 121 | public async open(targetBlock: Block = this.Editor.BlockManager.currentBlock): Promise<void> { |
| 122 | this.opened = true; |
| 123 | |
| 124 | /** |
| 125 | * If block settings contains any inputs, focus will be set there, |
| 126 | * so we need to save current selection to restore it after block settings is closed |
| 127 | */ |
| 128 | this.selection.save(); |
| 129 | |
| 130 | /** |
| 131 | * Highlight content of a Block we are working with |
| 132 | */ |
| 133 | this.Editor.BlockSelection.selectBlock(targetBlock); |
| 134 | this.Editor.BlockSelection.clearCache(); |
| 135 | |
| 136 | /** Get tool's settings data */ |
| 137 | const { toolTunes, commonTunes } = targetBlock.getTunes(); |
| 138 | |
| 139 | /** Tell to subscribers that block settings is opened */ |
| 140 | this.eventsDispatcher.emit(this.events.opened); |
| 141 | |
| 142 | const PopoverClass = isMobileScreen() ? PopoverMobile : PopoverDesktop; |
| 143 | |
| 144 | this.popover = new PopoverClass({ |
| 145 | searchable: true, |
| 146 | items: await this.getTunesItems(targetBlock, commonTunes, toolTunes), |
| 147 | scopeElement: this.Editor.API.methods.ui.nodes.redactor, |
| 148 | messages: { |
| 149 | nothingFound: I18n.ui(I18nInternalNS.ui.popover, 'Nothing found'), |
| 150 | search: I18n.ui(I18nInternalNS.ui.popover, 'Filter'), |
| 151 | }, |
| 152 | }); |
| 153 | |
| 154 | this.popover.on(PopoverEvent.Closed, this.onPopoverClose); |
| 155 | |
| 156 | this.nodes.wrapper?.append(this.popover.getElement()); |
| 157 | |
| 158 | this.popover.show(); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Returns root block settings element |
nothing calls this directly
no test coverage detected