Skip to content

Commit

Permalink
2.30.7
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 authored Jul 1, 2020
2 parents 1ac8059 + 8ede9ea commit 64fbc09
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 220 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,13 @@ editor.onImageUploadBefore: function (files, info, core, uploadHandler) {
// Also you can call directly image register not execute "uploadHandler"
// This work is not execute default upload handler
const response = { // Same format as "imageUploadUrl" response
"errorMessage": "insert error message",
"result": [ { "url": "...", "name": "...", "size": "999" }, ]
};
core.plugins.image.register.call(core, info, response);
// also you can call directly error method
core.plugins.image.error.call(core, "errorMessage", response);

// return values
/** return values */
return Boolean || return (new FileList) || return undefined;
}
// Called before the video is uploaded
Expand All @@ -1029,12 +1030,13 @@ editor.onVideoUploadBefore: function (files, info, core, uploadHandler) {
// Also you can call directly video register not execute "uploadHandler"
// This work is not execute default upload handler
const response = { // Same format as "videoUploadUrl" response
"errorMessage": "insert error message",
"result": [ { "url": "...", "name": "...", "size": "999" }, ]
};
core.plugins.video.register.call(core, info, response);
// also you can call directly error method
core.plugins.video.error.call(core, "errorMessage", response);

// return values
/** return values */
return Boolean || return (new FileList) || return undefined;
}
// Called before the audio is uploaded
Expand All @@ -1058,12 +1060,13 @@ editor.onAudioUploadBefore: function (files, info, core, uploadHandler) {
// Also you can call directly audio register not execute "uploadHandler"
// This work is not execute default upload handler
const response = { // Same format as "audioUploadUrl" response
"errorMessage": "insert error message",
"result": [ { "url": "...", "name": "...", "size": "999" }, ]
};
core.plugins.audio.register.call(core, info, response);
// also you can call directly error method
core.plugins.audio.error.call(core, "errorMessage", response);

// return values
/** return values */
return Boolean || return (new FileList) || return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suneditor",
"version": "2.30.6",
"version": "2.30.7",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion dist/css/suneditor.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/suneditor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sideEffects": [
"./src/assets/css/*.css"
],
"version": "2.30.6",
"version": "2.30.7",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion sample/html/out/document-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ <h4 class="name" id="lang"><span class="type-signature"></span>lang<span
<dl class="details"></dl>


