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

Link Inline Tool #264

Merged
merged 6 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
537 changes: 504 additions & 33 deletions build/codex-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/codex-editor.js.map

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions build/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions docs/tools-inline.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Inline Tool should implement next methods
- `surround()` — works with selected range
- `checkState()` — get Tool's activated state by selected range

Also, you can provide optional methods

- `renderActions()` — create additional element below the buttons
- `clear()` — clear Tool's stuff on opening/closing of Inline Toolbar
- `shortcut()` — shortcut that handles Tool

### render()

Method that returns button to append at the Inline Toolbar
Expand Down Expand Up @@ -55,3 +61,32 @@ selection | Selection | current Selection |
type | description |
-- | -- |
`Boolean` | `true` if Tool is active, otherwise `false` |

### renderActions()

Optional method that returns additional Element with actions.
For example, input for the 'link' tool or textarea for the 'comment' tool.
It will be places below the buttons list at Inline Toolbar.

#### Parameters

Method does not accept any parameters

#### Return value

type | description |
-- | -- |
`HTMLElement` | element that will be added to the Inline Toolbar |

### clear()

Optional method that will be called on opening/closing of Inline Toolbar.
Can contain logic for clearing Tool's stuff, such as inputs, states and other.

#### Parameters

Method does not accept any parameters

#### Return value

Method should not return a value.
File renamed without changes
3 changes: 3 additions & 0 deletions src/assets/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icon-plus.svg → src/assets/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/unlink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 14 additions & 13 deletions src/components/block-tunes/block-tune-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,24 @@ export default class DeleteTune implements IBlockTune {
*/
private needConfirmation: boolean;

/**
* set false confirmation state
*/
private resetConfirmation: () => void;

/**
* DeleteTune constructor
*
* @param {Object} api
*/
public constructor({api}) {
constructor({api}) {
this.api = api;

this.resetConfirmation = () => {
this.setConfirmation(false);
};
}

/**
* change tune state
*/
private setConfirmation(state): void {
this.needConfirmation = state;
}

/**
* set false confirmation state
*/
private resetConfirmation: () => void;

/**
* Create "Delete" button and add click event listener
* @returns [Element}
Expand Down Expand Up @@ -95,4 +88,12 @@ export default class DeleteTune implements IBlockTune {
this.api.blocks.delete();
}
}

/**
* change tune state
*/
private setConfirmation(state): void {
this.needConfirmation = state;
}

}
4 changes: 2 additions & 2 deletions src/components/inline-tools/inline-tool-bold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class BoldInlineTool implements InlineTool {
button: null,
};

constructor() {
constructor(api) {
console.log('Bold Inline Tool is ready');
}

Expand All @@ -42,7 +42,7 @@ export default class BoldInlineTool implements InlineTool {
public render(): HTMLElement {
this.nodes.button = document.createElement('button');
this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier);
this.nodes.button.appendChild($.svg('icon-bold', 13, 15));
this.nodes.button.appendChild($.svg('bold', 13, 15));
return this.nodes.button;
}

Expand Down
Loading