MCPcopy
hub / github.com/codex-team/editor.js / open

Method open

src/components/modules/toolbar/blockSettings.ts:121–159  ·  view source on GitHub ↗

* Open Block Settings pane * * @param targetBlock - near which Block we should open BlockSettings

(targetBlock: Block = this.Editor.BlockManager.currentBlock)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 12

getTunesItemsMethod · 0.95
isMobileScreenFunction · 0.90
selectBlockMethod · 0.80
clearCacheMethod · 0.80
getTunesMethod · 0.80
uiMethod · 0.80
appendMethod · 0.80
saveMethod · 0.65
emitMethod · 0.65
onMethod · 0.65
getElementMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected