Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#665 API to open and close inline-toolbar #711

Merged
merged 13 commits into from
Apr 11, 2019
1 change: 1 addition & 0 deletions src/components/modules/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class API extends Module {
selection: this.Editor.SelectionAPI.methods,
styles: this.Editor.StylesAPI.classes,
toolbar: this.Editor.ToolbarAPI.methods,
inlineToolbar: this.Editor.InlineToolbarAPI.methods,
} as APIInterfaces;
}
}
34 changes: 34 additions & 0 deletions src/components/modules/api/inline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Module from '../../__module';
import { InlineToolbar } from '../../../../types/api/inline';

/**
* @class InlineToolbarAPI
* provides with methods working with InlineToolbar
*/
export default class InlineToolbarAPI extends Module {
/**
* Available methods
* @return {InlineToolbar}
*/
get methods(): InlineToolbar {
return {
close: () => this.close(),
open: () => this.open(),
};
}

/**
* Open inlineToolbar
*/
public open(): void {
this.Editor.InlineToolbar.open();
}

/**
* Close inlineToolbar
*/
public close(): void {
this.Editor.InlineToolbar.close();
}

}
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class InlineToolbar extends Module {
/**
* Shows Inline Toolbar
*/
private open(): void {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neSpecc This file is also named inline.ts. Should we rename this as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's included at the /toolbar/ directory, so this is a redundant addition

public open(): void {
/**
* Filter inline-tools and show only allowed by Block's Tool
*/
Expand Down
2 changes: 2 additions & 0 deletions src/types-internal/editor-modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import SaverAPI from '../components/modules/api/saver';
import Saver from '../components/modules/saver';
import BlockSelection from '../components/modules/blockSelection';
import RectangleSelection from '../components/modules/RectangleSelection';
import InlineToolbarAPI from '../components/modules/api/inline';

export interface EditorModules {
UI: UI;
Expand Down Expand Up @@ -63,5 +64,6 @@ export interface EditorModules {
SelectionAPI: SelectionAPI;
StylesAPI: StylesAPI;
ToolbarAPI: ToolbarAPI;
InlineToolbarAPI: InlineToolbarAPI;
NotifierAPI: NotifierAPI;
}
1 change: 1 addition & 0 deletions types/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './styles';
export * from './caret';
export * from './toolbar';
export * from './notifier';
export * from './inline'
tanmayv marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions types/api/inline.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Describes InlineToolbar API methods
*/
export interface InlineToolbar {
/**
* Closes InlineToolbar
*/
close(): void;

/**
* Opens InlineToolbar
*/
open(): void;
}

5 changes: 3 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import {EditorConfig} from './configs';
import {Blocks, Caret, Events, Listeners, Notifier, Sanitizer, Saver, Selection, Styles, Toolbar} from './api';
import {Blocks, Caret, Events, Listeners, Notifier, Sanitizer, Saver, Selection, Styles, Toolbar, InlineToolbar} from './api';

/**
* Interfaces used for development
Expand Down Expand Up @@ -51,6 +51,7 @@ export interface API {
selection: Selection;
styles: Styles;
toolbar: Toolbar;
inlineToolbar: InlineToolbar;
}

/**
Expand All @@ -70,7 +71,7 @@ declare class EditorJS {
public selection: Selection;
public styles: Styles;
public toolbar: Toolbar;

public inlineToolbar: InlineToolbar;
constructor(configuration?: EditorConfig|string);

public destroy(): void;
Expand Down