Skip to content

Commit 9602aa1

Browse files
committed
feat:0902
1 parent 8a68c66 commit 9602aa1

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

src/components/block/api.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Block from './index';
2-
import { BlockToolData, ToolConfig } from '../../../types/tools';
3-
import { SavedData } from '../../../types/data-formats';
4-
import { BlockAPI as BlockAPIInterface } from '../../../types/api';
2+
import {BlockToolData, ToolConfig} from '../../../types/tools';
3+
import {SavedData} from '../../../types/data-formats';
4+
import {BlockAPI as BlockAPIInterface} from '../../../types/api';
55

66
/**
77
* Constructs new BlockAPI object
@@ -100,11 +100,11 @@ function BlockAPI(
100100
*
101101
* @returns {Promise<void|SavedData>}
102102
*/
103-
save(): Promise<void|SavedData> {
103+
save(): Promise<void | SavedData> {
104104
return block.save();
105105
},
106106

107-
markdown(): string {
107+
markdown(): Promise<string> {
108108
return block.markdown();
109109
},
110110

src/components/block/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,11 @@ export default class Block extends EventsDispatcher<BlockEvents> {
620620
return isValid;
621621
}
622622

623-
public markdown(): string {
623+
public markdown(): Promise<string> {
624624
if (this.toolInstance.markdown instanceof Function) {
625625
return this.toolInstance.markdown();
626626
}
627-
return '';
627+
return null;
628628
}
629629

630630
/**

src/components/modules/toolbar/index.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import Module from '../../__module';
22
import $ from '../../dom';
33
import * as _ from '../../utils';
44
import I18n from '../../i18n';
5-
import { I18nInternalNS } from '../../i18n/namespace-internal';
5+
import {I18nInternalNS} from '../../i18n/namespace-internal';
66
import * as tooltip from '../../utils/tooltip';
7-
import { ModuleConfig } from '../../../types-internal/module-config';
7+
import {ModuleConfig} from '../../../types-internal/module-config';
88
import Block from '../../block';
9-
import Toolbox, { ToolboxEvent } from '../../ui/toolbox';
10-
import { IconMenu, IconPlus } from '@codexteam/icons';
11-
import { BlockHovered } from '../../events/BlockHovered';
9+
import Toolbox, {ToolboxEvent} from '../../ui/toolbox';
10+
import {IconMenu, IconPlus} from '@codexteam/icons';
11+
import {BlockHovered} from '../../events/BlockHovered';
1212

1313
/**
1414
* @todo Tab on non-empty block should open Block Settings of the hoveredBlock (not where caret is set)
@@ -39,6 +39,7 @@ interface ToolbarNodes {
3939
plusButton: HTMLElement;
4040
settingsToggler: HTMLElement;
4141
}
42+
4243
/**
4344
*
4445
* «Toolbar» is the node that moves up/down over current block
@@ -108,7 +109,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
108109
* @param moduleConfiguration.config - Editor's config
109110
* @param moduleConfiguration.eventsDispatcher - Editor's event dispatcher
110111
*/
111-
constructor({ config, eventsDispatcher }: ModuleConfig) {
112+
constructor({config, eventsDispatcher}: ModuleConfig) {
112113
super({
113114
config,
114115
eventsDispatcher,
@@ -155,7 +156,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
155156
open: () => void;
156157
toggle: () => void;
157158
hasFocus: () => boolean | undefined;
158-
} {
159+
} {
159160
return {
160161
opened: this.toolboxInstance?.opened,
161162
close: () => {
@@ -165,7 +166,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
165166
/**
166167
* If Toolbox is not initialized yet, do nothing
167168
*/
168-
if (this.toolboxInstance === null) {
169+
if (this.toolboxInstance === null) {
169170
_.log('toolbox.open() called before initialization is finished', 'warn');
170171

171172
return;
@@ -182,7 +183,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
182183
/**
183184
* If Toolbox is not initialized yet, do nothing
184185
*/
185-
if (this.toolboxInstance === null) {
186+
if (this.toolboxInstance === null) {
186187
_.log('toolbox.toggle() called before initialization is finished', 'warn');
187188

188189
return;
@@ -228,7 +229,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
228229
window.requestIdleCallback(() => {
229230
this.drawUI();
230231
this.enableModuleBindings();
231-
}, { timeout: 2000 });
232+
}, {timeout: 2000});
232233
} else {
233234
this.destroy();
234235
this.Editor.BlockSettings.destroy();
@@ -245,7 +246,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
245246
/**
246247
* Some UI elements creates inside requestIdleCallback, so the can be not ready yet
247248
*/
248-
if (this.toolboxInstance === null) {
249+
if (this.toolboxInstance === null) {
249250
_.log('Can\'t open Toolbar since Editor initialization is not finished yet', 'warn');
250251

251252
return;
@@ -272,7 +273,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
272273
this.hoveredBlock = block;
273274

274275
const targetBlockHolder = block.holder;
275-
const { isMobile } = this.Editor.UI;
276+
const {isMobile} = this.Editor.UI;
276277
const renderedContent = block.pluginsContent;
277278
const renderedContentStyle = window.getComputedStyle(renderedContent);
278279
const blockRenderedElementPaddingTop = parseInt(renderedContentStyle.paddingTop, 10);
@@ -390,9 +391,9 @@ export default class Toolbar extends Module<ToolbarNodes> {
390391
*/
391392
const tooltipContent = $.make('div');
392393

393-
tooltipContent.appendChild(document.createTextNode(I18n.ui(I18nInternalNS.ui.toolbar.toolbox, 'Add')));
394+
// tooltipContent.appendChild(document.createTextNode(I18n.ui(I18nInternalNS.ui.toolbar.toolbox, 'Add')));
394395
tooltipContent.appendChild($.make('div', this.CSS.plusButtonShortcut, {
395-
textContent: '⇥ Tab',
396+
textContent: _.beautifyShortcut('ctrl+/'),
396397
}));
397398

398399
tooltip.onHover(this.nodes.plusButton, tooltipContent, {
@@ -455,8 +456,8 @@ export default class Toolbar extends Module<ToolbarNodes> {
455456
this.Editor.UI.nodes.wrapper.classList.remove(this.CSS.openedToolboxHolderModifier);
456457
});
457458

458-
this.toolboxInstance.on(ToolboxEvent.BlockAdded, ({ block }) => {
459-
const { BlockManager, Caret } = this.Editor;
459+
this.toolboxInstance.on(ToolboxEvent.BlockAdded, ({block}) => {
460+
const {BlockManager, Caret} = this.Editor;
460461
const newBlock = BlockManager.getBlockById(block.id);
461462

462463
/**

types/api/block.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface BlockAPI {
5757
* @return {string}
5858
* @author asan
5959
*/
60-
markdown(): string;
60+
markdown(): Promise<string>;
6161

6262
/**
6363
* Save Block content

types/tools/block-tool.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface BlockTool extends BaseTool {
2424
*/
2525
save(block: HTMLElement): BlockToolData;
2626

27-
markdown?(): string;
27+
markdown?(): Promise<string>;
2828

2929
/**
3030
* Create Block's settings block

0 commit comments

Comments
 (0)