Skip to content

Commit

Permalink
Change execute export name to exec
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredreich committed Jul 15, 2017
1 parent bfd59aa commit 8ce06c3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Live demo: [https://jaredreich.com/pell](https://jaredreich.com/pell)

| library | size (min+gzip) | size (min) | jquery | bootstrap |
|---------------|-----------------|------------|--------|-----------|
| pell | 1.11kB | 2.86kB | | |
| pell | 1.11kB | 2.85kB | | |
| medium-editor | 27kB | 105kB | | |
| quill | 43kB | 205kB | | |
| ckeditor | 163kB | 551kB | | |
Expand Down Expand Up @@ -100,7 +100,7 @@ npm install --save pell
// ES6
import pell from 'pell'
// or
import { execute, init } from 'pell'
import { exec, init } from 'pell'
```

```js
Expand Down Expand Up @@ -153,7 +153,7 @@ pell.init({
// Execute a document command, see reference:
// https://developer.mozilla.org/en/docs/Web/API/Document/execCommand
// this is just `document.execCommand(command, false, value)`
pell.execute(command<string>, value<string>)
pell.exec(command<string>, value<string>)
```

#### List of overwriteable action names
Expand Down Expand Up @@ -197,7 +197,7 @@ const editor = pell.init({
'underline',
{
name: 'italic',
result: () => window.pell.execute('italic')
result: () => window.pell.exec('italic')
},
{
name: 'custom',
Expand All @@ -209,14 +209,14 @@ const editor = pell.init({
name: 'image',
result: () => {
const url = window.prompt('Enter the image URL')
if (url) window.pell.execute('insertImage', ensureHTTP(url))
if (url) window.pell.exec('insertImage', ensureHTTP(url))
}
},
{
name: 'link',
result: () => {
const url = window.prompt('Enter the link URL')
if (url) window.pell.execute('createLink', ensureHTTP(url))
if (url) window.pell.exec('createLink', ensureHTTP(url))
}
}
],
Expand Down
6 changes: 3 additions & 3 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ <h3>HTML output:</h3>
name: 'zitalic',
icon: 'Z',
title: 'Zitalic',
result: () => window.pell.execute('italic')
result: () => window.pell.exec('italic')
},
{
name: 'image',
result: () => {
const url = window.prompt('Enter the image URL')
if (url) window.pell.execute('insertImage', ensureHTTP(url))
if (url) window.pell.exec('insertImage', ensureHTTP(url))
}
},
{
name: 'link',
result: () => {
const url = window.prompt('Enter the link URL')
if (url) window.pell.execute('createLink', ensureHTTP(url))
if (url) window.pell.exec('createLink', ensureHTTP(url))
}
}
],
Expand Down
36 changes: 18 additions & 18 deletions dist/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,100 +11,100 @@ var actions = {
icon: '<b>B</b>',
title: 'Bold',
result: function result() {
return execute('bold');
return exec('bold');
}
},
italic: {
icon: '<i>I</i>',
title: 'Italic',
result: function result() {
return execute('italic');
return exec('italic');
}
},
underline: {
icon: '<u>U</u>',
title: 'Underline',
result: function result() {
return execute('underline');
return exec('underline');
}
},
strikethrough: {
icon: '<strike>S</strike>',
title: 'Strike-through',
result: function result() {
return execute('strikeThrough');
return exec('strikeThrough');
}
},
heading1: {
icon: '<b>H<sub>1</sub></b>',
title: 'Heading 1',
result: function result() {
return execute('formatBlock', '<H1>');
return exec('formatBlock', '<H1>');
}
},
heading2: {
icon: '<b>H<sub>2</sub></b>',
title: 'Heading 2',
result: function result() {
return execute('formatBlock', '<H2>');
return exec('formatBlock', '<H2>');
}
},
paragraph: {
icon: '&#182;',
title: 'Paragraph',
result: function result() {
return execute('formatBlock', '<P>');
return exec('formatBlock', '<P>');
}
},
quote: {
icon: '&#8220; &#8221;',
title: 'Quote',
result: function result() {
return execute('formatBlock', '<BLOCKQUOTE>');
return exec('formatBlock', '<BLOCKQUOTE>');
}
},
olist: {
icon: '&#35;',
title: 'Ordered List',
result: function result() {
return execute('insertOrderedList');
return exec('insertOrderedList');
}
},
ulist: {
icon: '&#8226;',
title: 'Unordered List',
result: function result() {
return execute('insertUnorderedList');
return exec('insertUnorderedList');
}
},
code: {
icon: '&lt;/&gt;',
title: 'Code',
result: function result() {
return execute('formatBlock', '<PRE>');
return exec('formatBlock', '<PRE>');
}
},
line: {
icon: '&#8213;',
title: 'Horizontal Line',
result: function result() {
return execute('insertHorizontalRule');
return exec('insertHorizontalRule');
}
},
link: {
icon: '&#128279;',
title: 'Link',
result: function result() {
var url = window.prompt('Enter the link URL');
if (url) execute('createLink', url);
if (url) exec('createLink', url);
}
},
image: {
icon: '&#128247;',
title: 'Image',
result: function result() {
var url = window.prompt('Enter the image URL');
if (url) execute('insertImage', url);
if (url) exec('insertImage', url);
}
}
};
Expand All @@ -115,7 +115,7 @@ var classes = {
content: 'pell-content'
};

var execute = function execute(command) {
var exec = function exec(command) {
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

document.execCommand(command, false, value);
Expand Down Expand Up @@ -157,14 +157,14 @@ var init = function init(settings) {
actionbar.appendChild(button);
});

if (settings.styleWithCSS) execute('styleWithCSS');
if (settings.styleWithCSS) exec('styleWithCSS');

return settings.element;
};

var pell = { execute: execute, init: init };
var pell = { exec: exec, init: init };

exports.execute = execute;
exports.exec = exec;
exports.init = init;
exports['default'] = pell;

Expand Down
2 changes: 1 addition & 1 deletion dist/pell.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pell",
"description": "pell - the simplest and smallest WYSIWYG text editor for web, with no dependencies",
"author": "Jared Reich",
"version": "0.6.0",
"version": "0.7.0",
"main": "./dist/pell.min.js",
"scripts": {
"dev": "gulp",
Expand Down
34 changes: 17 additions & 17 deletions src/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,77 @@ const actions = {
bold: {
icon: '<b>B</b>',
title: 'Bold',
result: () => execute('bold')
result: () => exec('bold')
},
italic: {
icon: '<i>I</i>',
title: 'Italic',
result: () => execute('italic')
result: () => exec('italic')
},
underline: {
icon: '<u>U</u>',
title: 'Underline',
result: () => execute('underline')
result: () => exec('underline')
},
strikethrough: {
icon: '<strike>S</strike>',
title: 'Strike-through',
result: () => execute('strikeThrough')
result: () => exec('strikeThrough')
},
heading1: {
icon: '<b>H<sub>1</sub></b>',
title: 'Heading 1',
result: () => execute('formatBlock', '<H1>')
result: () => exec('formatBlock', '<H1>')
},
heading2: {
icon: '<b>H<sub>2</sub></b>',
title: 'Heading 2',
result: () => execute('formatBlock', '<H2>')
result: () => exec('formatBlock', '<H2>')
},
paragraph: {
icon: '&#182;',
title: 'Paragraph',
result: () => execute('formatBlock', '<P>')
result: () => exec('formatBlock', '<P>')
},
quote: {
icon: '&#8220; &#8221;',
title: 'Quote',
result: () => execute('formatBlock', '<BLOCKQUOTE>')
result: () => exec('formatBlock', '<BLOCKQUOTE>')
},
olist: {
icon: '&#35;',
title: 'Ordered List',
result: () => execute('insertOrderedList')
result: () => exec('insertOrderedList')
},
ulist: {
icon: '&#8226;',
title: 'Unordered List',
result: () => execute('insertUnorderedList')
result: () => exec('insertUnorderedList')
},
code: {
icon: '&lt;/&gt;',
title: 'Code',
result: () => execute('formatBlock', '<PRE>')
result: () => exec('formatBlock', '<PRE>')
},
line: {
icon: '&#8213;',
title: 'Horizontal Line',
result: () => execute('insertHorizontalRule')
result: () => exec('insertHorizontalRule')
},
link: {
icon: '&#128279;',
title: 'Link',
result: () => {
const url = window.prompt('Enter the link URL')
if (url) execute('createLink', url)
if (url) exec('createLink', url)
}
},
image: {
icon: '&#128247;',
title: 'Image',
result: () => {
const url = window.prompt('Enter the image URL')
if (url) execute('insertImage', url)
if (url) exec('insertImage', url)
}
}
}
Expand All @@ -83,7 +83,7 @@ const classes = {
content: 'pell-content'
}

export const execute = (command, value = null) => {
export const exec = (command, value = null) => {
document.execCommand(command, false, value)
}

Expand Down Expand Up @@ -122,9 +122,9 @@ export const init = settings => {
actionbar.appendChild(button)
})

if (settings.styleWithCSS) execute('styleWithCSS')
if (settings.styleWithCSS) exec('styleWithCSS')

return settings.element
}

export default { execute, init }
export default { exec, init }

0 comments on commit 8ce06c3

Please sign in to comment.