Skip to content

Commit 94232ea

Browse files
committed
Cleanup
1 parent 1a1120a commit 94232ea

File tree

6 files changed

+248
-1388
lines changed

6 files changed

+248
-1388
lines changed

src/components/inline-tools/inline-tool-link.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,37 +128,19 @@ export default class LinkInlineTool implements InlineTool {
128128
return this.nodes.button;
129129
}
130130

131-
// /**
132-
// * Create button for Inline Toolbar
133-
// */
134-
// public render(): any {
135-
// return {
136-
// icon: IconLink,
137-
// title: 'Link',
138-
// onActivate: () => {
139-
// // this.surround(this.selection.get());
140-
// },
141-
// };
142-
// }
143-
144131
/**
145132
* Input for the link
146133
*/
147134
public renderActions(): HTMLElement {
148135
this.nodes.input = document.createElement('input') as HTMLInputElement;
149136
this.nodes.input.placeholder = this.i18n.t('Add a link');
150137
this.nodes.input.classList.add(this.CSS.input);
151-
// this.nodes.input.classList.add(this.CSS.inputShowed);
152138
this.nodes.input.addEventListener('keydown', (event: KeyboardEvent) => {
153139
if (event.keyCode === this.ENTER_KEY) {
154140
this.enterPressed(event);
155141
}
156142
});
157143

158-
// setTimeout(() => {
159-
// this.nodes.input.focus();
160-
// }, 1000);
161-
162144
return this.nodes.input;
163145
}
164146

@@ -168,8 +150,6 @@ export default class LinkInlineTool implements InlineTool {
168150
* @param {Range} range - range to wrap with link
169151
*/
170152
public surround(range: Range): void {
171-
debugger;
172-
console.log('surround');
173153
/**
174154
* Range will be null when user makes second click on the 'link icon' to close opened input
175155
*/
@@ -251,7 +231,6 @@ export default class LinkInlineTool implements InlineTool {
251231
* Show/close link input
252232
*/
253233
private toggleActions(): void {
254-
debugger;
255234
if (!this.inputOpened) {
256235
this.openActions(true);
257236
} else {

src/components/modules/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ import UiAPI from './api/ui';
1818

1919
/** ./toolbar */
2020
import BlockSettings from './toolbar/blockSettings';
21-
import ConversionToolbar from './toolbar/conversion';
2221
import Toolbar from './toolbar/index';
23-
// import InlineToolbar from './toolbar/inline';
24-
import InlineToolbar from './toolbar/inline2';
22+
import InlineToolbar from './toolbar/inline';
2523

2624
/** . */
2725
import BlockEvents from './blockEvents';
@@ -60,7 +58,6 @@ export default {
6058

6159
// Toolbar Modules
6260
BlockSettings,
63-
ConversionToolbar,
6461
Toolbar,
6562
InlineToolbar,
6663

src/components/modules/toolbar/blockSettings.ts

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import { I18nInternalNS } from '../../i18n/namespace-internal';
77
import Flipper from '../../flipper';
88
import { TunesMenuConfigItem } from '../../../../types/tools';
99
import { resolveAliases } from '../../utils/resolve-aliases';
10-
import { type Popover, PopoverDesktop, PopoverMobile, PopoverItemParams, PopoverItemDefaultParams, PopoverItemType } from '../../utils/popover';
10+
import { type Popover, PopoverDesktop, PopoverMobile, PopoverItemParams, PopoverItemType } from '../../utils/popover';
1111
import { PopoverEvent } from '../../utils/popover/popover.types';
1212
import { isMobileScreen } from '../../utils';
1313
import { EditorMobileLayoutToggled } from '../../events';
14-
import * as _ from '../../utils';
1514
import { IconReplace } from '@codexteam/icons';
16-
import { getConvertToItems, isSameBlockData } from '../../utils/blocks';
15+
import { getConvertToItems } from '../../utils/blocks';
1716

1817
/**
1918
* HTML Elements that used for BlockSettings
@@ -234,77 +233,6 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
234233
return items.map(tune => this.resolveTuneAliases(tune));
235234
}
236235

237-
/**
238-
* Returns list of all available conversion menu items
239-
*
240-
* @param currentBlock - block we are about to open block tunes for
241-
*/
242-
private async getConvertToItems(currentBlock: Block): Promise<PopoverItemDefaultParams[]> {
243-
const conversionEntries = Array.from(this.Editor.Tools.blockTools.entries());
244-
245-
const resultItems: PopoverItemDefaultParams[] = [];
246-
247-
const blockData = await currentBlock.data;
248-
249-
conversionEntries.forEach(([toolName, tool]) => {
250-
const conversionConfig = tool.conversionConfig;
251-
252-
/**
253-
* Skip tools without «import» rule specified
254-
*/
255-
if (!conversionConfig || !conversionConfig.import) {
256-
return;
257-
}
258-
259-
tool.toolbox?.forEach((toolboxItem) => {
260-
/**
261-
* Skip tools that don't pass 'toolbox' property
262-
*/
263-
if (_.isEmpty(toolboxItem) || !toolboxItem.icon) {
264-
return;
265-
}
266-
267-
let shouldSkip = false;
268-
269-
if (toolboxItem.data !== undefined) {
270-
/**
271-
* When a tool has several toolbox entries, we need to make sure we do not add
272-
* toolbox item with the same data to the resulting array. This helps exclude duplicates
273-
*/
274-
const hasSameData = isSameBlockData(toolboxItem.data, blockData);
275-
276-
shouldSkip = hasSameData;
277-
} else {
278-
shouldSkip = toolName === currentBlock.name;
279-
}
280-
281-
282-
if (shouldSkip) {
283-
return;
284-
}
285-
286-
resultItems.push({
287-
icon: toolboxItem.icon,
288-
title: toolboxItem.title,
289-
name: toolName,
290-
onActivate: async () => {
291-
const { BlockManager, BlockSelection, Caret } = this.Editor;
292-
293-
const newBlock = await BlockManager.convert(this.Editor.BlockManager.currentBlock, toolName, toolboxItem.data);
294-
295-
BlockSelection.clearSelection();
296-
297-
this.close();
298-
299-
Caret.setToBlock(newBlock, Caret.positions.END);
300-
},
301-
});
302-
});
303-
});
304-
305-
return resultItems;
306-
}
307-
308236
/**
309237
* Handles popover close event
310238
*/

0 commit comments

Comments
 (0)