inline-tools: prevent default behaviour on clicks to prevent form submitting (#454)

* fix inline-tool buttons

* prevent default on inline-tool clicks

* update

* update version from package json

* update version and use badgen in README

* upd
This commit is contained in:
Murod Khaydarov 2018-09-20 14:51:21 +03:00 committed by GitHub
parent cbe8fd2965
commit bdae8d3fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 28 deletions

View file

@ -1,6 +1,6 @@
<p align="center"><img src="https://capella.pics/3c0b525b-50d9-4720-8aad-9148114cfa6e.jpg"></p> <p align="center"><img src="https://capella.pics/3c0b525b-50d9-4720-8aad-9148114cfa6e.jpg"></p>
![](https://flat.badgen.net/badge/CodeX%20Editor/v2.0.10/blue?icon=npm) [![](https://flat.badgen.net/npm/v/codex.editor?icon=npm)](https://www.npmjs.com/package/codex.editor)
## Version 2.0-beta is here! ## Version 2.0-beta is here!

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "codex.editor", "name": "codex.editor",
"version": "2.0.10", "version": "2.0.12",
"description": "Codex Editor. Native JS, based on API and Open Source", "description": "Codex Editor. Native JS, based on API and Open Source",
"main": "build/codex-editor.js", "main": "build/codex-editor.js",
"scripts": { "scripts": {

View file

@ -44,6 +44,7 @@ export default class BoldInlineTool implements InlineTool {
*/ */
public render(): HTMLElement { public render(): HTMLElement {
this.nodes.button = document.createElement('button'); this.nodes.button = document.createElement('button');
this.nodes.button.type = 'button';
this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier); this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier);
this.nodes.button.appendChild($.svg('bold', 13, 15)); this.nodes.button.appendChild($.svg('bold', 13, 15));
return this.nodes.button; return this.nodes.button;

View file

@ -43,6 +43,7 @@ export default class ItalicInlineTool implements InlineTool {
*/ */
public render(): HTMLElement { public render(): HTMLElement {
this.nodes.button = document.createElement('button'); this.nodes.button = document.createElement('button');
this.nodes.button.type = 'button';
this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier); this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier);
this.nodes.button.appendChild($.svg('italic', 6, 15)); this.nodes.button.appendChild($.svg('italic', 6, 15));
return this.nodes.button; return this.nodes.button;

View file

@ -71,6 +71,7 @@ export default class LinkInlineTool implements InlineTool {
*/ */
public render(): HTMLElement { public render(): HTMLElement {
this.nodes.button = document.createElement('button'); this.nodes.button = document.createElement('button');
this.nodes.button.type = 'button';
this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier); this.nodes.button.classList.add(this.CSS.button, this.CSS.buttonModifier);
this.nodes.button.appendChild($.svg('link', 15, 14)); this.nodes.button.appendChild($.svg('link', 15, 14));
this.nodes.button.appendChild($.svg('unlink', 16, 18)); this.nodes.button.appendChild($.svg('unlink', 16, 18));

View file

@ -304,8 +304,9 @@ export default class InlineToolbar extends Module {
this.nodes.actions.appendChild(actions); this.nodes.actions.appendChild(actions);
} }
this.Editor.Listeners.on(button, 'click', () => { this.Editor.Listeners.on(button, 'click', (event) => {
this.toolClicked(tool); this.toolClicked(tool);
event.preventDefault();
}); });
/** /**