New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

suneditor

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suneditor - npm Package Compare versions

Comparing version 1.11.4 to 2.0.11

dist/css/suneditor.min.css

2

bower.json
{
"name": "suneditor",
"version": "1.11.4",
"version": "2.0.11",
"description": "Pure JavaScript based WYSIWYG web editor",

@@ -5,0 +5,0 @@ "main": "src/suneditor.js",

{
"name": "suneditor",
"version": "1.11.4",
"sideEffects": [
"./src/assets/css/*.css"
],
"version": "2.0.11",
"description": "Pure JavaScript based WYSIWYG web editor",

@@ -32,6 +35,24 @@ "main": "src/suneditor.js",

"dependencies": {},
"devDependencies": {},
"devDependencies": {
"@babel/core": "7.0.0",
"@webpack-cli/init": "^0.1.0",
"babel-loader": "^8.0.2",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^1.0.0",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.4.2",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"url-loader": "^1.1.1",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8",
"webpack-merge": "^4.1.4"
},
"scripts": {
"dev": "webpack-dev-server --open --config webpack.dev.js",
"build": "webpack --config webpack.prod.js",
"customize": "webpack --config webpack.customize.ex.js",
"test": "echo \"Error: no test specified\" && exit 1"
}
}

@@ -6,2 +6,10 @@ # Suneditor

[![NPM](https://nodei.co/npm/suneditor.png)](https://nodei.co/npm/suneditor/)
![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)
![GitHub release](https://img.shields.io/github/release/qubyte/rubidium.svg)
![Npm](https://img.shields.io/npm/v/npm.svg)
![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/react.svg)
![Github All Releases](https://img.shields.io/github/downloads/atom/atom/total.svg)
```properties

@@ -35,3 +43,249 @@ The Suneditor is based on pure JavaScript

**<a href="http://suneditor.com/sample/html/getting-started.html" target="_blank">Getting Started</a>**
### 1. Include
```html
<link href="../dist/suneditor.min.css" rel="stylesheet" type="text/css">
<script src="../dist/suneditor.min.js"></script>
```
### 2. Target Element
```html
<textarea id="sample">Hi</textarea>
```
### 3. Create
```javascript
/**
* ID : 'suneditor_sample'
* ClassName : 'sun-eidtor'
*/
// ID or DOM object
const suneditor = SUNEDITOR.create((document.getElementById('sample') || 'sample'),{
// All of the plugins are loaded in the "window.SUNEDITOR" object in dist/suneditor.min.js file
// insert options
});
```
### 4. Contents display
```text
When you display a document created by suneditor
You need to include "src/assets/css/suneditor-contents.css" or "dist/css/suneditor.min.css" file.
Then add "sun-editor-editable" to the class name of the Tag element that displays the content.
In "suneditor-contents.css", you can define the style of all the tags created in suneditor.
```
### Use import statement
### 1. Default options
```javascript
import 'suneditor/dist/css/suneditor.min.css'
// or
// import 'suneditor/src/assets/css/suneditor.css'
// import 'suneditor/src/assets/css/suneditor-contents.css'
import suneditor from 'suneditor'
// The default button list is created.
suneditor.create('sample', {
// insert options
});
```
### 2. Load only what you want
```javascript
import 'suneditor/dist/css/suneditor.min.css'
import suneditor from 'suneditor'
import {en, ko} from 'suneditor/src/lang'
import {align, font, fontSize, fontColor, hiliteColor,
horizontalRule, list, table, formatBlock, link, image, video} from 'suneditor/src/plugins'
suneditor.create('sample', {
plugins: [
align,
font,
fontSize,
fontColor,
hiliteColor,
horizontalRule,
list,
table,
formatBlock,
link,
image,
video
],
buttonList: [
['font', 'fontSize', 'formatBlock'],
['fontColor', 'hiliteColor'],
['align', 'horizontalRule', 'list', 'table'],
['link', 'image', 'video']
],
lang: ko
});
```
### 3. Load all plugins
```javascript
import 'suneditor/dist/css/suneditor.min.css'
import suneditor from 'suneditor'
import plugins from 'suneditor/src/plugins'
suneditor.create('sample', {
plugins: plugins,
buttonList: [
['undo', 'redo'],
['font', 'fontSize', 'formatBlock'],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['removeFormat'],
'/', Line break
['fontColor', 'hiliteColor'],
['indent', 'outdent'],
['align', 'horizontalRule', 'list', 'table'],
['link', 'image', 'video'],
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print']
]
})
// You can also load what you want
suneditor.create('sample', {
plugins: [
plugins.font
plugins.fontSize,
plugins.formatBlock
],
buttonList: [
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['font', 'fontSize', 'formatBlock'],
['removeFormat']
]
})
```
### 4. Plugins can be used directly in the button list
```javascript
import 'suneditor/dist/css/suneditor.min.css'
import suneditor from 'suneditor'
import {align, font, fontSize, fontColor, hiliteColor,
horizontalRule, list, table, formatBlock, link, image, video} from 'suneditor/src/plugins'
suneditor.create('sample', {
buttonList: [
['undo', 'redo'],
[font, fontSize, formatBlock],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['removeFormat'],
'/', // Line break
[fontColor, hiliteColor],
['indent', 'outdent'],
[align, horizontalRule, list, table],
[link, image, video],
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print']
],
})
```
### 5. Use init function
```text
The init function can be used by predefining options and calling the create function on the returned object.
The value of the option argument put in the "create" function call takes precedence
```
```javascript
import 'suneditor/dist/css/suneditor.min.css'
import suneditor from 'suneditor'
import plugins from 'suneditor/src/plugins'
// all plugins
const initEditor = suneditor.init({
plugins: plugins,
buttonList: [
['undo', 'redo'],
['font', 'fontSize', 'formatBlock'],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['removeFormat'],
'/', // line break
['fontColor', 'hiliteColor'],
['indent', 'outdent'],
['align', 'horizontalRule', 'list', 'table'],
['link', 'image', 'video'],
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print']
]
});
initEditor.create('sample_1', {
// The value of the option argument put in the "create" function call takes precedence
});
initEditor.create('sample_2', {
// The value of the option argument put in the "create" function call takes precedence
buttonList: [
['undo', 'redo'],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['removeFormat'],
['indent', 'outdent'],
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print']
]
});
```
### options
```javascript
// Plugins
plugins: [
font,
fontSize,
formatBlock,
fontColor,
hiliteColor,
align,
horizontalRule,
list,
table,
link,
image,
video
],
// User Options
fontSize : Change default font-size List default : null
font : Change default font-family List default : null
width : The width size of the editor default : textarea.offsetHeight
height : The height size of the editor default : textarea.style.width||offsetWidth
display : The display property of suneditor default : 'block'
videoX : The default width size of the video frame default : 560
videoY : The default heigth size of the video frame default : 315
showPathLabel : Displays the current node structure to resizebar default : true
popupDisplay : Size of background area when activating dialog window ('full' || '') default : ''
lang : language object default : English
imageFileInput : Choose whether to create a file input tag in the image upload window default : true
imageUrlInput : Choose whether to create a image url input tag in the image upload window default : true
If the value of imageFileInput is false, it will be unconditionally true
imageSize : The default width size of the image frame default : 350
imageUploadUrl : The image upload to server mapping address default : null
ex) "/editor/uploadImage.ajax"
When not used, it enters base64 data
return type : JSONArray [{"SUNEDITOR_IMAGE_SRC":"/download/editorImg/image1.jpg"},
{"SUNEDITOR_IMAGE_SRC":"/download/editorImg/image2.jpg"}]
buttonList : Defines button list to array
default : [
['undo', 'redo'],
// ['font', 'fontSize', 'formatBlock'],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['removeFormat'],
// '/', Line break
// ['fontColor', 'hiliteColor'],
['indent', 'outdent'],
// ['align', 'horizontalRule', 'list', 'table'],
// ['link', 'image', 'video'],
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print']
]
```
## Examples

@@ -38,0 +292,0 @@ **<a href="http://suneditor.com/sample/html/examples.html" target="_blank">Examples</a>**

@@ -8,4 +8,10 @@ /*

*/
SUNEDITOR.plugin.image = {
'use strict';
import dialog from '../modules/dialog'
export default {
name: 'image',
add: function (_this) {
_this._addModule(dialog);
const context = _this.context;

@@ -28,7 +34,8 @@ context.image = {

_proportionChecked: true,
_onCaption: false
_onCaption: false,
_floatClassRegExp: 'float\\-[a-z]+'
};
/** image dialog */
let image_dialog = eval(this.setDialog(_this.context.user));
let image_dialog = eval(this.setDialog(_this.context.user, _this.lang));
context.image.modal = image_dialog;

@@ -62,4 +69,3 @@ context.image.imgUrlFile = image_dialog.getElementsByClassName('sun-editor-id-image-url')[0];

/** dialog */
setDialog: function (user) {
const lang = SUNEDITOR.lang;
setDialog: function (user, lang) {
const dialog = document.createElement('DIV');

@@ -70,14 +76,14 @@ dialog.className = 'modal-content sun-editor-id-dialog-image';

let html = '' +
'<div class="modal-header">' +
' <button type="button" data-command="close" class="close" aria-label="Close">' +
' <div aria-hidden="true" data-command="close" class="icon-cancel"></div>' +
' </button>' +
' <h5 class="modal-title">' + lang.dialogBox.imageBox.title + '</h5>' +
'</div>' +
'<div class="modal-header">' +
' <button type="button" data-command="close" class="close" aria-label="Close" title="' + lang.dialogBox.close + '">' +
' <div aria-hidden="true" data-command="close" class="icon-cancel"></div>' +
' </button>' +
' <h5 class="modal-title">' + lang.dialogBox.imageBox.title + '</h5>' +
'</div>' +
'<div class="sun-editor-tab-button">' +
' <button type="button" class="sun-editor-id-tab-link active" data-tab-link="image">' + lang.toolbar.image + '</button>' +
' <button type="button" class="sun-editor-id-tab-link" data-tab-link="url">' + lang.toolbar.link + '</button>' +
' <button type="button" class="sun-editor-id-tab-link" data-tab-link="url">' + lang.toolbar.link + '</button>' +
'</div>' +
'<form class="editor_image" method="post" enctype="multipart/form-data">' +
' <div class="sun-editor-id-tab-content sun-editor-id-tab-content-image">' +
' <div class="sun-editor-id-tab-content sun-editor-id-tab-content-image">' +
' <div class="modal-body">';

@@ -115,20 +121,20 @@

' </div>' +
' </div>' +
' <div class="sun-editor-id-tab-content sun-editor-id-tab-content-url" style="display: none">' +
' <div class="modal-body">' +
' <div class="form-group">' +
' <label>' + lang.dialogBox.linkBox.url + '</label><input class="form-control sun-editor-id-image-link" type="text" />' +
' </div>' +
' <label><input type="checkbox" class="sun-editor-id-linkCheck" />&nbsp;' + lang.dialogBox.linkBox.newWindowCheck + '</label>' +
' </div>' +
' </div>' +
' <div class="modal-footer">' +
' </div>' +
' <div class="sun-editor-id-tab-content sun-editor-id-tab-content-url" style="display: none">' +
' <div class="modal-body">' +
' <div class="form-group">' +
' <label>' + lang.dialogBox.linkBox.url + '</label><input class="form-control sun-editor-id-image-link" type="text" />' +
' </div>' +
' <input type="checkbox" id="suneditor_image_check_newLink" class="sun-editor-id-linkCheck"/><label for="suneditor_image_check_newLink">&nbsp;' + lang.dialogBox.linkBox.newWindowCheck + '</label>' +
' </div>' +
' </div>' +
' <div class="modal-footer">' +
' <div style="float: left;">' +
' <input type="radio" id="suneditor_image_radio_none" name="suneditor_image_radio" class="modal-radio" value="none" checked><label for="suneditor_image_radio_none">' + lang.dialogBox.basic + '</label>' +
' <input type="radio" id="suneditor_image_radio_left" name="suneditor_image_radio" class="modal-radio" value="left"><label for="suneditor_image_radio_left">' + lang.dialogBox.left + '</label>' +
' <input type="radio" id="suneditor_image_radio_none" name="suneditor_image_radio" class="modal-radio" value="none" checked><label for="suneditor_image_radio_none">' + lang.dialogBox.basic + '</label>' +
' <input type="radio" id="suneditor_image_radio_left" name="suneditor_image_radio" class="modal-radio" value="left"><label for="suneditor_image_radio_left">' + lang.dialogBox.left + '</label>' +
' <input type="radio" id="suneditor_image_radio_center" name="suneditor_image_radio" class="modal-radio" value="center"><label for="suneditor_image_radio_center">' + lang.dialogBox.center + '</label>' +
' <input type="radio" id="suneditor_image_radio_right" name="suneditor_image_radio" class="modal-radio" value="right"><label for="suneditor_image_radio_right">' + lang.dialogBox.right + '</label>' +
' </div>' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-image"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' </div>' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-image" title="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' </div>' +
'</form>';

@@ -141,10 +147,10 @@

openTab: function (e) {
openTab: function (e) {
const targetElement = (e === 'init' ? document.getElementsByClassName('sun-editor-id-tab-link')[0] : e.target);
if (!/^BUTTON$/i.test(targetElement.tagName)) {
return false;
}
if (!/^BUTTON$/i.test(targetElement.tagName)) {
return false;
}
// Declare all variables
// Declare all variables
const tabName = targetElement.getAttribute('data-tab-link');

@@ -154,21 +160,21 @@ const contentClassName = 'sun-editor-id-tab-content';

// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName(contentClassName);
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = 'none';
}
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName(contentClassName);
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = 'none';
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName('sun-editor-id-tab-link');
for (i = 0; i < tablinks.length; i++) {
this.dom.removeClass(tablinks[i], 'active');
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName('sun-editor-id-tab-link');
for (i = 0; i < tablinks.length; i++) {
this.util.removeClass(tablinks[i], 'active');
}
// Show the current tab, and add an "active" class to the button that opened the tab
// Show the current tab, and add an "active" class to the button that opened the tab
this.context.image.modal.getElementsByClassName(contentClassName + '-' + tabName)[0].style.display = 'block';
this.dom.addClass(targetElement, 'active');
this.util.addClass(targetElement, 'active');
// focus
if (tabName === 'image') {
this.context.image.imgUrlFile.focus();
this.context.image.imgInputFile.focus();
} else if (tabName === 'url') {

@@ -178,4 +184,4 @@ this.context.image.imgLink.focus();

return false;
},
return false;
},

@@ -197,9 +203,9 @@ xmlHttp: null,

SUNEDITOR.plugin.image.xmlHttp = this.util.getXMLHttpRequest();
SUNEDITOR.plugin.image.xmlHttp.onreadystatechange = SUNEDITOR.plugin.image.callBack_imgUpload.bind(this, this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.image.imageX.value + 'px', this.context.image._align, this.context.dialog.updateModal);
SUNEDITOR.plugin.image.xmlHttp.open('post', imageUploadUrl, true);
SUNEDITOR.plugin.image.xmlHttp.send(formData);
this.plugins.image.xmlHttp = this.util.getXMLHttpRequest();
this.plugins.image.xmlHttp.onreadystatechange = this.plugins.image.callBack_imgUpload.bind(this, this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.image.imageX.value + 'px', this.context.image._align, this.context.dialog.updateModal);
this.plugins.image.xmlHttp.open('post', imageUploadUrl, true);
this.plugins.image.xmlHttp.send(formData);
} else {
for (let i = 0; i < filesLen; i++) {
SUNEDITOR.plugin.image.setup_reader.call(this, files[i], this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.dialog.updateModal);
this.plugins.image.setup_reader.call(this, files[i], this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.dialog.updateModal);
}

@@ -222,3 +228,3 @@ }

reader.onload = function (update) {
SUNEDITOR.plugin.image.create_image.call(this, reader.result, imgLinkValue, newWindowCheck, this.context.image.imageX.value + 'px', this.context.image._align, update);
this.plugins.image.create_image.call(this, reader.result, imgLinkValue, newWindowCheck, this.context.image.imageX.value + 'px', this.context.image._align, update);
}.bind(this, update);

@@ -230,3 +236,3 @@

callBack_imgUpload: function (linkValue, linkNewWindow, width, align, update) {
const xmlHttp = SUNEDITOR.plugin.image.xmlHttp;
const xmlHttp = this.plugins.image.xmlHttp;
if (xmlHttp.readyState === 4) {

@@ -237,3 +243,3 @@ if (xmlHttp.status === 200) {

for (let i = 0, len = (update && result.length > 0 ? 1 : result.length); i < len; i++) {
SUNEDITOR.plugin.image.create_image.call(this, result[i].SUNEDITOR_IMAGE_SRC, linkValue, linkNewWindow, width, align, update);
this.plugins.image.create_image.call(this, result[i].SUNEDITOR_IMAGE_SRC, linkValue, linkNewWindow, width, align, update);
}

@@ -252,3 +258,3 @@ } else {

try {
SUNEDITOR.plugin.image.create_image.call(this, this.context.image.imgUrlFile.value, this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.image.imageX.value + 'px', this.context.image._align);
this.plugins.image.create_image.call(this, this.context.image.imgUrlFile.value, this.context.image._linkValue, this.context.image.imgLinkNewWindowCheck.checked, this.context.image.imageX.value + 'px', this.context.image._align);
} catch (e) {

@@ -269,5 +275,2 @@ this.closeLoading();

imgTag.setAttribute('data-image-link', imgLinkValue);
imgTag.style.padding = '1px';
imgTag.style.margin = '1px';
imgTag.style.outline = '1px solid #f4b124';

@@ -307,9 +310,9 @@ link.appendChild(imgTag);

if (this.context.dialog.updateModal) {
SUNEDITOR.plugin.image.update_image.call(this);
this.plugins.image.update_image.call(this);
} else {
SUNEDITOR.plugin.image.onRender_imgInput.call(this);
SUNEDITOR.plugin.image.onRender_imgUrl.call(this);
this.plugins.image.onRender_imgInput.call(this);
this.plugins.image.onRender_imgUrl.call(this);
}
} finally {
SUNEDITOR.plugin.dialog.closeDialog.call(this);
this.plugins.dialog.closeDialog.call(this);
this.closeLoading();

@@ -323,6 +326,6 @@ }

const caption = document.createElement('FIGCAPTION');
caption.innerHTML = '<p>' + SUNEDITOR.lang.dialogBox.imageBox.caption + '</p>';
caption.addEventListener('click', SUNEDITOR.plugin.image.toggle_caption_contenteditable.bind(this, true));
caption.innerHTML = '<p>' + this.lang.dialogBox.imageBox.caption + '</p>';
caption.addEventListener('click', this.plugins.image.toggle_caption_contenteditable.bind(this, true));
return caption;

@@ -343,3 +346,2 @@ },

container.setAttribute('contenteditable', false);
container.style.textAlign = 'center';
container.appendChild(cover);

@@ -362,20 +364,22 @@

oImg.alt = this.context.image._altText;
oImg = SUNEDITOR.plugin.image.onRender_link(oImg, linkValue, linkNewWindow);
oImg = this.plugins.image.onRender_link(oImg, linkValue, linkNewWindow);
const cover = SUNEDITOR.plugin.image.set_cover.call(this, oImg);
const container = SUNEDITOR.plugin.image.set_container.call(this, cover);
const cover = this.plugins.image.set_cover.call(this, oImg);
const container = this.plugins.image.set_container.call(this, cover);
// caption
if (this.context.image._captionChecked) {
this.context.image._imageCaption = SUNEDITOR.plugin.image.create_caption.call(this);
this.context.image._imageCaption = this.plugins.image.create_caption.call(this);
this.context.image._imageCaption.setAttribute('contenteditable', false);
cover.appendChild(this.context.image._imageCaption);
}
// align
if ('center' !== align) {
container.style.display = 'inline-block';
container.style.float = align;
this.util.removeClass(container, this.context.image._floatClassRegExp);
this.util.addClass(container, 'float-' + align);
}
this.insertNode(container, this.dom.getFormatElement(this.getSelectionNode()));
this.insertNode(container, this.util.getFormatElement(this.getSelectionNode()));
this.appendP(container);

@@ -387,4 +391,4 @@ },

const linkValue = contextImage._linkValue;
let cover = this.dom.getParentElement(contextImage._element, '.sun-editor-image-cover');
let container = this.dom.getParentElement(contextImage._element, '.sun-editor-id-image-container');
let cover = this.util.getParentElement(contextImage._element, '.sun-editor-image-cover');
let container = this.util.getParentElement(contextImage._element, '.sun-editor-id-image-container');
let isNewContainer = false;

@@ -394,3 +398,3 @@

isNewContainer = true;
cover = SUNEDITOR.plugin.image.set_cover.call(this, contextImage._element.cloneNode(true));
cover = this.plugins.image.set_cover.call(this, contextImage._element.cloneNode(true));
}

@@ -400,3 +404,3 @@

isNewContainer = true;
container = SUNEDITOR.plugin.image.set_container.call(this, cover.cloneNode(true));
container = this.plugins.image.set_container.call(this, cover.cloneNode(true));
} else if (isNewContainer) {

@@ -408,3 +412,3 @@ container.innerHTML = '';

// input update
SUNEDITOR.plugin.image.onRender_imgInput.call(this);
this.plugins.image.onRender_imgInput.call(this);

@@ -421,3 +425,3 @@ // src, size

if (contextImage._imageCaption === null) {
contextImage._imageCaption = SUNEDITOR.plugin.image.create_caption.call(this);
contextImage._imageCaption = this.plugins.image.create_caption.call(this);
cover.appendChild(contextImage._imageCaption);

@@ -427,3 +431,3 @@ }

if (contextImage._imageCaption) {
this.dom.removeItem(contextImage._imageCaption);
this.util.removeItem(contextImage._imageCaption);
}

@@ -435,6 +439,8 @@ }

container.style.display = 'inline-block';
container.style.float = contextImage._align;
this.util.removeClass(container, this.context.image._floatClassRegExp);
this.util.addClass(container, 'float-' + contextImage._align);
} else {
container.style.display = '';
container.style.float = 'none';
this.util.removeClass(container, this.context.image._floatClassRegExp);
this.util.addClass(container, 'float-none');
}

@@ -448,8 +454,8 @@

contextImage._linkElement.href = linkValue;
contextImage._linkElement.target = this.context.image.imgLinkNewWindowCheck.checked;
contextImage._linkElement.target = (contextImage.imgLinkNewWindowCheck.checked ? '_blank' : '');
contextImage._element.setAttribute('data-image-link', linkValue);
} else {
let newEl = SUNEDITOR.plugin.image.onRender_link(contextImage._element.cloneNode(true), linkValue, this.context.image.imgLinkNewWindowCheck.checked);
cover.innerHTML = '';
cover.appendChild(newEl);
let newEl = this.plugins.image.onRender_link(contextImage._element.cloneNode(true), linkValue, this.context.image.imgLinkNewWindowCheck.checked);
cover.removeChild(contextImage._element);
cover.insertBefore(newEl, contextImage._imageCaption);
}

@@ -461,15 +467,11 @@ }

imageElement.setAttribute('data-image-link', '');
imageElement.style.padding = '';
imageElement.style.margin = '';
imageElement.style.outline = '';
let newEl = imageElement.cloneNode(true);
cover.innerHTML = '';
cover.appendChild(newEl);
cover.removeChild(contextImage._linkElement);
cover.insertBefore(newEl, contextImage._imageCaption);
}
if (isNewContainer) {
const existElement = this.dom.getFormatElement(contextImage._element);
const existElement = this.util.getFormatElement(contextImage._element);
existElement.parentNode.insertBefore(container, existElement);
this.dom.removeItem(existElement);
this.util.removeItem(existElement);
}

@@ -496,3 +498,3 @@ },

contextImage._element = contextImage._resize_element = element;
contextImage._imageCaption = element.nextSibling;
contextImage._imageCaption = contextImage._linkElement ? contextImage._linkElement.nextSibling : element.nextSibling;

@@ -521,3 +523,3 @@ contextImage._element_w = size.w;

contextImage.imgLink.value = contextImage._linkElement === null ? '' : contextImage._linkElement.href;
contextImage.imgLinkNewWindowCheck.checked = !contextImage._linkElement || contextImage._linkElement.target === '_blank';
contextImage.imgLinkNewWindowCheck.checked = contextImage._linkElement && contextImage._linkElement.target === '_blank';
contextImage.modal.querySelector('#suneditor_image_radio_' + (contextImage._element.getAttribute('data-align') || 'none')).checked = true;

@@ -531,3 +533,3 @@ contextImage._captionChecked = contextImage.caption.checked = !!contextImage._imageCaption;

SUNEDITOR.plugin.dialog.openDialog.call(this, 'image', null, true);
this.plugins.dialog.openDialog.call(this, 'image', null, true);
},

@@ -541,5 +543,5 @@

destroy: function () {
const imageContainer = this.dom.getParentElement(this.context.image._element, '.sun-editor-id-image-container') || this.context.image._element;
this.dom.removeItem(imageContainer);
SUNEDITOR.plugin.image.init.call(this);
const imageContainer = this.util.getParentElement(this.context.image._element, '.sun-editor-id-image-container') || this.context.image._element;
this.util.removeItem(imageContainer);
this.plugins.image.init.call(this);
},

@@ -561,4 +563,4 @@

this.context.image._element = null;
SUNEDITOR.plugin.image.openTab.call(this, 'init');
this.plugins.image.openTab.call(this, 'init');
}
};

@@ -8,4 +8,10 @@ /*

*/
SUNEDITOR.plugin.link = {
'use strict';
import dialog from '../modules/dialog'
export default {
name: 'link',
add: function (_this) {
_this._addModule(dialog);
const context = _this.context;

@@ -15,3 +21,3 @@ context.link = {};

/** link dialog */
let link_dialog = eval(this.setDialog());
let link_dialog = eval(this.setDialog(_this.lang));
context.link.modal = link_dialog;

@@ -23,3 +29,3 @@ context.link.focusElement = link_dialog.getElementsByClassName('sun-editor-id-link-url')[0];

/** link button */
let link_button = eval(this.setController_LinkBtn());
let link_button = eval(this.setController_LinkBtn(_this.lang));
context.link.linkBtn = link_button;

@@ -41,4 +47,3 @@ context.link._linkAnchor = null;

/** dialog */
setDialog: function () {
const lang = SUNEDITOR.lang;
setDialog: function (lang) {
const dialog = document.createElement('DIV');

@@ -51,3 +56,3 @@

' <div class="modal-header">' +
' <button type="button" data-command="close" class="close" aria-label="Close">' +
' <button type="button" data-command="close" class="close" aria-label="Close" title="' + lang.dialogBox.close + '">' +
' <div aria-hidden="true" data-command="close" class="icon-cancel"></div>' +

@@ -68,3 +73,3 @@ ' </button>' +

' <div class="modal-footer">' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-link"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-link" title="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' </div>' +

@@ -77,4 +82,3 @@ '</form>';

/** modify controller button */
setController_LinkBtn: function () {
const lang = SUNEDITOR.lang;
setController_LinkBtn: function (lang) {
const link_btn = document.createElement('DIV');

@@ -131,3 +135,3 @@

} finally {
SUNEDITOR.plugin.dialog.closeDialog.call(this);
this.plugins.dialog.closeDialog.call(this);
this.closeLoading();

@@ -148,3 +152,3 @@ this.focus();

linkBtn.style.left = selectionATag.offsetLeft + 'px';
linkBtn.style.top = (selectionATag.offsetTop + selectionATag.offsetHeight + this.context.tool.bar.offsetHeight + 10 - this.context.element.wysiwygWindow.pageYOffset) + "px";
linkBtn.style.top = (selectionATag.offsetTop + selectionATag.offsetHeight - this.context.element.wysiwyg.scrollTop + 10) + 'px';
linkBtn.style.display = 'block';

@@ -167,7 +171,7 @@

this.context.link.linkNewWindowCheck.checked = (/_blank/i.test(this.context.link._linkAnchor.target) ? true : false);
SUNEDITOR.plugin.dialog.openDialog.call(this, 'link', null, true);
this.plugins.dialog.openDialog.call(this, 'link', null, true);
}
else {
/** delete */
this.dom.removeItem(this.context.link._linkAnchor);
this.util.removeItem(this.context.link._linkAnchor);
this.context.link._linkAnchor = null;

@@ -187,2 +191,2 @@ this.focus();

}
};
};

@@ -8,4 +8,10 @@ /*

*/
SUNEDITOR.plugin.video = {
'use strict';
import dialog from '../modules/dialog'
export default {
name: 'video',
add: function (_this) {
_this._addModule(dialog);
const context = _this.context;

@@ -30,8 +36,8 @@ context.video = {

const pNode = e.target.parentNode;
const size = SUNEDITOR.plugin.dialog.call_controller_resize.call(_this, pNode, 'video');
SUNEDITOR.plugin.video.onModifyMode.call(_this, pNode.children[0], size);
const size = _this.plugins.dialog.call_controller_resize.call(_this, pNode, 'video');
_this.plugins.video.onModifyMode.call(_this, pNode.children[0], size);
});
/** video dialog */
let video_dialog = eval(this.setDialog());
let video_dialog = eval(this.setDialog(_this.lang));
context.video.modal = video_dialog;

@@ -61,4 +67,3 @@ context.video.focusElement = video_dialog.getElementsByClassName('sun-editor-id-video-url')[0];

/** dialog */
setDialog: function () {
const lang = SUNEDITOR.lang;
setDialog: function (lang) {
const dialog = document.createElement('DIV');

@@ -71,3 +76,3 @@

' <div class="modal-header">' +
' <button type="button" data-command="close" class="close" aria-label="Close">' +
' <button type="button" data-command="close" class="close" aria-label="Close" title="' + lang.dialogBox.close + '">' +
' <div aria-hidden="true" data-command="close" class="icon-cancel"></div>' +

@@ -90,3 +95,3 @@ ' </button>' +

' <div class="modal-footer">' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-video"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' <button type="submit" class="btn btn-primary sun-editor-id-submit-video" title="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
' </div>' +

@@ -156,4 +161,4 @@ '</form>';

/** cover event */
coverSpan.addEventListener('mouseenter', SUNEDITOR.plugin.video.onMouseEnter_cover.bind(this));
coverSpan.addEventListener('mouseleave', SUNEDITOR.plugin.video.onMouseLeave_cover.bind(this).bind(this));
coverSpan.addEventListener('mouseenter', this.plugins.video.onMouseEnter_cover.bind(this));
coverSpan.addEventListener('mouseleave', this.plugins.video.onMouseLeave_cover.bind(this).bind(this));

@@ -178,3 +183,3 @@ oIframe.width = '100%';

} finally {
SUNEDITOR.plugin.dialog.closeDialog.call(this);
this.plugins.dialog.closeDialog.call(this);
this.closeLoading();

@@ -241,3 +246,3 @@ }

SUNEDITOR.plugin.dialog.openDialog.call(this, 'video', null, true);
this.plugins.dialog.openDialog.call(this, 'video', null, true);
},

@@ -251,4 +256,4 @@

destroy: function () {
this.dom.removeItem(this.context.video._coverElement);
SUNEDITOR.plugin.video.init.call(this);
this.util.removeItem(this.context.video._coverElement);
this.plugins.video.init.call(this);
},

@@ -255,0 +260,0 @@

@@ -8,6 +8,9 @@ /*

*/
SUNEDITOR.plugin.align = {
'use strict';
export default {
name: 'align',
add: function (_this, targetElement) {
/** set submenu */
let listDiv = eval(this.setSubmenu());
let listDiv = eval(this.setSubmenu(_this.lang));

@@ -24,4 +27,3 @@ /** add event listeners */

setSubmenu: function () {
const lang = SUNEDITOR.lang;
setSubmenu: function (lang) {
const listDiv = document.createElement('DIV');

@@ -60,2 +62,2 @@

}
};
};

@@ -8,3 +8,6 @@ /*

*/
SUNEDITOR.plugin.font = {
'use strict';
export default {
name: 'font',
add: function (_this, targetElement) {

@@ -30,3 +33,3 @@ /** set submenu */

let font, text, i, len;
let fontList = !user.fontList ?
let fontList = !user.font ?
[

@@ -40,3 +43,3 @@ 'Arial',

'Verdana'
] : user.fontList;
] : user.font;

@@ -48,18 +51,6 @@ let list = '<div class="inner_layer list_family">' +

text = font.split(',')[0];
list += '<li><button type="button" class="btn_edit" data-value="' + font + '" data-txt="' + text + '" style="font-family:' + font + ';">' + text + '</button></li>';
list += '<li><button type="button" class="btn_edit" data-value="' + font + '" data-txt="' + text + '" title="' + text + '" style="font-family:' + font + ';">' + text + '</button></li>';
}
list += ' </ul>';
if (user.addFont) {
fontList = user.addFont;
list += '<ul class="list_editor list_family_add sun-editor-list-font-family-add">';
for (i = 0, len = fontList.length; i < len; i++) {
font = fontList[i];
text = font.split(',')[0];
list += '<li><button type="button" class="btn_edit" data-value="' + font + '" data-txt="' + text + '" style="font-family:' + font + ';">' + text + '</button></li>';
}
list += '</ul>';
}
list += '</div>';
listDiv.innerHTML = list;

@@ -82,3 +73,3 @@

this.dom.changeTxt(this.context.tool.font, target.getAttribute('data-txt'));
this.util.changeTxt(this.context.tool.font, target.getAttribute('data-txt'));
const newNode = document.createElement('SPAN'); newNode.style.fontFamily = target.getAttribute('data-value');

@@ -88,2 +79,2 @@ this.wrapRangeToTag(newNode, ['font-family']);

}
};
};

@@ -8,3 +8,6 @@ /*

*/
SUNEDITOR.plugin.fontSize = {
'use strict';
export default {
name: 'fontSize',
add: function (_this, targetElement) {

@@ -29,3 +32,3 @@ /** set submenu */

const sizeList = !user.fontSizeList ? [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] : user.fontSizeList;
const sizeList = !user.fontSize ? [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] : user.fontSize;

@@ -36,3 +39,3 @@ let list = '<div class="inner_layer">' +

const size = sizeList[i];
list += '<li><button type="button" class="btn_edit" data-value="' + size + '" style="font-size:' + size + 'px;">' + size + '</button></li>';
list += '<li><button type="button" class="btn_edit" data-value="' + size + '" title="' + size + '" style="font-size:' + size + 'px;">' + size + '</button></li>';
}

@@ -57,3 +60,3 @@ list += ' </ul>' +

this.dom.changeTxt(this.context.tool.fontSize, e.target.getAttribute('data-value'));
this.util.changeTxt(this.context.tool.fontSize, e.target.getAttribute('data-value'));
const newNode = document.createElement('SPAN'); newNode.style.fontSize = e.target.getAttribute('data-value') + 'px';

@@ -63,2 +66,2 @@ this.wrapRangeToTag(newNode, ['font-size']);

}
};
};

@@ -8,6 +8,9 @@ /*

*/
SUNEDITOR.plugin.formatBlock = {
'use strict';
export default {
name: 'formatBlock',
add: function (_this, targetElement) {
/** set submenu */
let listDiv = eval(this.setSubmenu());
let listDiv = eval(this.setSubmenu(_this.lang));

@@ -24,4 +27,3 @@ /** add event listeners */

setSubmenu: function () {
const lang = SUNEDITOR.lang;
setSubmenu: function (lang) {
const listDiv = document.createElement('DIV');

@@ -34,10 +36,10 @@

' <ul class="list_editor format_list">' +
' <li style="border-bottom:1px solid #dedede;"><button type="button" class="btn_edit" data-value="P" style="height:24px;"><span style="font-size:13px;">' + lang.toolbar.tag_p + '</span></button></li>' +
' <li><button type="button" class="btn_edit" data-value="DIV" style="height:24px; border-bottom:1px solid #dedede;"><span style="font-size:13px;">' + lang.toolbar.tag_div + '</span></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H1" style="height:45px;"><h1>' + lang.toolbar.tag_h + ' 1</h1></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H2" style="height:34px;"><h2>' + lang.toolbar.tag_h + ' 2</h2></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H3" style="height:26px;"><h3>' + lang.toolbar.tag_h + ' 3</h3></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H4" style="height:23px;"><h4>' + lang.toolbar.tag_h + ' 4</h4></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H5" style="height:19px;"><h5>' + lang.toolbar.tag_h + ' 5</h5></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H6" style="height:15px;"><h6>' + lang.toolbar.tag_h + ' 6</h6></button></li>' +
' <li style="border-bottom:1px solid #dedede;"><button type="button" class="btn_edit" data-value="P" title="' + lang.toolbar.tag_p + '" style="height:24px;"><span style="font-size:13px;">' + lang.toolbar.tag_p + '</span></button></li>' +
' <li><button type="button" class="btn_edit" data-value="DIV" title="' + lang.toolbar.tag_div + '" style="height:24px; border-bottom:1px solid #dedede;"><span style="font-size:13px;">' + lang.toolbar.tag_div + '</span></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H1" title="' + lang.toolbar.tag_h + ' 1" style="height:45px;"><h1>' + lang.toolbar.tag_h + ' 1</h1></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H2" title="' + lang.toolbar.tag_h + ' 2" style="height:34px;"><h2>' + lang.toolbar.tag_h + ' 2</h2></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H3" title="' + lang.toolbar.tag_h + ' 3" style="height:26px;"><h3>' + lang.toolbar.tag_h + ' 3</h3></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H4" title="' + lang.toolbar.tag_h + ' 4" style="height:23px;"><h4>' + lang.toolbar.tag_h + ' 4</h4></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H5" title="' + lang.toolbar.tag_h + ' 5" style="height:19px;"><h5>' + lang.toolbar.tag_h + ' 5</h5></button></li>' +
' <li><button type="button" class="btn_edit" data-value="H6" title="' + lang.toolbar.tag_h + ' 6" style="height:15px;"><h6>' + lang.toolbar.tag_h + ' 6</h6></button></li>' +
' </ul>' +

@@ -62,6 +64,6 @@ '</div>';

this.focus();
this.dom.changeTxt(this.commandMap['FORMAT'], value);
this.util.changeTxt(this.commandMap['FORMAT'], value);
this.execCommand('formatBlock', false, value);
this.submenuOff();
}
};
};

@@ -8,3 +8,6 @@ /*

*/
SUNEDITOR.plugin.hiliteColor = {
'use strict';
export default {
name: 'hiliteColor',
add: function (_this, targetElement) {

@@ -26,3 +29,3 @@ /** set submenu */

const listDiv = document.createElement('DIV');
listDiv.className = 'layer_editor layer_color';
listDiv.className = 'layer_editor';
listDiv.style.display = 'none';

@@ -33,11 +36,8 @@

let list = '<div class="inner_layer">' +
' <div class="pallet_bgcolor pallet_text">' +
' <ul class="list_color list_bgcolor">';
' <div class="pallet_hilite_color">' +
' <ul class="list_color">';
for (let i = 0, len = colorList.length; i < len; i++) {
const color = colorList[i];
list += '<li>' +
' <button type="button" class="' + (/ffffff/.test(color) ? ' color_white' : '') + '" data-value="' + color + '" style="background-color:' + color + ';">' + color + '' +
' <span class="bg_check"></span>' +
' <span class="bg_btnframe"></span>' +
' </button>' +
' <button type="button" class="' + (/ffffff/.test(color) ? ' color_white' : '') + '" data-value="' + color + '" title="' + color + '" style="background-color:' + color + ';"></button>' +
'</li>';

@@ -68,2 +68,2 @@ }

}
};
};

@@ -8,6 +8,9 @@ /*

*/
SUNEDITOR.plugin.list = {
'use strict';
export default {
name: 'list',
add: function (_this, targetElement) {
/** set submenu */
let listDiv = eval(this.setSubmenu());
let listDiv = eval(this.setSubmenu(_this.lang));

@@ -24,4 +27,3 @@ /** add event listeners */

setSubmenu: function () {
const lang = SUNEDITOR.lang;
setSubmenu: function (lang) {
const listDiv = document.createElement('DIV');

@@ -60,2 +62,2 @@

}
};
};

@@ -8,3 +8,6 @@ /*

*/
SUNEDITOR.plugin.table = {
'use strict';
export default {
name: 'table',
add: function (_this, targetElement) {

@@ -70,6 +73,6 @@ const context = _this.context;

this.insertNode(oTable, this.dom.getFormatElement(this.getSelectionNode()));
this.insertNode(oTable, this.util.getFormatElement(this.getSelectionNode()));
this.appendP(oTable);
SUNEDITOR.plugin.table.reset_table_picker.call(this);
this.plugins.table.reset_table_picker.call(this);
},

@@ -92,3 +95,3 @@

this.dom.changeTxt(this.context.submenu.tableDisplay, x + ' x ' + y);
this.util.changeTxt(this.context.submenu.tableDisplay, x + ' x ' + y);
this.context.submenu._tableXY = [x, y];

@@ -108,5 +111,5 @@ },

this.dom.changeTxt(this.context.submenu.tableDisplay, '1 x 1');
this.util.changeTxt(this.context.submenu.tableDisplay, '1 x 1');
this.submenuOff();
}
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc