Fix summernote issues

This commit is contained in:
Namhyeon Go 2024-03-20 16:30:30 +09:00
parent f7b4934f6b
commit 0e324a349d
4 changed files with 47 additions and 41 deletions

View File

@ -5856,7 +5856,9 @@ var Editor_Editor = /*#__PURE__*/function () {
value: function beforeCommand() { value: function beforeCommand() {
this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command
document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution try {
document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution
} catch (e) {}
this.focus(); this.focus();
} }

View File

@ -79,29 +79,29 @@ Router.add('/test', function(render) {
// nodepad // nodepad
Router.add('/notepad', function(render) { Router.add('/notepad', function(render) {
// load resources // load resources
Browser.addResources([ Browser.addStylesheet("app/assets/mixed/summernote-0.8.18-dist/summernote-lite.css");
{ Browser.waitUntil(function(test, ttl) {
type: "javascript", Browser.addScript("app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js", function(el) {
url: "app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js" // set DOM id
}, var target_dom_id = "summernote";
{
type: "stylesheet",
url: "app/assets/mixed/summernote-0.8.18-dist/summernote-lite.css"
}
]);
// set DOM id // load HTML
var target_dom_id = "summernote"; render("app/notepad.html", {
"target_dom_id": target_dom_id
});
// load HTML // load Summernote (wysiwyg editor)
render("app/notepad.html", { $('#' + target_dom_id).summernote({
"target_dom_id": target_dom_id minHeight: 300
});
}, test, ttl);
}, function(el) {
alert(typeof $.summernote);
return $.summernote;
}); });
// load Summernote (wysiwyg editor) document.getElementById("useragent").innerHTML = window.navigator.userAgent;
$('#' + target_dom_id).summernote({
minHeight: 300
});
}); });
// go // go

View File

@ -8,5 +8,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col">
<div class="panel cell">
<div class="header">User Agent</div>
<div class="body">
<div class="cell">
<div class="col">
<span id="useragent"></span>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -128,7 +128,7 @@ function getIEVersion() {
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// exports.waitUntil() // waitUntil()
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
function waitUntil(f, test, ttl) { function waitUntil(f, test, ttl) {
if (typeof f !== "function") return; if (typeof f !== "function") return;
@ -177,34 +177,26 @@ function addScript(url, callback, test, ttl) {
return el; return el;
}; };
////////////////////////////////////////////////////////////////////////
// addResources()
////////////////////////////////////////////////////////////////////////
function addResources(resources, callback) {
resources.forEach(function(resource) {
if (["javascript", "text/javascript"].indexOf(resource.type) > -1) {
addScript(resource.url, callback);
} else if (["stylesheet", "text/css"].indexOf(resource.type) > -1) {
addStylesheet(resource.url, callback);
} else {
console.warn("Not supported resource type");
}
});
};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// addStylesheet() // addStylesheet()
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
function addStylesheet(url, callback) { function addStylesheet(url, callback, test, ttl) {
if (typeof test !== "function") {
test = function(el, callback, ttl) {};
}
var ttl = (typeof ttl === "number" ? ttl : 30000); // TTL(Time-To-Live)
var el = document.createElement("link"); var el = document.createElement("link");
el.href = url; el.href = url;
el.rel = "stylesheet"; el.rel = "stylesheet";
el.type = "text/css"; el.type = "text/css";
el.media = "screen, projection"; el.media = "screen, projection";
document.head.appendChild(el); document.head.appendChild(el);
if (typeof(callback) === "function") {
el.onload = callback(el); if (typeof test === "function") {
test(el, callback, ttl);
} }
return el; return el;
}; };
@ -274,14 +266,13 @@ function close() {
exports.getIEVersion = getIEVersion; exports.getIEVersion = getIEVersion;
exports.waitUntil = waitUntil; exports.waitUntil = waitUntil;
exports.addScript = addScript; exports.addScript = addScript;
exports.addResources = addResources;
exports.addStylesheet = addStylesheet; exports.addStylesheet = addStylesheet;
exports.setContent = setContent; exports.setContent = setContent;
exports.start = start; exports.start = start;
exports.reload = reload; exports.reload = reload;
exports.close = close; exports.close = close;
exports.VERSIONINFO = "Browser Library (browser.js) version 0.1.3"; exports.VERSIONINFO = "Browser Library (browser.js) version 0.1.4";
exports.AUTHOR = "abuse@catswords.net"; exports.AUTHOR = "abuse@catswords.net";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;