mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-02 05:52:43 +02:00
Better separator display/hide logic
This commit is contained in:
parent
6b6bb408cf
commit
3da94ef677
File diff suppressed because one or more lines are too long
|
@ -13774,6 +13774,9 @@ var toolbarBuiltInButtons = {
|
||||||
title: "Toggle Fullscreen",
|
title: "Toggle Fullscreen",
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
"separator-4": {
|
||||||
|
name: "separator-4"
|
||||||
|
},
|
||||||
"guide": {
|
"guide": {
|
||||||
name: "guide",
|
name: "guide",
|
||||||
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
||||||
|
@ -13781,8 +13784,8 @@ var toolbarBuiltInButtons = {
|
||||||
title: "Markdown Guide",
|
title: "Markdown Guide",
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"separator-4": {
|
"separator-5": {
|
||||||
name: "separator-4"
|
name: "separator-5"
|
||||||
},
|
},
|
||||||
"undo": {
|
"undo": {
|
||||||
name: "undo",
|
name: "undo",
|
||||||
|
@ -14174,7 +14177,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var toolbar_data = {};
|
var toolbarData = {};
|
||||||
self.toolbar = items;
|
self.toolbar = items;
|
||||||
|
|
||||||
for(i = 0; i < items.length; i++) {
|
for(i = 0; i < items.length; i++) {
|
||||||
|
@ -14189,6 +14192,23 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
|
if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
// Don't include trailing separators
|
||||||
|
if(items[i] === "|") {
|
||||||
|
var nonSeparatorIconsFollow = false;
|
||||||
|
|
||||||
|
for(var x = (i + 1); x < items.length; x++) {
|
||||||
|
if(items[x] !== "|") {
|
||||||
|
nonSeparatorIconsFollow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!nonSeparatorIconsFollow)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Create the icon and append to the toolbar
|
||||||
(function(item) {
|
(function(item) {
|
||||||
var el;
|
var el;
|
||||||
if(item === "|") {
|
if(item === "|") {
|
||||||
|
@ -14208,20 +14228,21 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
el.target = "_blank";
|
el.target = "_blank";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toolbar_data[item.name || item] = el;
|
|
||||||
|
toolbarData[item.name || item] = el;
|
||||||
bar.appendChild(el);
|
bar.appendChild(el);
|
||||||
})(items[i]);
|
})(items[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.toolbarElements = toolbar_data;
|
self.toolbarElements = toolbarData;
|
||||||
|
|
||||||
var cm = this.codemirror;
|
var cm = this.codemirror;
|
||||||
cm.on("cursorActivity", function() {
|
cm.on("cursorActivity", function() {
|
||||||
var stat = getState(cm);
|
var stat = getState(cm);
|
||||||
|
|
||||||
for(var key in toolbar_data) {
|
for(var key in toolbarData) {
|
||||||
(function(key) {
|
(function(key) {
|
||||||
var el = toolbar_data[key];
|
var el = toolbarData[key];
|
||||||
if(stat[key]) {
|
if(stat[key]) {
|
||||||
el.className += " active";
|
el.className += " active";
|
||||||
} else if(key != "fullscreen" && key != "side-by-side") {
|
} else if(key != "fullscreen" && key != "side-by-side") {
|
||||||
|
@ -14333,9 +14354,6 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
||||||
if(typeof item.onUpdate === "function") {
|
if(typeof item.onUpdate === "function") {
|
||||||
// Create a closure around the span of the current action, then execute the onUpdate handler
|
// Create a closure around the span of the current action, then execute the onUpdate handler
|
||||||
this.codemirror.on("update", (function(el, item) {
|
this.codemirror.on("update", (function(el, item) {
|
||||||
console.log(el);
|
|
||||||
console.log(item);
|
|
||||||
console.log("---------------");
|
|
||||||
return function() {
|
return function() {
|
||||||
item.onUpdate(el);
|
item.onUpdate(el);
|
||||||
};
|
};
|
||||||
|
|
2
dist/simplemde.min.js
vendored
2
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -909,6 +909,9 @@ var toolbarBuiltInButtons = {
|
||||||
title: "Toggle Fullscreen",
|
title: "Toggle Fullscreen",
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
"separator-4": {
|
||||||
|
name: "separator-4"
|
||||||
|
},
|
||||||
"guide": {
|
"guide": {
|
||||||
name: "guide",
|
name: "guide",
|
||||||
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
||||||
|
@ -916,8 +919,8 @@ var toolbarBuiltInButtons = {
|
||||||
title: "Markdown Guide",
|
title: "Markdown Guide",
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"separator-4": {
|
"separator-5": {
|
||||||
name: "separator-4"
|
name: "separator-5"
|
||||||
},
|
},
|
||||||
"undo": {
|
"undo": {
|
||||||
name: "undo",
|
name: "undo",
|
||||||
|
@ -1309,7 +1312,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var toolbar_data = {};
|
var toolbarData = {};
|
||||||
self.toolbar = items;
|
self.toolbar = items;
|
||||||
|
|
||||||
for(i = 0; i < items.length; i++) {
|
for(i = 0; i < items.length; i++) {
|
||||||
|
@ -1324,6 +1327,23 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
|
if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
// Don't include trailing separators
|
||||||
|
if(items[i] === "|") {
|
||||||
|
var nonSeparatorIconsFollow = false;
|
||||||
|
|
||||||
|
for(var x = (i + 1); x < items.length; x++) {
|
||||||
|
if(items[x] !== "|") {
|
||||||
|
nonSeparatorIconsFollow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!nonSeparatorIconsFollow)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Create the icon and append to the toolbar
|
||||||
(function(item) {
|
(function(item) {
|
||||||
var el;
|
var el;
|
||||||
if(item === "|") {
|
if(item === "|") {
|
||||||
|
@ -1343,20 +1363,21 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||||
el.target = "_blank";
|
el.target = "_blank";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toolbar_data[item.name || item] = el;
|
|
||||||
|
toolbarData[item.name || item] = el;
|
||||||
bar.appendChild(el);
|
bar.appendChild(el);
|
||||||
})(items[i]);
|
})(items[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.toolbarElements = toolbar_data;
|
self.toolbarElements = toolbarData;
|
||||||
|
|
||||||
var cm = this.codemirror;
|
var cm = this.codemirror;
|
||||||
cm.on("cursorActivity", function() {
|
cm.on("cursorActivity", function() {
|
||||||
var stat = getState(cm);
|
var stat = getState(cm);
|
||||||
|
|
||||||
for(var key in toolbar_data) {
|
for(var key in toolbarData) {
|
||||||
(function(key) {
|
(function(key) {
|
||||||
var el = toolbar_data[key];
|
var el = toolbarData[key];
|
||||||
if(stat[key]) {
|
if(stat[key]) {
|
||||||
el.className += " active";
|
el.className += " active";
|
||||||
} else if(key != "fullscreen" && key != "side-by-side") {
|
} else if(key != "fullscreen" && key != "side-by-side") {
|
||||||
|
|
Loading…
Reference in a new issue