mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-02 14:02:22 +02:00
Add characters count to status bar.
This commit is contained in:
parent
5f3a67dae2
commit
6c61b1a4aa
|
@ -171,7 +171,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
before actual scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
|
@ -551,6 +551,10 @@ span.CodeMirror-selectedtext { background: none; }
|
|||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SimpleMDE = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
(function (global){
|
||||
|
||||
; Typo = global.Typo = require("D:\\My Web Sites\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js");
|
||||
; Typo = global.Typo = require("/Users/vladson/projects/simplemde-markdown-editor/node_modules/codemirror-spell-checker/src/js/typo.js");
|
||||
CodeMirror = global.CodeMirror = require("codemirror");
|
||||
; var __browserify_shim_require__=require;(function browserifyShim(module, define, require) {
|
||||
// Initialize data globally to reduce memory consumption
|
||||
|
@ -105,7 +105,7 @@ if(!String.prototype.includes) {
|
|||
}).call(global, module, undefined, undefined);
|
||||
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"D:\\My Web Sites\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js":2,"codemirror":6}],2:[function(require,module,exports){
|
||||
},{"/Users/vladson/projects/simplemde-markdown-editor/node_modules/codemirror-spell-checker/src/js/typo.js":2,"codemirror":6}],2:[function(require,module,exports){
|
||||
(function (global){
|
||||
; var __browserify_shim_require__=require;(function browserifyShim(module, exports, require, define, browserify_shim__define__module__export__) {
|
||||
'use strict';
|
||||
|
@ -1078,7 +1078,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
else if (typeof define == "function" && define.amd) // AMD
|
||||
return define([], mod);
|
||||
else // Plain browser env
|
||||
this.CodeMirror = mod();
|
||||
(this || window).CodeMirror = mod();
|
||||
})(function() {
|
||||
"use strict";
|
||||
|
||||
|
@ -2159,10 +2159,6 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
||||
}
|
||||
|
||||
function isReadOnly(cm) {
|
||||
return cm.options.readOnly || cm.doc.cantEdit;
|
||||
}
|
||||
|
||||
// This will be set to an array of strings when copying, so that,
|
||||
// when pasting, we know what kind of selections the copied text
|
||||
// was made out of.
|
||||
|
@ -2217,7 +2213,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
||||
if (pasted) {
|
||||
e.preventDefault();
|
||||
if (!isReadOnly(cm) && !cm.options.disableInput)
|
||||
if (!cm.isReadOnly() && !cm.options.disableInput)
|
||||
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
||||
return true;
|
||||
}
|
||||
|
@ -2488,7 +2484,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
// in which case reading its value would be expensive.
|
||||
if (this.contextMenuPending || !cm.state.focused ||
|
||||
(hasSelection(input) && !prevInput && !this.composing) ||
|
||||
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
||||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
|
||||
return false;
|
||||
|
||||
var text = input.value;
|
||||
|
@ -2677,7 +2673,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
|
||||
on(div, "input", function() {
|
||||
if (input.composing) return;
|
||||
if (isReadOnly(cm) || !input.pollContent())
|
||||
if (cm.isReadOnly() || !input.pollContent())
|
||||
runInOp(input.cm, function() {regChange(cm);});
|
||||
});
|
||||
|
||||
|
@ -2757,8 +2753,13 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
||||
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
||||
if (rng) {
|
||||
if (!gecko && this.cm.state.focused) {
|
||||
sel.collapse(start.node, start.offset);
|
||||
if (!rng.collapsed) sel.addRange(rng);
|
||||
} else {
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(rng);
|
||||
}
|
||||
if (old && sel.anchorNode == null) sel.addRange(old);
|
||||
else if (gecko) this.startGracePeriod();
|
||||
}
|
||||
|
@ -2902,7 +2903,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
this.div.focus();
|
||||
},
|
||||
applyComposition: function(composing) {
|
||||
if (isReadOnly(this.cm))
|
||||
if (this.cm.isReadOnly())
|
||||
operation(this.cm, regChange)(this.cm)
|
||||
else if (composing.data && composing.data != composing.startData)
|
||||
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
||||
|
@ -2914,7 +2915,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
|
||||
onKeyPress: function(e) {
|
||||
e.preventDefault();
|
||||
if (!isReadOnly(this.cm))
|
||||
if (!this.cm.isReadOnly())
|
||||
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
||||
},
|
||||
|
||||
|
@ -4679,7 +4680,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
}
|
||||
|
||||
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
||||
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
||||
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
|
||||
type == "single" && (contained = sel.contains(start)) > -1 &&
|
||||
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
||||
(cmp(contained.to(), start) > 0 || start.xRel < 0))
|
||||
|
@ -4903,7 +4904,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
e_preventDefault(e);
|
||||
if (ie) lastDrop = +new Date;
|
||||
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
||||
if (!pos || isReadOnly(cm)) return;
|
||||
if (!pos || cm.isReadOnly()) return;
|
||||
// Might be a file drop, in which case we simply extract the text
|
||||
// and insert it.
|
||||
if (files && files.length && window.FileReader && window.File) {
|
||||
|
@ -5142,7 +5143,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
cm.display.input.ensurePolled();
|
||||
var prevShift = cm.display.shift, done = false;
|
||||
try {
|
||||
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
||||
if (cm.isReadOnly()) cm.state.suppressEdits = true;
|
||||
if (dropShift) cm.display.shift = false;
|
||||
done = bound(cm) != Pass;
|
||||
} finally {
|
||||
|
@ -6303,6 +6304,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||
},
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
||||
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
|
||||
|
||||
scrollTo: methodOp(function(x, y) {
|
||||
if (x != null || y != null) resolveScrollToPos(this);
|
||||
|
@ -14074,6 +14076,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
|||
cm.on("update", function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if(name == "characters") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = cm.getValue().length;
|
||||
});
|
||||
} else if(name === "lines") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
|
|
2
dist/simplemde.min.css
vendored
2
dist/simplemde.min.css
vendored
File diff suppressed because one or more lines are too long
16
dist/simplemde.min.js
vendored
16
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -210,6 +210,10 @@
|
|||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
|
|
|
@ -1271,6 +1271,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
|||
cm.on("update", function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if(name == "characters") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = cm.getValue().length;
|
||||
});
|
||||
} else if(name === "lines") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
|
|
Loading…
Reference in a new issue