mirror of
https://github.com/codex-team/editor.js
synced 2024-05-10 18:36:51 +02:00
toolbox leaf (#96)
* toolbox leaf * new bundle * bundle updates * code improved * updated
This commit is contained in:
parent
d9bab26b62
commit
b76ec5c0a1
|
@ -2581,11 +2581,18 @@ var codex =
|
|||
toolbox.leaf = function () {
|
||||
|
||||
var currentTool = codex.toolbar.current,
|
||||
tool,
|
||||
tools = Object.keys(codex.tools),
|
||||
barButtons = codex.nodes.toolbarButtons,
|
||||
nextToolIndex,
|
||||
hiddenToolsAmount = 0,
|
||||
toolToSelect;
|
||||
|
||||
/** Count toolbox hidden tools */
|
||||
for (tool in codex.tools) {
|
||||
if (!codex.tools[tool].displayInToolbox) hiddenToolsAmount++;
|
||||
}
|
||||
|
||||
if (!currentTool) {
|
||||
|
||||
/** Get first tool from object*/
|
||||
|
@ -2596,7 +2603,22 @@ var codex =
|
|||
|
||||
nextToolIndex = tools.indexOf(currentTool) + 1;
|
||||
|
||||
if (nextToolIndex == tools.length) nextToolIndex = 0;
|
||||
var toolIsLastInToolbox = nextToolIndex == tools.length - (hiddenToolsAmount - 1);
|
||||
|
||||
if (toolIsLastInToolbox) {
|
||||
|
||||
nextToolIndex = 0;
|
||||
|
||||
/** getting first displayed tool */
|
||||
for (tool in codex.tools) {
|
||||
|
||||
nextToolIndex++;
|
||||
|
||||
if (!codex.tools[tool].displayInToolbox) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toolToSelect = tools[nextToolIndex];
|
||||
}
|
||||
|
@ -2604,7 +2626,6 @@ var codex =
|
|||
for (var button in barButtons) {
|
||||
barButtons[button].classList.remove('selected');
|
||||
}barButtons[toolToSelect].classList.add('selected');
|
||||
|
||||
codex.toolbar.current = toolToSelect;
|
||||
};
|
||||
|
||||
|
@ -4012,7 +4033,7 @@ var codex =
|
|||
/**
|
||||
* Splits content by `\n` and returns blocks
|
||||
*/
|
||||
parser.getSeparatedTexttSeparatedTextFromContent = function (content) {
|
||||
parser.getSeparatedTextFromContent = function (content) {
|
||||
return content.split('\n');
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
4253
codex.editor.js
4253
codex.editor.js
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
@ -44,11 +44,19 @@ var toolbox = (function(toolbox) {
|
|||
toolbox.leaf = function(){
|
||||
|
||||
var currentTool = codex.toolbar.current,
|
||||
tool,
|
||||
tools = Object.keys(codex.tools),
|
||||
barButtons = codex.nodes.toolbarButtons,
|
||||
nextToolIndex,
|
||||
hiddenToolsAmount = 0,
|
||||
toolToSelect;
|
||||
|
||||
/** Count toolbox hidden tools */
|
||||
for( tool in codex.tools ) {
|
||||
if (!codex.tools[tool].displayInToolbox)
|
||||
hiddenToolsAmount ++;
|
||||
}
|
||||
|
||||
if ( !currentTool ) {
|
||||
|
||||
/** Get first tool from object*/
|
||||
|
@ -58,16 +66,30 @@ var toolbox = (function(toolbox) {
|
|||
|
||||
nextToolIndex = tools.indexOf(currentTool) + 1;
|
||||
|
||||
if ( nextToolIndex == tools.length) nextToolIndex = 0;
|
||||
var toolIsLastInToolbox = nextToolIndex == tools.length - (hiddenToolsAmount - 1);
|
||||
|
||||
if ( toolIsLastInToolbox ) {
|
||||
|
||||
nextToolIndex = 0;
|
||||
|
||||
/** getting first displayed tool */
|
||||
for( tool in codex.tools ) {
|
||||
|
||||
nextToolIndex ++;
|
||||
|
||||
if (!codex.tools[tool].displayInToolbox){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
toolToSelect = tools[nextToolIndex];
|
||||
|
||||
}
|
||||
|
||||
for (var button in barButtons) barButtons[button].classList.remove('selected');
|
||||
|
||||
barButtons[toolToSelect].classList.add('selected');
|
||||
|
||||
codex.toolbar.current = toolToSelect;
|
||||
|
||||
};
|
||||
|
|
19
package.json
19
package.json
|
@ -1,16 +1,21 @@
|
|||
{
|
||||
"name": "webpack",
|
||||
"name": "codex.editor",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"build": "webpack"
|
||||
},
|
||||
"author": "",
|
||||
"author": "Codex Team",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.21.0",
|
||||
"babel-loader": "^6.2.10",
|
||||
"babel-polyfill": "^6.20.0",
|
||||
"babel-runtime": "^6.20.0",
|
||||
"css-loader": "^0.26.1",
|
||||
"lodash": "^4.17.2",
|
||||
"style-loader": "^0.13.1"
|
||||
"extract-text-webpack-plugin": "^1.0.1",
|
||||
"webpack": "^1.14.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue