hideToolbar flag added (#162)

This commit is contained in:
George Berezhnoy 2017-02-17 01:15:23 +03:00 committed by Peter Savchenko
parent d2e755086a
commit 9e32f5a47d
8 changed files with 28 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -55,6 +55,7 @@
codex.editor.start({
textareaId : "codex_area",
initialBlockPlugin : 'paragraph',
hideToolbar: false,
tools : {
paragraph: {
type: 'paragraph',

View file

@ -41,7 +41,15 @@ module.exports = (function (callbacks) {
callbacks.tabKeyPressed = function (event) {
if ( !editor.toolbar.opened ) {
var blockIsEmpty = !editor.content.currentNode.textContent.trim();
if (!blockIsEmpty) {
return;
}
if ( !editor.toolbar.opened ) {
editor.toolbar.open();
@ -361,9 +369,12 @@ module.exports = (function (callbacks) {
/** Hide plus buttons */
editor.toolbar.hidePlusButton();
/** Mark current block */
editor.content.markBlock();
if (!inputIsEmpty) {
/** Mark current block */
editor.content.markBlock();
}
if ( isInitialType && inputIsEmpty ) {

View file

@ -43,6 +43,8 @@ module.exports = (function (core) {
}
editor.hideToolbar = userSettings.hideToolbar;
editor.nodes.textarea = document.getElementById(userSettings.textareaId || editor.settings.textareaId);
if (typeof editor.nodes.textarea === undefined || editor.nodes.textarea === null) {

View file

@ -34,6 +34,12 @@ module.exports = (function (toolbar) {
*/
toolbar.open = function () {
if (editor.hideToolbar) {
return;
}
editor.nodes.toolbar.classList.add('opened');
this.opened = true;

View file

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

File diff suppressed because one or more lines are too long