|
|
@ -17119,79 +17119,74 @@ var SimpleMDE = function (_Action) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
key: 'createToolbar',
|
|
|
|
key: 'createToolbar',
|
|
|
|
value: function createToolbar(items) {
|
|
|
|
value: function createToolbar() {
|
|
|
|
items = items || this.options.toolbar;
|
|
|
|
var _this4 = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.toolbar;
|
|
|
|
|
|
|
|
|
|
|
|
if (!items || items.length === 0) return;
|
|
|
|
if (!items || items.length === 0) return;
|
|
|
|
var i = void 0;
|
|
|
|
var isExistent = function isExistent(value) {
|
|
|
|
for (i = 0; i < items.length; i++) {
|
|
|
|
return _metadata.toolbarBuiltInButtons[value] != undefined;
|
|
|
|
if (_metadata.toolbarBuiltInButtons[items[i]] != undefined) {
|
|
|
|
};
|
|
|
|
items[i] = _metadata.toolbarBuiltInButtons[items[i]];
|
|
|
|
this.toolbar = items.map(function (v) {
|
|
|
|
}
|
|
|
|
return isExistent(v) ? _metadata.toolbarBuiltInButtons[v] : v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var bar = document.createElement("div");
|
|
|
|
var bar = document.createElement("div");
|
|
|
|
bar.className = "editor-toolbar";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var toolbarData = {};
|
|
|
|
var toolbarData = {};
|
|
|
|
self.toolbar = items;
|
|
|
|
var nextLoop = function nextLoop(v, i) {
|
|
|
|
|
|
|
|
var name = v.name;
|
|
|
|
for (i = 0; i < items.length; i++) {
|
|
|
|
if (name == "guide" && _this4.options.toolbarGuideIcon === false) return true;
|
|
|
|
if (items[i].name == "guide" && self.options.toolbarGuideIcon === false) continue;
|
|
|
|
if (_this4.options.hideIcons && _this4.options.hideIcons.indexOf(name) != -1) return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (self.options.hideIcons && self.options.hideIcons.indexOf(items[i].name) != -1) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if ((items[i].name == "fullscreen" || items[i].name == "side-by-side") && _utils2.default.isMobile()) continue;
|
|
|
|
if ((name == "fullscreen" || name == "side-by-side") && _utils2.default.isMobile()) return true;
|
|
|
|
|
|
|
|
|
|
|
|
// Don't include trailing separators
|
|
|
|
// Don't include trailing separators
|
|
|
|
if (items[i] === "|") {
|
|
|
|
if (v === "|") {
|
|
|
|
var nonSeparatorIconsFollow = false;
|
|
|
|
var nonSeparatorIconsFollow = true;
|
|
|
|
|
|
|
|
for (var x = i + 1; x < _this4.toolbar.length; x++) {
|
|
|
|
for (var x = i + 1; x < items.length; x++) {
|
|
|
|
if (_this4.toolbar[x] !== "|" && (!_this4.options.hideIcons || _this4.options.hideIcons.indexOf(name) == -1)) {
|
|
|
|
if (items[x] !== "|" && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) {
|
|
|
|
nonSeparatorIconsFollow = false;
|
|
|
|
nonSeparatorIconsFollow = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nonSeparatorIconsFollow) return true;
|
|
|
|
if (!nonSeparatorIconsFollow) continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var createElement = function createElement(v) {
|
|
|
|
|
|
|
|
if (v === "|") return createSep();
|
|
|
|
|
|
|
|
return createIcon(v, _this4.options.toolbarTips, _this4.options.shortcuts);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.toolbar.every(function (v, i) {
|
|
|
|
|
|
|
|
if (nextLoop(v, i)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Create the icon and append to the toolbar
|
|
|
|
// Create the icon and append to the toolbar
|
|
|
|
(function (item) {
|
|
|
|
var el = createElement(v);
|
|
|
|
var el = void 0;
|
|
|
|
|
|
|
|
if (item === "|") {
|
|
|
|
|
|
|
|
el = createSep();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind events, special for info
|
|
|
|
// bind events, special for info
|
|
|
|
if (item.action) {
|
|
|
|
if (v.action) {
|
|
|
|
if (typeof item.action === "function") {
|
|
|
|
if (typeof v.action === "function") {
|
|
|
|
el.onclick = function (e) {
|
|
|
|
el.onclick = function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
item.action(self);
|
|
|
|
v.action(_this4);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else if (typeof item.action === "string") {
|
|
|
|
}
|
|
|
|
el.href = item.action;
|
|
|
|
if (typeof v.action === "string") {
|
|
|
|
|
|
|
|
el.href = v.action;
|
|
|
|
el.target = "_blank";
|
|
|
|
el.target = "_blank";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toolbarData[item.name || item] = el;
|
|
|
|
toolbarData[v.name || v] = el;
|
|
|
|
bar.appendChild(el);
|
|
|
|
bar.appendChild(el);
|
|
|
|
})(items[i]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.toolbarElements = toolbarData;
|
|
|
|
self.toolbarElements = toolbarData;
|
|
|
|
this.codemirror.on("cursorActivity", function () {
|
|
|
|
|
|
|
|
var stat = _base2.default.getState(_this4.codemirror);
|
|
|
|
var cm = this.codemirror;
|
|
|
|
|
|
|
|
cm.on("cursorActivity", function () {
|
|
|
|
|
|
|
|
var stat = _base2.default.getState(cm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var key in toolbarData) {
|
|
|
|
for (var key in toolbarData) {
|
|
|
|
(function (key) {
|
|
|
|
(function (key) {
|
|
|
@ -17205,14 +17200,16 @@ var SimpleMDE = function (_Action) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var cmWrapper = cm.getWrapperElement();
|
|
|
|
var cmWrapper = this.codemirror.getWrapperElement();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bar.className = "editor-toolbar";
|
|
|
|
cmWrapper.parentNode.insertBefore(bar, cmWrapper);
|
|
|
|
cmWrapper.parentNode.insertBefore(bar, cmWrapper);
|
|
|
|
return bar;
|
|
|
|
return bar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
key: 'createStatusbar',
|
|
|
|
key: 'createStatusbar',
|
|
|
|
value: function createStatusbar() {
|
|
|
|
value: function createStatusbar() {
|
|
|
|
var _this4 = this;
|
|
|
|
var _this5 = 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;
|
|
|
|
|
|
|
|
|
|
|
@ -17290,7 +17287,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
|
|
|
|
_this4.codemirror.on("update", function () {
|
|
|
|
_this5.codemirror.on("update", function () {
|
|
|
|
return v.onUpdate(el);
|
|
|
|
return v.onUpdate(el);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|