Add notification if URL is not valid (#548)

This commit is contained in:
George Berezhnoy 2018-12-06 09:42:30 +03:00 committed by GitHub
parent 71f8d76787
commit 3a9e4a814b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "2.7.2",
"version": "2.7.3",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "dist/codex-editor.js",
"types": "./types/index.d.ts",

View file

@ -3,7 +3,7 @@ import SelectionUtils from '../selection';
import $ from '../dom';
import _ from '../utils';
import {API, InlineTool, SanitizerConfig} from '../../../types';
import {Toolbar} from '../../../types/api';
import {Notifier, Toolbar} from '../../../types/api';
/**
* Link Tool
*
@ -84,11 +84,17 @@ export default class LinkInlineTool implements InlineTool {
*/
private inlineToolbar: Toolbar;
/**
* Notifier API methods
*/
private notifier: Notifier;
/**
* @param {{api: API}} - CodeX Editor API
*/
constructor({api}) {
this.inlineToolbar = api.toolbar;
this.notifier = api.notifier;
this.selection = new SelectionUtils();
}
@ -239,9 +245,12 @@ export default class LinkInlineTool implements InlineTool {
}
if (!this.validateURL(value)) {
/**
* @todo show notification 'Incorrect Link'
*/
this.notifier.show({
message: 'Pasted link is not valid.',
style: 'error',
});
_.log('Incorrect Link pasted', 'warn', value);
return;
}