<h4 class="name" id="context"><span class="type-signature"></span>context {JsonObject}<span
<h4 class="name" id="context"><span class="type-signature"></span>context {Object}<span
class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
Expand Down
29 changes: 16 additions & 13 deletions sample/html/out/document-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,15 @@ <h4 class="name" id="onImageUploadBefore"><span class="type-signature"></span>on
Called before the image is uploaded.<br>
If false is returned, no image upload is performed.<br>
If new fileList are returned, replaced the previous fileList<br>
<span style="color:#ffe4c4;">@example</span><br>
<span style="color:#ffe4c4;">//</span><br>
<span style="color:#ffe4c4;">Also you can call directly image register not execute "uploadHandler".</span><br>
<span style="color:#ffe4c4;">This work is not execute default upload handler.</span><br>
const response = { <span style="color:#ffe4c4;">// Same format as "imageUploadUrl" response</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;"errorMessage": "insert error message",<br>
&nbsp;&nbsp;&nbsp;&nbsp;"result": [ { "url": "...", "name": "...", "size": "999" }, ]<br>
};<br>
core.plugins.image.register.call(core, info, response);
core.plugins.image.register.call(core, info, response);<br>
<span style="color:#ffe4c4;">also you can call directly error method</span><br>
core.plugins.image.error.call(core, "errorMessage", response);
</div>
<table class="params">
<thead>
Expand Down Expand Up @@ -1140,14 +1141,15 @@ <h4 class="name" id="onVideoUploadBefore"><span class="type-signature"></span>on
Called before the video is uploaded.<br>
If false is returned, no video(iframe, video) upload is performed.<br>
If new fileList are returned, replaced the previous fileList<br>
<span style="color:#ffe4c4;">@example</span><br>
<span style="color:#ffe4c4;">Also you can call directly image register not execute "uploadHandler".</span><br>
<span style="color:#ffe4c4;">//</span><br>
<span style="color:#ffe4c4;">Also you can call directly video register not execute "uploadHandler".</span><br>
<span style="color:#ffe4c4;">This work is not execute default upload handler.</span><br>
const response = { <span style="color:#ffe4c4;">// Same format as "imageUploadUrl" response</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;"errorMessage": "insert error message",<br>
const response = { <span style="color:#ffe4c4;">// Same format as "videoUploadUrl" response</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;"result": [ { "url": "...", "name": "...", "size": "999" }, ]<br>
};<br>
core.plugins.image.register.call(core, info, response);
core.plugins.video.register.call(core, info, response);<br>
<span style="color:#ffe4c4;">also you can call directly error method</span><br>
core.plugins.video.error.call(core, "errorMessage", response);
</div>
<table class="params">
<thead>
Expand Down Expand Up @@ -1365,14 +1367,15 @@ <h4 class="name" id="onAudioUploadBefore"><span class="type-signature"></span>on
Called before the audio is uploaded.<br>
If false is returned, no audio upload is performed.<br>
If new fileList are returned, replaced the previous fileList<br>
<span style="color:#ffe4c4;">@example</span><br>
<span style="color:#ffe4c4;">Also you can call directly image register not execute "uploadHandler".</span><br>
<span style="color:#ffe4c4;">//</span><br>
<span style="color:#ffe4c4;">Also you can call directly audio register not execute "uploadHandler".</span><br>
<span style="color:#ffe4c4;">This work is not execute default upload handler.</span><br>
const response = { <span style="color:#ffe4c4;">// Same format as "imageUploadUrl" response</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;"errorMessage": "insert error message",<br>
const response = { <span style="color:#ffe4c4;">// Same format as "audioUploadUrl" response</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;"result": [ { "url": "...", "name": "...", "size": "999" }, ]<br>
};<br>
core.plugins.image.register.call(core, info, response);
core.plugins.audio.register.call(core, info, response);<br>
<span style="color:#ffe4c4;">also you can call directly error method</span><br>
core.plugins.audio.error.call(core, "errorMessage", response);
<table class="params">
<thead>
<tr>
Expand Down
6 changes: 6 additions & 0 deletions src/assets/css/suneditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
margin: -1px 10px 0 0;
vertical-align: middle;
}
/* se-line-breaker inner icon */
.sun-editor .se-line-breaker > button > svg {
width: 24px;
height: 24px;
}

/* icon class */
.sun-editor button > i::before {
-moz-osx-font-smoothing:grayscale;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/defaultIcons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 16 additions & 62 deletions src/lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export default {
}

/** append html */
editor_div.appendChild(wysiwyg_div);
editor_div.appendChild(textarea);
if (placeholder_span) editor_div.appendChild(placeholder_span);
if (!toolbarContainer) relative.appendChild(tool_bar.element);
Expand Down Expand Up @@ -240,20 +239,17 @@ export default {

if (el.resizingBar) relative.removeChild(el.resizingBar);
if (bottomBar.resizingBar) relative.appendChild(bottomBar.resizingBar);

el.resizingBar = bottomBar.resizingBar;
el.navigation = bottomBar.navigation;
el.charWrapper = bottomBar.charWrapper;
el.charCounter = bottomBar.charCounter;

editorArea.innerHTML = '';
editorArea.appendChild(wysiwygFrame);
editorArea.appendChild(code);

if (placeholder_span) editorArea.appendChild(placeholder_span);

code = this._checkCodeMirror(mergeOptions, code);


el.resizingBar = bottomBar.resizingBar;
el.navigation = bottomBar.navigation;
el.charWrapper = bottomBar.charWrapper;
el.charCounter = bottomBar.charCounter;
el.wysiwygFrame = wysiwygFrame;
el.code = code;
el.placeholder = placeholder_span;
Expand All @@ -276,11 +272,7 @@ export default {
*/
_initElements: function (options, topDiv, toolBar, toolBarArrow) {
/** top div */
topDiv.style.width = options.width;
topDiv.style.minWidth = options.minWidth;
topDiv.style.maxWidth = options.maxWidth;
topDiv.style.display = options.display;
if (typeof options.position === 'string') topDiv.style.position = options.position;
topDiv.style.cssText = options._editorStyles.top;

/** toolbar */
if (/inline/i.test(options.mode)) {
Expand All @@ -301,59 +293,18 @@ export default {
wysiwygDiv.setAttribute('contenteditable', true);
wysiwygDiv.setAttribute('scrolling', 'auto');
wysiwygDiv.className += ' sun-editor-editable';
wysiwygDiv.style.cssText = options._editorStyles.frame + options._editorStyles.editor;
} else {
const cssTags = (function () {
const linkNames = options.iframeCSSFileName;
let tagString = '';

for (let f = 0, len = linkNames.length, path; f < len; f++) {
path = [];

if (/(^https?:\/\/)|(^data:text\/css,)/.test(linkNames[f])) {
path.push(linkNames[f]);
} else {
const CSSFileName = new RegExp('(^|.*[\\/])' + linkNames[f] + '(\\..+)?\\.css(?:\\?.*|;.*)?$', 'i');

for (let c = document.getElementsByTagName('link'), i = 0, len = c.length, styleTag; i < len; i++) {
styleTag = c[i].href.match(CSSFileName);
if (styleTag) path.push(styleTag[0]);
}
}

if (!path || path.length === 0) throw '[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframeCSSFileName" before creating editor instances.';

for (let i = 0, len = path.length; i < len; i++) {
tagString += '<link href="' + path[i] + '" rel="stylesheet">';
}
}

return tagString;
})() + (options.height === 'auto' ? '<style>\n/** Iframe height auto */\nbody{height: min-content; overflow: hidden;}\n</style>' : '');

wysiwygDiv.allowFullscreen = true;
wysiwygDiv.frameBorder = 0;
wysiwygDiv.addEventListener('load', function () {
this.setAttribute('scrolling', 'auto');
this.contentDocument.head.innerHTML = '' +
'<meta charset="utf-8" />' +
'<meta name="viewport" content="width=device-width, initial-scale=1">' +
'<title></title>' +
cssTags;
this.contentDocument.body.className = 'sun-editor-editable';
this.contentDocument.body.setAttribute('contenteditable', true);
});
wysiwygDiv.style.cssText = options._editorStyles.frame;
}

wysiwygDiv.style.cssText = util._setDefaultOptionStyle(options);

// textarea for code view
const textarea = document.createElement('TEXTAREA');
textarea.className = 'se-wrapper-inner se-wrapper-code';
textarea.style.cssText = options._editorStyles.frame;
textarea.style.display = 'none';

textarea.style.height = options.height;
textarea.style.minHeight = options.minHeight;
textarea.style.maxHeight = options.maxHeight;
if (options.height === 'auto') textarea.style.overflow = 'hidden';

/** resize bar */
Expand Down Expand Up @@ -461,7 +412,7 @@ export default {
options.minHeight = (util.isNumber(options.minHeight) ? options.minHeight + 'px' : options.minHeight) || '';
options.maxHeight = (util.isNumber(options.maxHeight) ? options.maxHeight + 'px' : options.maxHeight) || '';
/** Editing area default style */
options.defaultStyle = util._setDefaultOptionStyle(options) + (typeof options.defaultStyle === 'string' ? options.defaultStyle : '');
options.defaultStyle = typeof options.defaultStyle === 'string' ? options.defaultStyle : '';
/** Defining menu items */
options.font = !options.font ? null : options.font;
options.fontSize = !options.fontSize ? null : options.fontSize;
Expand Down Expand Up @@ -546,6 +497,9 @@ export default {
}
return _default;
}, {});

/** _init options */
options._editorStyles = util._setDefaultOptionStyle(options, options.defaultStyle);
},

/**
Expand All @@ -570,9 +524,9 @@ export default {
removeFormat: ['', lang.toolbar.removeFormat, 'removeFormat', '', icons.erase],
indent: ['_se_command_indent', lang.toolbar.indent + (shortcutsDisable.indexOf('indent') > -1 ? '' : ' (' + cmd + '+])'), 'indent', '', icons.outdent],
outdent: ['_se_command_outdent', lang.toolbar.outdent + (shortcutsDisable.indexOf('indent') > -1 ? '' : ' (' + cmd + '+[)'), 'outdent', '', icons.indent],
fullScreen: ['se-code-view-enabled se-resizing-enabled', lang.toolbar.fullScreen, 'fullScreen', '', icons.expansion],
showBlocks: ['', lang.toolbar.showBlocks, 'showBlocks', '', icons.show_blocks],
codeView: ['se-code-view-enabled se-resizing-enabled', lang.toolbar.codeView, 'codeView', '', icons.code_view],
fullScreen: ['se-code-view-enabled se-resizing-enabled _se_command_fullScreen', lang.toolbar.fullScreen, 'fullScreen', '', icons.expansion],
showBlocks: ['_se_command_showBlocks', lang.toolbar.showBlocks, 'showBlocks', '', icons.show_blocks],
codeView: ['se-code-view-enabled se-resizing-enabled _se_command_codeView', lang.toolbar.codeView, 'codeView', '', icons.code_view],
undo: ['_se_command_undo se-resizing-enabled', lang.toolbar.undo + (shortcutsDisable.indexOf('undo') > -1 ? '' : ' (' + cmd + '+Z)'), 'undo', '', icons.undo],
redo: ['_se_command_redo se-resizing-enabled', lang.toolbar.redo + (shortcutsDisable.indexOf('undo') > -1 ? '' : ' (' + cmd + '+Y / ' + cmd + '+SHIFT+Z)'), 'redo', '', icons.redo],
preview: ['se-resizing-enabled', lang.toolbar.preview, 'preview', '', icons.preview],
Expand Down
7 changes: 5 additions & 2 deletions src/lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const _Context = function (element, cons, options) {
charCounter: cons._charCounter,
editorArea: cons._editorArea,
wysiwygFrame: cons._wysiwygArea,
wysiwyg: options.iframe ? cons._wysiwygArea.contentDocument.body : cons._wysiwygArea,
wysiwyg: cons._wysiwygArea, // if (options.iframe) cons._wysiwygArea.contentDocument.body
code: cons._codeArea,
placeholder: cons._placeholder,
loading: cons._loading,
Expand All @@ -53,7 +53,10 @@ const _Context = function (element, cons, options) {
redo: cons._toolBar.querySelector('._se_command_redo'),
save: cons._toolBar.querySelector('._se_command_save'),
outdent: cons._toolBar.querySelector('._se_command_outdent'),
indent: cons._toolBar.querySelector('._se_command_indent')
indent: cons._toolBar.querySelector('._se_command_indent'),
fullScreen: cons._toolBar.querySelector('._se_command_fullScreen'),
showBlocks: cons._toolBar.querySelector('._se_command_showBlocks'),
codeView: cons._toolBar.querySelector('._se_command_codeView')
},
options: options,
option: options
Expand Down
Loading

0 comments on commit 64fbc09

Please sign in to comment.