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() {
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();
}

View File

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

View File

@ -8,5 +8,18 @@
</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>

View File

@ -128,7 +128,7 @@ function getIEVersion() {
};
////////////////////////////////////////////////////////////////////////
// exports.waitUntil()
// waitUntil()
////////////////////////////////////////////////////////////////////////
function waitUntil(f, test, ttl) {
if (typeof f !== "function") return;
@ -177,34 +177,26 @@ function addScript(url, callback, test, ttl) {
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()
////////////////////////////////////////////////////////////////////////
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");
el.href = url;
el.rel = "stylesheet";
el.type = "text/css";
el.media = "screen, projection";
document.head.appendChild(el);
if (typeof(callback) === "function") {
el.onload = callback(el);
if (typeof test === "function") {
test(el, callback, ttl);
}
return el;
};
@ -274,14 +266,13 @@ function close() {
exports.getIEVersion = getIEVersion;
exports.waitUntil = waitUntil;
exports.addScript = addScript;
exports.addResources = addResources;
exports.addStylesheet = addStylesheet;
exports.setContent = setContent;
exports.start = start;
exports.reload = reload;
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.global = global;
exports.require = global.require;