Socket
Socket
Sign inDemoInstall

summernote

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

summernote - npm Package Compare versions

Comparing version 0.6.16 to 0.7.0

.agignore

25

Gruntfile.js

@@ -43,2 +43,3 @@ module.exports = function (grunt) {

'test/**/*.js',
'!test/coverage/**/*.js',
'build/*.js'

@@ -96,6 +97,6 @@ ],

'dist/*.js',
'dist/summernote.css'
'dist/*.css'
]
}, {
src: ['plugin/*.js'],
src: ['plugin/**/*.js', 'lang/**/*.js'],
dest: 'dist/'

@@ -175,2 +176,22 @@ }]

}
},
karma: {
options: {
configFile: './test/karma.conf.js'
},
travis: {
singleRun: true,
browsers: ['PhantomJS'],
reporters: ['progress', 'coverage']
}
},
coveralls: {
options: {
force: false
},
travis: {
src: 'test/coverage/**/lcov.info'
}
}

@@ -177,0 +198,0 @@ });

81

grunts/grunt-build.js

@@ -12,41 +12,22 @@ module.exports = function (grunt) {

grunt.registerMultiTask('build', 'concatenate source: summernote.js', function () {
var self = this;
/**
* Strip all definitions generated by requirejs
*
* @param {String} name
* @param {String} path
* @param {String} contents The contents to be written (including their AMD wrappers)
*/
var convert = function (name, path, contents) {
contents = contents.replace(rDefineStart, '');
var done = this.async();
requirejs.optimize({
name: 'summernote/summernote',
baseUrl: this.data.baseUrl,
/**
* Handle final output from the optimizer
*/
out: function (compiled) {
// 01. Embed version
var version = grunt.config('pkg.version');
compiled = compiled.replace(/@VERSION/g, version);
if (rDefineEndWithReturn.test(contents)) {
contents = contents.replace(rDefineEndWithReturn, '');
} else {
contents = contents.replace(rDefineEnd, '');
}
return contents;
};
// 02. Embed Date
var date = (new Date()).toISOString().replace(/:\d+\.\d+Z$/, 'Z');
compiled = compiled.replace(/@DATE/g, date);
var outputPath = this.data.outFile;
/**
* Handle final output from the optimizer
*/
var out = function (compiled) {
// 01. Embed version
var version = grunt.config('pkg.version');
compiled = compiled.replace(/@VERSION/g, version);
// 02. Embed Date
var date = (new Date()).toISOString().replace(/:\d+\.\d+Z$/, 'Z');
compiled = compiled.replace(/@DATE/g, date);
grunt.file.write(outputPath, compiled);
};
var config = {
name: 'summernote/summernote',
baseUrl: this.data.baseUrl,
out: out,
grunt.file.write(self.data.outFile, compiled);
},
optimize: 'none',

@@ -59,4 +40,21 @@ wrap: {

skipSemiColonInsertion: true,
onBuildWrite: convert,
/**
* Strip all definitions generated by requirejs
*
* @param {String} name
* @param {String} path
* @param {String} contents The contents to be written (including their AMD wrappers)
*/
onBuildWrite: function (name, path, contents) {
contents = contents.replace(rDefineStart, '');
if (rDefineEndWithReturn.test(contents)) {
contents = contents.replace(rDefineEndWithReturn, '');
} else {
contents = contents.replace(rDefineEnd, '');
}
return contents;
},
excludeShallow: ['jquery', 'CodeMirror', 'app'],
include: ['summernote/bs3/settings'],
paths: {

@@ -68,9 +66,6 @@ jquery: 'empty:',

name: 'summernote',
location: './',
main: 'summernote'
main: 'summernote',
location: './'
}]
};
var done = this.async();
requirejs.optimize(config, function () {
}, function () {
done();

@@ -77,0 +72,0 @@ }, function (err) {

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'فيديو',
videoLink: 'رابط الفيديو',
insert: 'إدراج الفيديو',
url: 'رابط الفيديو',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion ou Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'رابط رابط',

@@ -26,2 +26,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Enllaç del video',
insert: 'Inserir video',
url: 'URL del video?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, o Youku)'
},
link: {

@@ -28,0 +35,0 @@ link: 'Enllaç',

@@ -26,2 +26,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Odkaz videa',
insert: 'Vložit video',
url: 'URL videa?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion nebo Youku)'
},
link: {

@@ -28,0 +35,0 @@ link: 'Odkaz',

@@ -37,2 +37,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Video Link',
insert: 'Indsæt Video',
url: 'Video URL?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion eller Youku)'
},
link: {

@@ -39,0 +46,0 @@ link: 'Link',

@@ -33,2 +33,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Video Link',
insert: 'Video einfügen',
url: 'Video URL?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, oder Youku)'
},
link: {

@@ -35,0 +42,0 @@ link: 'Link',

@@ -29,2 +29,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Link del video',
insert: 'Insertar video',
url: '¿URL del video?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, o Youku)'
},
link: {

@@ -31,0 +38,0 @@ link: 'Link',

@@ -27,2 +27,9 @@ (function ($) {

},
video: {
video: 'Bideoa',
videoLink: 'Bideorako esteka',
insert: 'Bideo berri bat txertatu',
url: 'Bideoaren URL helbidea',
providers: '(YouTube, Vimeo, Vine, Instagram, edo DailyMotion)'
},
link: {

@@ -29,0 +36,0 @@ link: 'Esteka',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'ویدیو',
videoLink: 'لینک ویدیو',
insert: 'افزودن ویدیو',
url: 'آدرس ویدیو ؟',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, یا Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'لینک',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Linkki videoon',
insert: 'Lisää video',
url: 'Videon URL-osoite?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion tai Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Linkki',

@@ -37,2 +37,9 @@ (function ($) {

},
video: {
video: 'Vidéo',
videoLink: 'Lien vidéo',
insert: 'Insérer une vidéo',
url: 'URL de la vidéo',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion ou Youku)'
},
link: {

@@ -39,0 +46,0 @@ link: 'Lien',

@@ -30,2 +30,9 @@ (function ($) {

},
video: {
video: 'סרטון',
videoLink: 'קישור לסרטון',
insert: 'הוסף סרטון',
url: 'קישור לסרטון',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion או Youku)'
},
link: {

@@ -32,0 +39,0 @@ link: 'קישור',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Videó',
videoLink: 'Videó hivatkozás',
insert: 'Videó beszúrása',
url: 'Videó URL címe',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, vagy Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Hivatkozás',

@@ -27,2 +27,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Link video',
insert: 'Sisipkan video',
url: 'Tautan video',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, atau Youku)'
},
link: {

@@ -29,0 +36,0 @@ link: 'Tautan',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Collegamento ad un Video',
insert: 'Inserisci Video',
url: 'URL del Video',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion o Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Collegamento',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: '動画',
videoLink: '動画リンク',
insert: '動画挿入',
url: '動画のURL',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'リンク',

@@ -19,3 +19,3 @@ (function ($) {

insert: '사진 추가',
resizeFull: '원본 크기로 변경',
resizeFull: '100% 크기로 변경',
resizeHalf: '50% 크기로 변경',

@@ -30,3 +30,4 @@ resizeQuarter: '25% 크기로 변경',

shapeNone: '스타일: 없음',
dragImageHere: '사진을 이곳으로 끌어오세요',
dragImageHere: '텍스트 혹은 사진을 이곳으로 끌어오세요',
dropImage: '텍스트 혹은 사진을 내려놓으세요',
selectFromFiles: '파일 선택',

@@ -36,2 +37,9 @@ url: '사진 URL',

},
video: {
video: '동영상',
videoLink: '동영상 링크',
insert: '동영상 추가',
url: '동영상 URL',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, Youku 사용 가능)'
},
link: {

@@ -103,2 +111,6 @@ link: '링크',

redo: '다시 실행'
},
specialChar: {
specialChar: '특수문자',
select: '특수문자를 선택하세요'
}

@@ -105,0 +117,0 @@ }

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Videolenke',
insert: 'Sett inn video',
url: 'Video-URL',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion eller Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Lenke',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Video link',
insert: 'Video invoegen',
url: 'URL van de video',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion of Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Link',

@@ -35,2 +35,9 @@ (function ($) {

},
video: {
video: 'Wideo',
videoLink: 'Adres wideo',
insert: 'Wstaw wideo',
url: 'Adres wideo',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, lub Youku)'
},
link: {

@@ -37,0 +44,0 @@ link: 'Odnośnik',

@@ -27,2 +27,9 @@ (function ($) {

},
video: {
video: 'Vídeo',
videoLink: 'Link para vídeo',
insert: 'Inserir vídeo',
url: 'URL do vídeo?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, ou Youku)'
},
link: {

@@ -29,0 +36,0 @@ link: 'Link',

@@ -26,2 +26,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Link video',
insert: 'Inserează video',
url: 'URL video?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion, sau Youku)'
},
link: {

@@ -28,0 +35,0 @@ link: 'Link',

@@ -25,3 +25,8 @@ (function ($) {

floatNone: 'Расположение по-умолчанию',
shapeRounded: 'Форма: Закругленная',
shapeCircle: 'Форма: Круг',
shapeThumbnail: 'Форма: Миниатюра',
shapeNone: 'Форма: Нет',
dragImageHere: 'Перетащите сюда картинку',
dropImage: 'Перетащите картинку',
selectFromFiles: 'Выбрать из файлов',

@@ -31,2 +36,9 @@ url: 'URL картинки',

},
video: {
video: 'Видео',
videoLink: 'Ссылка на видео',
insert: 'Вставить видео',
url: 'URL видео',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion или Youku)'
},
link: {

@@ -33,0 +45,0 @@ link: 'Ссылка',

@@ -26,2 +26,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Odkaz videa',
insert: 'Vložiť video',
url: 'URL videa?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion nebo Youku)'
},
link: {

@@ -28,0 +35,0 @@ link: 'Odkaz',

@@ -30,2 +30,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Video povezava',
insert: 'Vstavi video',
url: 'Povezava do videa',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion ali Youku)'
},
link: {

@@ -32,0 +39,0 @@ link: 'Povezava',

@@ -27,2 +27,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Veza ka videu',
insert: 'Umetni video',
url: 'URL video',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion ili Youku)'
},
link: {

@@ -29,0 +36,0 @@ link: 'Veza',

@@ -27,2 +27,9 @@ (function ($) {

},
video: {
video: 'Видео',
videoLink: 'Веза ка видеу',
insert: 'Уметни видео',
url: 'URL видео',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion или Youku)'
},
link: {

@@ -29,0 +36,0 @@ link: 'Веза',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Filmklipp',
videoLink: 'Länk till filmklipp',
insert: 'Infoga filmklipp',
url: 'Länk till filmklipp',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion eller Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Länk',

@@ -11,6 +11,6 @@ (function ($) {

name: 'แบบตัวอักษร',
strikethrough: 'ขีดฆ่า',
subscript: 'ตัวห้อย',
superscript: 'ตัวยก',
size: 'ขนาดตัวอักษร'
strikethrough: 'ขีดฆ่า',
subscript: 'ตัวห้อย',
superscript: 'ตัวยก',
size: 'ขนาดตัวอักษร'
},

@@ -31,2 +31,9 @@ image: {

},
video: {
video: 'วีดีโอ',
videoLink: 'ลิงก์ของวีดีโอ',
insert: 'แทรกวีดีโอ',
url: 'ที่อยู่ URL ของวีดีโอ?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion หรือ Youku)'
},
link: {

@@ -33,0 +40,0 @@ link: 'ตัวเชื่อมโยง',

@@ -34,2 +34,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Video bağlantısı',
insert: 'Video ekle',
url: 'Video bağlantısı?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion veya Youku)'
},
link: {

@@ -36,0 +43,0 @@ link: 'Bağlantı',

@@ -25,3 +25,8 @@ (function ($) {

floatNone: 'Початкове розташування',
shapeRounded: 'Форма: Заокруглена',
shapeCircle: 'Форма: Коло',
shapeThumbnail: 'Форма: Мініатюра',
shapeNone: 'Форма: Немає',
dragImageHere: 'Перетягніть сюди картинку',
dropImage: 'Перетягніть картинку',
selectFromFiles: 'Вибрати з файлів',

@@ -31,2 +36,9 @@ url: 'URL картинки',

},
video: {
video: 'Відео',
videoLink: 'Посилання на відео',
insert: 'Вставити відео',
url: 'URL відео',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion чи Youku)'
},
link: {

@@ -33,0 +45,0 @@ link: 'Посилання',

@@ -28,2 +28,9 @@ (function ($) {

},
video: {
video: 'Video',
videoLink: 'Đường Dẫn đến Video',
insert: 'Chèn Video',
url: 'URL',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion và Youku)'
},
link: {

@@ -30,0 +37,0 @@ link: 'Đường Dẫn',

@@ -36,2 +36,9 @@ (function ($) {

},
video: {
video: '视频',
videoLink: '视频链接',
insert: '插入视频',
url: '视频地址',
providers: '(优酷, Instagram, DailyMotion, Youtube等)'
},
link: {

@@ -38,0 +45,0 @@ link: '链接',

@@ -36,2 +36,9 @@ (function ($) {

},
video: {
video: '影片',
videoLink: '影片連結',
insert: '插入影片',
url: '影片網址',
providers: '(優酷, Instagram, DailyMotion, Youtube等)'
},
link: {

@@ -38,0 +45,0 @@ link: '連結',

{
"name": "summernote",
"description": "Super Simple WYSIWYG Editor on Bootstrap",
"version": "0.6.16",
"description": "Super simple WYSIWYG editor",
"version": "0.7.0",
"license": "MIT",
"keywords": [
"editor",
"bootstrap",
"WYSIWYG"

@@ -16,3 +15,3 @@ ],

"author": {
"name": "Hackerwins",
"name": "hackerwins",
"email": "<susukang98@gmail.com>"

@@ -29,9 +28,17 @@ },

"grunt-contrib-watch": "*",
"grunt-coveralls": "^1.0.0",
"grunt-exec": "^0.4.6",
"grunt-karma": "^0.12.0",
"grunt-recess": "*",
"grunt-saucelabs": "*",
"karma": "^0.13.3",
"karma-coverage": "^0.4.2",
"karma-phantomjs-launcher": "^0.2.0",
"karma-qunit": "^0.1.5",
"karma-requirejs": "^0.2.2",
"load-grunt-tasks": "0.2.0",
"open": "0.0.4",
"phantomjs": "^1.9.17",
"requirejs": "2.1.9"
}
}
# Summernote
Super simple WYSIWYG Editor using Bootstrap (3.0 and 2.x).
Super simple WYSIWYG Editor.
[![Build Status](https://secure.travis-ci.org/summernote/summernote.png)](http://travis-ci.org/summernote/summernote)
[![Build Status](https://secure.travis-ci.org/summernote/summernote.svg)](http://travis-ci.org/summernote/summernote)
[![npm version](https://badge.fury.io/js/summernote.svg)](http://badge.fury.io/js/summernote)
[![Dependency Status](https://gemnasium.com/summernote/summernote.svg)](https://gemnasium.com/summernote/summernote)
[![Coverage Status](https://coveralls.io/repos/summernote/summernote/badge.svg?branch=develop&service=github)](https://coveralls.io/github/summernote/summernote?branch=develop)
[![Gratipay](https://img.shields.io/gratipay/HackerWins.svg)](https://gratipay.com/~HackerWins/)

@@ -14,3 +16,3 @@ [![Sauce Test Status](https://saucelabs.com/browser-matrix/summernoteis.svg)](https://saucelabs.com/u/summernoteis)

Home Page: http://summernote.org
Home page: <http://summernote.org>

@@ -27,6 +29,2 @@ ### Why Summernote?

#### Inspired by
* Gmail's WYSIWYG editor (http://www.gmail.com)
* Redactor (http://imperavi.com/redactor/)
### Installation and dependencies

@@ -46,10 +44,10 @@

<!-- include libraries(jQuery, bootstrap, fontawesome) -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" />
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css" />
<!-- include summernote css/js-->
<link href="summernote.css" rel="stylesheet">
<script src="summernote.min.js"></script>
<script src="summernote.js"></script>
```

@@ -80,3 +78,3 @@

```javascript
var sHTML = $('#summernote').code();
var html = $('#summernote').summernote('code');
```

@@ -87,3 +85,3 @@

```javascript
$('#summernote').destroy();
$('#summernote').summernote('destroy');
```

@@ -106,3 +104,2 @@

### Developer information

@@ -109,0 +106,0 @@

require.config({
baseUrl: 'src/js',
paths: {
jquery: '//code.jquery.com/jquery-1.11.3',
bootstrap: '//netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min',
summernotevideo: '/../../plugin/summernote-ext-video',
CodeMirror: '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror',
CodeMirrorXml: '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.min',
CodeMirrorFormatting: '//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.min'
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery',
bootstrap: '//netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap',
lang: '../../lang/summernote-ko-KR'
},
shim: {
bootstrap: ['jquery'],
CodeMirror: { exports: 'CodeMirror' },
CodeMirrorXml: ['CodeMirror'],
CodeMirrorFormatting: ['CodeMirror', 'CodeMirrorXml'],
summernotevideo: ['summernote']
lang: ['jquery']
},
packages: [{
name: 'summernote',
location: './',
main: 'summernote'
main: 'summernote',
location: './'
}]

@@ -26,18 +20,34 @@ });

require([
'jquery', 'bootstrap', 'CodeMirrorFormatting',
'summernote', 'summernotevideo'
'jquery',
'summernote'
], function ($) {
// summernote
$('.summernote').summernote({
height: 300, // set editable area's height
focus: true, // set focus editable area after summernote loaded
tabsize: 2, // size of tab
placeholder: 'Type your message here...', // set editable area's placeholder text
codemirror: { // code mirror options
mode: 'text/html',
htmlMode: true,
lineNumbers: true,
theme: 'monokai'
}
var requireByPromise = function (paths) {
return $.Deferred(function (deferred) {
require(paths, function () {
deferred.resolve.apply(this, arguments);
});
});
};
var promise = $.Deferred();
// editor type setting
switch ($('script[data-editor-type]').data('editor-type')) {
case 'lite':
promise = requireByPromise(['summernote/lite/settings']);
break;
case 'bs3':
promise = requireByPromise(['bootstrap', 'summernote/bs3/settings']).then(function () {
return requireByPromise(['lang']);
});
break;
}
promise.then(function () {
// initialize summernote
$('.summernote').summernote({
height: 300,
lang: 'ko-KR',
placeholder: 'type here...'
});
});
});
/**
* Super simple wysiwyg editor on Bootstrap v@VERSION
* Super simple wysiwyg editor v@VERSION
* http://summernote.org/

@@ -16,4 +16,7 @@ *

define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals: jQuery
// Browser globals
factory(window.jQuery);

@@ -20,0 +23,0 @@ }

define([
'summernote/core/agent',
'summernote/core/list',
'summernote/core/dom',
'summernote/core/range',
'summernote/defaults',
'summernote/EventHandler',
'summernote/Renderer'
], function (agent, list, dom, range,
defaults, EventHandler, Renderer) {
'jquery',
'summernote/base/core/func',
'summernote/base/core/list',
'summernote/base/core/dom'
], function ($, func, list, dom) {
// jQuery namespace for summernote
/**
* @class $.summernote
*
* summernote attribute
*
* @mixin defaults
* @singleton
*
* @param {jQuery} $note
* @param {Object} options
* @return {Context}
*/
$.summernote = $.summernote || {};
var Context = function ($note, options) {
var self = this;
// extends default settings
// - $.summernote.version
// - $.summernote.options
// - $.summernote.lang
$.extend($.summernote, defaults);
var ui = $.summernote.ui;
this.memos = {};
this.modules = {};
this.layoutInfo = {};
this.options = options;
var renderer = new Renderer();
var eventHandler = new EventHandler();
this.initialize = function () {
// create layout info
this.layoutInfo = ui.createLayout($note, options);
$.extend($.summernote, {
/** @property {Renderer} */
renderer: renderer,
/** @property {EventHandler} */
eventHandler: eventHandler,
/**
* @property {Object} core
* @property {core.agent} core.agent
* @property {core.dom} core.dom
* @property {core.range} core.range
*/
core: {
agent: agent,
list : list,
dom: dom,
range: range
},
/**
* @property {Object}
* pluginEvents event list for plugins
* event has name and callback function.
*
* ```
* $.summernote.addPlugin({
* events : {
* 'hello' : function(layoutInfo, value, $target) {
* console.log('event name is hello, value is ' + value );
* }
* }
* })
* ```
*
* * event name is data-event property.
* * layoutInfo is a summernote layout information.
* * value is data-value property.
*/
pluginEvents: {},
// add optional buttons
var buttons = $.extend({}, this.options.buttons);
Object.keys(buttons).forEach(function (key) {
self.memo('button.' + key, buttons[key]);
});
plugins : []
});
var modules = $.extend({}, this.options.modules, $.summernote.plugins || {});
/**
* @method addPlugin
*
* add Plugin in Summernote
*
* Summernote can make a own plugin.
*
* ### Define plugin
* ```
* // get template function
* var tmpl = $.summernote.renderer.getTemplate();
*
* // add a button
* $.summernote.addPlugin({
* buttons : {
* // "hello" is button's namespace.
* "hello" : function(lang, options) {
* // make icon button by template function
* return tmpl.iconButton(options.iconPrefix + 'header', {
* // callback function name when button clicked
* event : 'hello',
* // set data-value property
* value : 'hello',
* hide : true
* });
* }
*
* },
*
* events : {
* "hello" : function(layoutInfo, value) {
* // here is event code
* }
* }
* });
* ```
* ### Use a plugin in toolbar
*
* ```
* $("#editor").summernote({
* ...
* toolbar : [
* // display hello plugin in toolbar
* ['group', [ 'hello' ]]
* ]
* ...
* });
* ```
*
*
* @param {Object} plugin
* @param {Object} [plugin.buttons] define plugin button. for detail, see to Renderer.addButtonInfo
* @param {Object} [plugin.dialogs] define plugin dialog. for detail, see to Renderer.addDialogInfo
* @param {Object} [plugin.events] add event in $.summernote.pluginEvents
* @param {Object} [plugin.langs] update $.summernote.lang
* @param {Object} [plugin.options] update $.summernote.options
*/
$.summernote.addPlugin = function (plugin) {
// save plugin list
$.summernote.plugins.push(plugin);
if (plugin.buttons) {
$.each(plugin.buttons, function (name, button) {
renderer.addButtonInfo(name, button);
// add module
Object.keys(modules).forEach(function (key) {
self.module(key, modules[key], true);
});
}
if (plugin.dialogs) {
$.each(plugin.dialogs, function (name, dialog) {
renderer.addDialogInfo(name, dialog);
Object.keys(this.modules).forEach(function (key) {
self.initializeModule(key);
});
}
if (plugin.events) {
$.each(plugin.events, function (name, event) {
$.summernote.pluginEvents[name] = event;
$note.hide();
return this;
};
this.destroy = function () {
Object.keys(this.modules).forEach(function (key) {
self.removeModule(key);
});
}
if (plugin.langs) {
$.each(plugin.langs, function (locale, lang) {
if ($.summernote.lang[locale]) {
$.extend($.summernote.lang[locale], lang);
}
Object.keys(this.memos).forEach(function (key) {
self.removeMemo(key);
});
}
if (plugin.options) {
$.extend($.summernote.options, plugin.options);
}
};
$note.removeData('summernote');
/*
* extend $.fn
*/
$.fn.extend({
/**
* @method
* Initialize summernote
* - create editor layout and attach Mouse and keyboard events.
*
* ```
* $("#summernote").summernote( { options ..} );
* ```
*
* @member $.fn
* @param {Object|String} options reference to $.summernote.options
* @return {this}
*/
summernote: function () {
// check first argument's type
// - {String}: External API call {{module}}.{{method}}
// - {Object}: init options
var type = $.type(list.head(arguments));
var isExternalAPICalled = type === 'string';
var hasInitOptions = type === 'object';
ui.removeLayout($note, this.layoutInfo);
};
// extend default options with custom user options
var options = hasInitOptions ? list.head(arguments) : {};
this.code = function (html) {
var isActivated = this.invoke('codeview.isActivated');
options = $.extend({}, $.summernote.options, options);
options.icons = $.extend({}, $.summernote.options.icons, options.icons);
if (html === undefined) {
this.invoke('codeview.sync');
return isActivated ? this.layoutInfo.codable.val() : this.layoutInfo.editable.html();
} else {
if (isActivated) {
this.layoutInfo.codable.val(html);
} else {
this.layoutInfo.editable.html(html);
}
}
};
// Include langInfo in options for later use, e.g. for image drag-n-drop
// Setup language info with en-US as default
options.langInfo = $.extend(true, {}, $.summernote.lang['en-US'], $.summernote.lang[options.lang]);
this.triggerEvent = function () {
var namespace = list.head(arguments);
var args = list.tail(list.from(arguments));
// override plugin options
if (!isExternalAPICalled && hasInitOptions) {
for (var i = 0, len = $.summernote.plugins.length; i < len; i++) {
var plugin = $.summernote.plugins[i];
var callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')];
if (callback) {
callback.apply($note[0], args);
}
$note.trigger('summernote.' + namespace, args);
};
if (options.plugin[plugin.name]) {
$.summernote.plugins[i] = $.extend(true, plugin, options.plugin[plugin.name]);
}
}
this.initializeModule = function (key) {
var module = this.modules[key];
module.shouldInitialize = module.shouldInitialize || func.ok;
if (!module.shouldInitialize()) {
return;
}
this.each(function (idx, holder) {
var $holder = $(holder);
// initialize module
if (module.initialize) {
module.initialize();
}
// if layout isn't created yet, createLayout and attach events
if (!renderer.hasNoteEditor($holder)) {
renderer.createLayout($holder, options);
// attach events
if (module.events) {
dom.attachEvents($note, module.events);
}
};
var layoutInfo = renderer.layoutInfoFromHolder($holder);
$holder.data('layoutInfo', layoutInfo);
this.module = function (key, ModuleClass, withoutIntialize) {
if (arguments.length === 1) {
return this.modules[key];
}
eventHandler.attach(layoutInfo, options);
eventHandler.attachCustomEvent(layoutInfo, options);
}
});
this.modules[key] = new ModuleClass(this);
var $first = this.first();
if ($first.length) {
var layoutInfo = renderer.layoutInfoFromHolder($first);
if (!withoutIntialize) {
this.initializeModule(key);
}
};
// external API
if (isExternalAPICalled) {
var moduleAndMethod = list.head(list.from(arguments));
var args = list.tail(list.from(arguments));
this.removeModule = function (key) {
var module = this.modules[key];
if (module.shouldInitialize()) {
if (module.events) {
dom.detachEvents($note, module.events);
}
// TODO now external API only works for editor
var params = [moduleAndMethod, layoutInfo.editable()].concat(args);
return eventHandler.invoke.apply(eventHandler, params);
} else if (options.focus) {
// focus on first editable element for initialize editor
layoutInfo.editable().focus();
if (module.destroy) {
module.destroy();
}
}
return this;
},
delete this.modules[key];
this.modules[key] = null;
};
/**
* @method
*
* get the HTML contents of note or set the HTML contents of note.
*
* * get contents
* ```
* var content = $("#summernote").code();
* ```
* * set contents
*
* ```
* $("#summernote").code(html);
* ```
*
* @member $.fn
* @param {String} [html] - HTML contents(optional, set)
* @return {this|String} - context(set) or HTML contents of note(get).
*/
code: function (html) {
// get the HTML contents of note
if (html === undefined) {
var $holder = this.first();
if (!$holder.length) {
return;
}
this.memo = function (key, obj) {
if (arguments.length === 1) {
return this.memos[key];
}
this.memos[key] = obj;
};
var layoutInfo = renderer.layoutInfoFromHolder($holder);
var $editable = layoutInfo && layoutInfo.editable();
this.removeMemo = function (key) {
if (this.memos[key] && this.memos[key].destroy) {
this.memos[key].destroy();
}
if ($editable && $editable.length) {
var isCodeview = eventHandler.invoke('codeview.isActivated', layoutInfo);
eventHandler.invoke('codeview.sync', layoutInfo);
return isCodeview ? layoutInfo.codable().val() :
layoutInfo.editable().html();
}
return dom.value($holder);
delete this.memos[key];
this.memos[key] = null;
};
this.createInvokeHandler = function (namespace, value) {
return function (event) {
event.preventDefault();
self.invoke(namespace, value || $(event.target).data('value') || $(event.currentTarget).data('value'));
};
};
this.invoke = function () {
var namespace = list.head(arguments);
var args = list.tail(list.from(arguments));
var splits = namespace.split('.');
var hasSeparator = splits.length > 1;
var moduleName = hasSeparator && list.head(splits);
var methodName = hasSeparator ? list.last(splits) : list.head(splits);
var module = this.modules[moduleName || 'editor'];
if (!moduleName && this[methodName]) {
return this[methodName].apply(this, args);
} else if (module && module[methodName] && module.shouldInitialize()) {
return module[methodName].apply(module, args);
}
};
// set the HTML contents of note
this.each(function (i, holder) {
var layoutInfo = renderer.layoutInfoFromHolder($(holder));
var $editable = layoutInfo && layoutInfo.editable();
if ($editable) {
$editable.html(html);
}
});
return this.initialize();
};
return this;
},
$.summernote = $.summernote || {
lang: {}
};
$.fn.extend({
/**
* @method
*
* destroy Editor Layout and detach Key and Mouse Event
* Summernote API
*
* @member $.fn
* @param {Object|String}
* @return {this}
*/
destroy: function () {
this.each(function (idx, holder) {
var $holder = $(holder);
summernote: function () {
var type = $.type(list.head(arguments));
var isExternalAPICalled = type === 'string';
var hasInitOptions = type === 'object';
if (!renderer.hasNoteEditor($holder)) {
return;
}
var options = hasInitOptions ? list.head(arguments) : {};
var info = renderer.layoutInfoFromHolder($holder);
var options = info.editor().data('options');
options = $.extend({}, $.summernote.options, options);
options.langInfo = $.extend(true, {}, $.summernote.lang['en-US'], $.summernote.lang[options.lang]);
eventHandler.detach(info, options);
renderer.removeLayout($holder, info, options);
this.each(function (idx, note) {
var $note = $(note);
if (!$note.data('summernote')) {
$note.data('summernote', new Context($note, options));
$note.data('summernote').triggerEvent('init');
}
});
return this;
var $note = this.first();
if (isExternalAPICalled && $note.length) {
var context = $note.data('summernote');
return context.invoke.apply(context, list.from(arguments));
} else {
return this;
}
}
});
});

@@ -23,3 +23,5 @@ /**

require([
'summernote/core/agent',
'summernote/base/core/agent',
'../../test/unit/func.spec',
'../../test/unit/key.spec',
'../../test/unit/dom.spec',

@@ -29,3 +31,3 @@ '../../test/unit/list.spec',

'../../test/unit/style.spec'
], function (agent, domSpec, listSpec, rangeSpec, styleSpec) {
], function (agent, funcSpec, keySpec, domSpec, listSpec, rangeSpec, styleSpec) {
/* global QUnit */

@@ -53,2 +55,6 @@ QUnit.start();

module('unit/func');
funcSpec(helper);
module('unit/key');
keySpec(helper);
module('unit/dom');

@@ -55,0 +61,0 @@ domSpec(helper);

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

'jquery',
'summernote/core/dom',
'summernote/core/func'
'summernote/base/core/dom',
'summernote/base/core/func'
], function ($, dom, func) {

@@ -12,0 +12,0 @@ return function (helper) {

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

*/
define(['jquery', 'summernote/core/list'], function ($, list) {
define([
'jquery',
'summernote/base/core/list'
], function ($, list) {
return function () {

@@ -9,0 +12,0 @@ test('list.head', function () {

@@ -8,5 +8,5 @@ /**

'jquery',
'summernote/core/agent',
'summernote/core/dom',
'summernote/core/range'
'summernote/base/core/agent',
'summernote/base/core/dom',
'summernote/base/core/range'
], function ($, agent, dom, range) {

@@ -67,5 +67,34 @@ return function (helper) {

equal(rng.commonAncestor(), $b[0].firstChild, 'rng.commonAncestor on <b>|b|</b> should returns b(#textNode)');
});
test('rng.expand', function () {
var rng, $cont, $b, $u, $anchor;
$cont = $('<div><a><b>b</b><u>u</u></a></div>');
$anchor = $cont.find('a');
$b = $cont.find('b');
$u = $cont.find('u');
rng = range.create($b[0].firstChild, 0, $b[0].firstChild, 0).expand(dom.isAnchor);
deepEqual([
rng.sc, rng.so, rng.ec, rng.eo
], [
$anchor[0], 0, $anchor[0], 2
], 'rng.expand on `<b>|b</b>` with isAnchor should returns `<b>|b</b> ~ <u>u|</u>`');
});
test('rng.collapse', function () {
var rng, $cont, $b, $u;
$cont = $('<div><b>b</b><u>u</u></div>');
$b = $cont.find('b');
$u = $cont.find('u');
rng = range.create($b[0].firstChild, 0, $u[0].firstChild, 1).collapse();
deepEqual([
rng.sc, rng.so, rng.ec, rng.eo
], [
$u[0].firstChild, 1, $u[0].firstChild, 1
], 'rng.collapse on `<b>|b</b> ~ <u>u|</u>` should returns `<u>u|</u>`');
});
test('rng.normalize', function () {

@@ -72,0 +101,0 @@ var rng, $cont, $p, $b, $u, $s;

@@ -8,5 +8,5 @@ /**

'jquery',
'summernote/core/dom',
'summernote/core/range',
'summernote/editing/Style'
'summernote/base/core/dom',
'summernote/base/core/range',
'summernote/base/editing/Style'
], function ($, dom, range, Style) {

@@ -123,5 +123,30 @@ return function () {

);
});
test('style.current basic', function () {
var $cont, $p, rng, styleInfo;
$cont = $('<div class="note-editable"><p style="font-family: Arial;">text</p></div>');
$p = $cont.find('p');
rng = range.create($p[0].firstChild, 0, $p[0].firstChild, 0);
styleInfo = style.current(rng);
equal(
styleInfo['font-family'],
'Arial',
'should return parent style when text node is selected'
);
$cont = $('<div class="note-editable"><p style="font-family: Arial;"><!-- comment --></p></div>');
$p = $cont.find('p');
rng = range.create($p[0].firstChild, 0, $p[0].firstChild, 0);
styleInfo = style.current(rng);
equal(
styleInfo['font-family'],
'Arial',
'should return parent style when comment node is selected'
);
});
};
});

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

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

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 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

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