Skip to content

Commit

Permalink
Link Inline Tool (#264)
Browse files Browse the repository at this point in the history
* Link Inline Tool

* api injected

* text improved

* Clear input on the reselection

* little improvements
  • Loading branch information
neSpecc authored Jun 25, 2018
1 parent 60eda57 commit c665677
Show file tree
Hide file tree
Showing 19 changed files with 1,080 additions and 92 deletions.
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

0 comments on commit c665677

Please sign in to comment.