mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-09-24 16:40:55 -06:00
reduced indentation
This commit is contained in:
parent
f4228c8397
commit
a58eff8097
File diff suppressed because one or more lines are too long
@ -17017,16 +17017,13 @@ var SimpleMDE = function (_Action) {
|
|||||||
}, {
|
}, {
|
||||||
key: 'autosave',
|
key: 'autosave',
|
||||||
value: function autosave() {
|
value: function autosave() {
|
||||||
var _this3 = this;
|
if (!_utils2.default.isLocalStorageAvailable()) {
|
||||||
|
return console.log("SimpleMDE: localStorage not available, cannot autosave");
|
||||||
|
}
|
||||||
|
var simplemde = this;
|
||||||
|
|
||||||
if (_utils2.default.isLocalStorageAvailable()) {
|
if (this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
|
||||||
var _ret3 = function () {
|
return console.log("SimpleMDE: You must set a uniqueId to use the autosave feature");
|
||||||
var simplemde = _this3;
|
|
||||||
|
|
||||||
if (_this3.options.autosave.uniqueId == undefined || _this3.options.autosave.uniqueId == "") {
|
|
||||||
return {
|
|
||||||
v: console.log("SimpleMDE: You must set a uniqueId to use the autosave feature")
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simplemde.element.form != null && simplemde.element.form != undefined) {
|
if (simplemde.element.form != null && simplemde.element.form != undefined) {
|
||||||
@ -17035,16 +17032,16 @@ var SimpleMDE = function (_Action) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this3.options.autosave.loaded !== true) {
|
if (this.options.autosave.loaded !== true) {
|
||||||
if (typeof localStorage.getItem("smde_" + _this3.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + _this3.options.autosave.uniqueId) != "") {
|
if (typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + this.options.autosave.uniqueId) != "") {
|
||||||
_this3.codemirror.setValue(localStorage.getItem("smde_" + _this3.options.autosave.uniqueId));
|
this.codemirror.setValue(localStorage.getItem("smde_" + this.options.autosave.uniqueId));
|
||||||
_this3.options.autosave.foundSavedValue = true;
|
this.options.autosave.foundSavedValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_this3.options.autosave.loaded = true;
|
this.options.autosave.loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem("smde_" + _this3.options.autosave.uniqueId, simplemde.value());
|
localStorage.setItem("smde_" + this.options.autosave.uniqueId, simplemde.value());
|
||||||
|
|
||||||
var el = document.getElementById("autosaved");
|
var el = document.getElementById("autosaved");
|
||||||
if (el != null && el != undefined && el != "") {
|
if (el != null && el != undefined && el != "") {
|
||||||
@ -17060,15 +17057,9 @@ var SimpleMDE = function (_Action) {
|
|||||||
el.innerHTML = 'Autosaved: ' + h + ':' + m + ' ' + dd;
|
el.innerHTML = 'Autosaved: ' + h + ':' + m + ' ' + dd;
|
||||||
}
|
}
|
||||||
|
|
||||||
_this3.autosaveTimeoutId = setTimeout(function () {
|
this.autosaveTimeoutId = setTimeout(function () {
|
||||||
simplemde.autosave();
|
simplemde.autosave();
|
||||||
}, _this3.options.autosave.delay || 10000);
|
}, this.options.autosave.delay || 10000);
|
||||||
}();
|
|
||||||
|
|
||||||
if ((typeof _ret3 === 'undefined' ? 'undefined' : _typeof(_ret3)) === "object") return _ret3.v;
|
|
||||||
} else {
|
|
||||||
console.log("SimpleMDE: localStorage not available, cannot autosave");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'clearAutosavedValue',
|
key: 'clearAutosavedValue',
|
||||||
@ -17088,8 +17079,9 @@ var SimpleMDE = function (_Action) {
|
|||||||
var cm = this.codemirror;
|
var cm = this.codemirror;
|
||||||
var wrapper = cm.getWrapperElement();
|
var wrapper = cm.getWrapperElement();
|
||||||
var preview = wrapper.nextSibling;
|
var preview = wrapper.nextSibling;
|
||||||
|
var notCreate = !preview || !/editor-preview-side/.test(preview.className);
|
||||||
|
|
||||||
if (!preview || !/editor-preview-side/.test(preview.className)) {
|
if (notCreate) {
|
||||||
preview = document.createElement("div");
|
preview = document.createElement("div");
|
||||||
preview.className = "editor-preview-side";
|
preview.className = "editor-preview-side";
|
||||||
wrapper.parentNode.insertBefore(preview, wrapper.nextSibling);
|
wrapper.parentNode.insertBefore(preview, wrapper.nextSibling);
|
||||||
@ -17120,7 +17112,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
}, {
|
}, {
|
||||||
key: 'createToolbar',
|
key: 'createToolbar',
|
||||||
value: function createToolbar() {
|
value: function createToolbar() {
|
||||||
var _this4 = this;
|
var _this3 = this;
|
||||||
|
|
||||||
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.toolbar;
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.toolbar;
|
||||||
|
|
||||||
@ -17136,8 +17128,8 @@ var SimpleMDE = function (_Action) {
|
|||||||
var toolbarData = {};
|
var toolbarData = {};
|
||||||
var nextLoop = function nextLoop(v, i) {
|
var nextLoop = function nextLoop(v, i) {
|
||||||
var name = v.name;
|
var name = v.name;
|
||||||
if (name == "guide" && _this4.options.toolbarGuideIcon === false) return true;
|
if (name == "guide" && _this3.options.toolbarGuideIcon === false) return true;
|
||||||
if (_this4.options.hideIcons && _this4.options.hideIcons.indexOf(name) != -1) return true;
|
if (_this3.options.hideIcons && _this3.options.hideIcons.indexOf(name) != -1) return true;
|
||||||
|
|
||||||
// Fullscreen does not work well on mobile devices (even tablets)
|
// Fullscreen does not work well on mobile devices (even tablets)
|
||||||
// In the future, hopefully this can be resolved
|
// In the future, hopefully this can be resolved
|
||||||
@ -17146,8 +17138,8 @@ var SimpleMDE = function (_Action) {
|
|||||||
// Don't include trailing separators
|
// Don't include trailing separators
|
||||||
if (v === "|") {
|
if (v === "|") {
|
||||||
var nonSeparatorIconsFollow = true;
|
var nonSeparatorIconsFollow = true;
|
||||||
for (var x = i + 1; x < _this4.toolbar.length; x++) {
|
for (var x = i + 1; x < _this3.toolbar.length; x++) {
|
||||||
if (_this4.toolbar[x] !== "|" && (!_this4.options.hideIcons || _this4.options.hideIcons.indexOf(name) == -1)) {
|
if (_this3.toolbar[x] !== "|" && (!_this3.options.hideIcons || _this3.options.hideIcons.indexOf(name) == -1)) {
|
||||||
nonSeparatorIconsFollow = false;
|
nonSeparatorIconsFollow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17157,7 +17149,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
};
|
};
|
||||||
var createElement = function createElement(v) {
|
var createElement = function createElement(v) {
|
||||||
if (v === "|") return createSep();
|
if (v === "|") return createSep();
|
||||||
return createIcon(v, _this4.options.toolbarTips, _this4.options.shortcuts);
|
return createIcon(v, _this3.options.toolbarTips, _this3.options.shortcuts);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toolbar.every(function (v, i) {
|
this.toolbar.every(function (v, i) {
|
||||||
@ -17171,7 +17163,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
if (typeof v.action === "function") {
|
if (typeof v.action === "function") {
|
||||||
el.onclick = function (e) {
|
el.onclick = function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
v.action(_this4);
|
v.action(_this3);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (typeof v.action === "string") {
|
if (typeof v.action === "string") {
|
||||||
@ -17186,7 +17178,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
});
|
});
|
||||||
this.toolbarElements = toolbarData;
|
this.toolbarElements = toolbarData;
|
||||||
this.codemirror.on("cursorActivity", function () {
|
this.codemirror.on("cursorActivity", function () {
|
||||||
var stat = _base2.default.getState(_this4.codemirror);
|
var stat = _base2.default.getState(_this3.codemirror);
|
||||||
|
|
||||||
for (var key in toolbarData) {
|
for (var key in toolbarData) {
|
||||||
(function (key) {
|
(function (key) {
|
||||||
@ -17209,7 +17201,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
}, {
|
}, {
|
||||||
key: 'createStatusbar',
|
key: 'createStatusbar',
|
||||||
value: function createStatusbar() {
|
value: function createStatusbar() {
|
||||||
var _this5 = this;
|
var _this4 = this;
|
||||||
|
|
||||||
var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.status;
|
var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.status;
|
||||||
|
|
||||||
@ -17287,7 +17279,7 @@ var SimpleMDE = function (_Action) {
|
|||||||
if (typeof v.defaultValue === "function") v.defaultValue(el);
|
if (typeof v.defaultValue === "function") v.defaultValue(el);
|
||||||
if (typeof v.onUpdate === "function") {
|
if (typeof v.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
|
||||||
_this5.codemirror.on("update", function () {
|
_this4.codemirror.on("update", function () {
|
||||||
return v.onUpdate(el);
|
return v.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
@ -257,7 +257,9 @@ class SimpleMDE extends Action {
|
|||||||
|
|
||||||
|
|
||||||
autosave() {
|
autosave() {
|
||||||
if(utils.isLocalStorageAvailable()) {
|
if(!utils.isLocalStorageAvailable()) {
|
||||||
|
return console.log("SimpleMDE: localStorage not available, cannot autosave")
|
||||||
|
}
|
||||||
const simplemde = this;
|
const simplemde = this;
|
||||||
|
|
||||||
if(this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
|
if(this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
|
||||||
@ -295,12 +297,9 @@ class SimpleMDE extends Action {
|
|||||||
el.innerHTML = `Autosaved: ${h}:${m} ${dd}`;
|
el.innerHTML = `Autosaved: ${h}:${m} ${dd}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.autosaveTimeoutId = setTimeout(function() {
|
this.autosaveTimeoutId = setTimeout(() => {
|
||||||
simplemde.autosave();
|
simplemde.autosave();
|
||||||
}, this.options.autosave.delay || 10000);
|
}, this.options.autosave.delay || 10000);
|
||||||
} else {
|
|
||||||
console.log("SimpleMDE: localStorage not available, cannot autosave");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
clearAutosavedValue() {
|
clearAutosavedValue() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user