Allow toolbar & statusbar text to be changed

pull/246/head
David Drury 8 years ago
parent a22a89ecd8
commit 0a58c699da

@ -169,6 +169,9 @@ var simplemde = new SimpleMDE({
} }
}], // Another optional usage, with a custom status bar item that counts keystrokes }], // Another optional usage, with a custom status bar item that counts keystrokes
tabSize: 4, tabSize: 4,
text: {
'preview': 'Vorschau' // Deutsch
} // Allows text for the Toolbar tooltips and statusbar items to be changed - only items to be changed need be included - use the name of the item as the key
toolbar: false, toolbar: false,
toolbarTips: false, toolbarTips: false,
}); });

@ -13,6 +13,11 @@
min-height: 300px min-height: 300px
} }
[dir='rtl'] .CodeMirror-scroll {
margin-right: 0;
margin-left: -30px;
}
.CodeMirror-fullscreen { .CodeMirror-fullscreen {
background: #fff; background: #fff;
position: fixed !important; position: fixed !important;
@ -196,22 +201,23 @@
text-align: right; text-align: right;
} }
.editor-statusbar span { [dir='rtl'] .editor-statusbar {
text-align: left;
}
.editor-statusbar .wrapper {
display: inline-block; display: inline-block;
min-width: 4em; min-width: 4em;
margin-left: 1em; margin-left: 1em;
} }
.editor-statusbar .lines:before { [dir='rtl'] .editor-statusbar .wrapper {
content: 'lines: ' margin-left: 0;
} margin-right: 1em;
.editor-statusbar .words:before {
content: 'words: '
} }
.editor-statusbar .characters:before { .editor-statusbar .value:before {
content: 'characters: ' content: ': ';
} }
.editor-preview { .editor-preview {

@ -1663,6 +1663,10 @@ SimpleMDE.prototype.createToolbar = function(items) {
if(item === "|") { if(item === "|") {
el = createSep(); el = createSep();
} else { } else {
var icon = item.name;
if(self.options.text[icon] !== undefined) {
item.title = self.options.text[icon];
}
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts); el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
} }
@ -1769,7 +1773,7 @@ SimpleMDE.prototype.createStatusbar = function(status) {
} }
items.push({ items.push({
className: name, name: name,
defaultValue: defaultValue, defaultValue: defaultValue,
onUpdate: onUpdate onUpdate: onUpdate
}); });
@ -1790,8 +1794,7 @@ SimpleMDE.prototype.createStatusbar = function(status) {
// Create span element // Create span element
var el = document.createElement("span"); var el = document.createElement("span");
el.className = item.className; el.className = "value";
// Ensure the defaultValue is a function // Ensure the defaultValue is a function
if(typeof item.defaultValue === "function") { if(typeof item.defaultValue === "function") {
@ -1809,9 +1812,18 @@ SimpleMDE.prototype.createStatusbar = function(status) {
}(el, item))); }(el, item)));
} }
// Create span element to hold the item's text
var wrapper = document.createElement("span");
wrapper.className = "wrapper";
if(options.text[item.name] !== undefined) {
wrapper.innerHTML = options.text[item.name];
} else {
wrapper.innerHTML = item.name;
}
wrapper.appendChild(el);
// Append the item to the status bar // Append the item to the status bar
bar.appendChild(el); bar.appendChild(wrapper);
} }

Loading…
Cancel
Save