|
1 | | -jQuery insert plugin for MediumEditor |
2 | | -====================================== |
| 1 | +# jQuery insert plugin for MediumEditor |
3 | 2 |
|
4 | | -This plugin expands capabilities of [MediumEditor](https://github.com/daviferreira/medium-editor) (a clone of [medium.com](http://medium.com) WYSIWYG editor). |
| 3 | +[](https://travis-ci.org/orthes/medium-editor-insert-plugin) |
| 4 | +[](http://www.versioneye.com/user/projects/53f742dce09da3467d000389) |
| 5 | +[](http://www.versioneye.com/user/projects/53f742e2e09da3dca800038f) |
| 6 | +[](https://www.codacy.com/public/orthes/mediumeditorinsertplugin) |
| 7 | +[](http://waffle.io/orthes/medium-editor-insert-plugin) |
5 | 8 |
|
6 | | -The plugins enables users to insert into the editor various types of content (depending on available addons). |
| 9 | +This plugin expands capabilities of [MediumEditor](https://github.com/daviferreira/medium-editor) (a clone of medium.com WYSIWYG editor) and it enables users to insert into the editor various types of content (depending on available addons). |
7 | 10 |
|
8 | 11 | Current available addons: |
9 | 12 |
|
10 | | -- images |
11 | | -- embeds (either through oEmbed proxy, such as [Iframely](https://iframely.com), or pre-defined parsers such as - Youtube, Vimeo, Twitter, Facebook, Instagram) |
12 | | -- tables (basic table creating) |
13 | | - |
14 | | ---- |
15 | | - |
16 | | -This is a legacy version of the plugin. To see the current **1.0 version** go to [master branch](https://github.com/orthes/medium-editor-insert-plugin). |
| 13 | +- **images** |
| 14 | +- **embeds** (either through oEmbed proxy, such as [Iframely](https://iframely.com/), or pre-defined parsers such as - Youtube, Vimeo, Twitter, Facebook, Instagram) |
17 | 15 |
|
18 | | ---- |
19 | 16 |
|
20 | | -## Table of Contents |
| 17 | +## Demo |
21 | 18 |
|
22 | | -- [Download](#download) |
23 | | -- [Usage](#usage) |
24 | | -- [Options](#options) |
25 | | -- [Methods](#methods) |
26 | | -- [Development & Contributing](#development) |
27 | | -- [Author](#author) |
| 19 | +[http://orthes.github.io/medium-editor-insert-plugin](http://orthes.github.io/medium-editor-insert-plugin) |
28 | 20 |
|
29 | 21 |
|
30 | | -## <a name="download"></a>Download |
| 22 | +## Download |
31 | 23 |
|
32 | | -- Bower: ```bower install medium-editor-insert-plugin#^0.3 --save``` |
33 | | -- Manual: [Download as ZIP](https://github.com/orthes/medium-editor-insert-plugin/archive/0.3.2.zip) |
| 24 | +* Bower (recommended): ```bower install medium-editor-insert-plugin#^1.0 --save``` |
| 25 | +* Manual: [Download the latest release](https://github.com/orthes/medium-editor-insert-plugin/releases) |
34 | 26 |
|
35 | 27 |
|
36 | | -## <a name="usage"></a>Usage |
| 28 | +## Quick Start |
37 | 29 |
|
38 | | -The first step is to add all prerequisites (MediumEditor and jQuery): |
| 30 | +The first step is to include the plugin with all its dependencies to your code: |
39 | 31 |
|
40 | 32 | ```html |
| 33 | +<!-- CSS --> |
41 | 34 | <link rel="stylesheet" href="bower_components/medium-editor/dist/css/medium-editor.min.css"> |
42 | | -<link rel="stylesheet" href="bower_components/medium-editor/dist/css/themes/default.css"> |
43 | | -<script src="bower_components/medium-editor/dist/js/medium-editor.min.js"></script> |
44 | | -<script src="bower_components/jquery/jquery.min.js"></script> |
45 | | -``` |
46 | | - |
47 | | -Now you have two possibilites. You can load all addons at once: |
48 | | - |
49 | | -```html |
| 35 | +<link rel="stylesheet" href="bower_components/medium-editor/dist/css/themes/default.css" id="medium-editor-theme"> |
| 36 | +<!-- Font Awesome for awesome icons. You can redefine icons used in a plugin configuration --> |
| 37 | +<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> |
| 38 | +<!-- The plugin itself --> |
50 | 39 | <link rel="stylesheet" href="bower_components/medium-editor-insert-plugin/dist/css/medium-editor-insert-plugin.min.css"> |
51 | | -<script src="bower_components/medium-editor-insert-plugin/dist/js/medium-editor-insert-plugin.all.min.js"></script> |
52 | | -``` |
53 | 40 |
|
54 | | -Or if you for some reason want, you can load only addons that you want separately. In this case, don't forget to load medium-editor-insert-plugin.min.js, which is the main plugin file, that initializes addons: |
55 | | - |
56 | | -```html |
57 | | -<link rel="stylesheet" href="bower_components/medium-editor-insert-plugin/dist/css/medium-editor-insert-plugin.min.css"> |
58 | | -<script src="bower_components/medium-editor-insert-plugin/dist/js/addons/medium-editor-insert-plugin.min.js"></script> |
59 | | -<script src="bower_components/medium-editor-insert-plugin/dist/js/addons/medium-editor-insert-images.min.js"></script> |
60 | | -<script src="bower_components/medium-editor-insert-plugin/dist/js/addons/medium-editor-insert-embeds.min.js"></script> |
61 | | -<script src="bower_components/medium-editor-insert-plugin/dist/js/addons/medium-editor-insert-tables.min.js"></script> |
| 41 | +<!-- JS --> |
| 42 | +<script src="bower_components/jquery/dist/jquery.min.js"></script> |
| 43 | +<script src="bower_components/medium-editor/dist/js/medium-editor.js"></script> |
| 44 | +<script src="bower_components/handlebars/handlebars.runtime.min.js"></script> |
| 45 | +<script src="bower_components/jquery-sortable/source/js/jquery-sortable-min.js"></script> |
| 46 | +<!-- Unfortunately, jQuery File Upload Plugin has a few more dependencies itself --> |
| 47 | +<script src="bower_components/blueimp-file-upload/js/vendor/jquery.ui.widget.js"></script> |
| 48 | +<script src="bower_components/blueimp-file-upload/js/jquery.iframe-transport.js"></script> |
| 49 | +<script src="bower_components/blueimp-file-upload/js/jquery.fileupload.js"></script> |
| 50 | +<!-- The plugin itself --> |
| 51 | +<script src="bower_components/medium-editor-insert-plugin/dist/js/medium-editor-insert-plugin.min.js"></script> |
62 | 52 | ``` |
63 | 53 |
|
64 | 54 | Initialize MediumEditor as you normally would: |
65 | 55 |
|
66 | | -```html |
67 | | -<script>var editor = new MediumEditor('.editable');</script> |
| 56 | +```javascript |
| 57 | +var editor = new MediumEditor('.editable'); |
68 | 58 | ``` |
69 | 59 |
|
70 | | -Finally, you can initialize the insert plugin with images and embed addon: |
| 60 | +Finally, you can initialize the insert plugin: |
71 | 61 |
|
72 | 62 | ```javascript |
73 | 63 | $(function () { |
74 | | - $('.editable').mediumInsert({ |
75 | | - editor: editor, |
76 | | - addons: { |
77 | | - images: {}, |
78 | | - embeds: { |
79 | | - oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1' |
80 | | - }, |
81 | | - tables: {} |
82 | | - } |
83 | | - }); |
| 64 | + $('.editable').mediumInsert({ |
| 65 | + editor: editor |
| 66 | + }); |
84 | 67 | }); |
85 | 68 | ``` |
86 | 69 |
|
87 | | -After you have a working editor with the plugin, you will want to get a clean content of the editor without any additional unnecessary placeholders. This could be done by using the editor's ```serialize()``` function, which returns JSON object with elements contents. |
88 | | - |
89 | | -```javascript |
90 | | -var allContents = editor.serialize(); |
91 | | -var elContent = allContents["element-0"].value; |
92 | | -``` |
93 | | - |
94 | | -For styling the content in frontend (where it will be read only without editing posibilities) use this CSS: |
95 | | - |
96 | | -```html |
97 | | -<link rel="stylesheet" href="bower_components/medium-editor-insert-plugin/dist/css/medium-editor-insert-plugin-frontend.min.css"> |
98 | | -``` |
99 | | - |
100 | | -## <a name="options"></a>Options |
101 | | - |
102 | | -- **editor**: (MediumEditor) instance of MediumEditor |
103 | | -- **beginning**: (boolean) whether inserting at the very beginning of the editor should be possible (in other words, if the first placeholder for instering should be placed as the first element of the editor, or after the first parahraph). Default: *false* |
104 | | -- **addons**: (object) keys are names of used addons and values are objects of addons options. (NOTICE: Remember to use medium-editor-insert-plugin.all.min.js, which includes all addons, or separately load medium-editor-insert-plugin.min.js and medium-editor-insert-{ADDON-NAME}.min.js). |
105 | | - - **images**: |
106 | | - - **imagesUploadScript**: (string) relative path to a script that handles file uploads. Default: *upload.php* |
107 | | - - **imagesDeleteScript**: (string) relative path to a script that handles file deleting. Default: *delete.php* |
108 | | - - **useDragAndDrop**: (boolean) active or inactive image's drag and drop. Default: *true* |
109 | | - - **formatData**: (function (file)) function that formats data before sending them to server while uploading an image |
110 | | - - **uploadFile**: (function ($placeholder, file, that)) function uploading an image to a server |
111 | | - - **deleteFile**: (function (file, that)) function deleting an image from a server |
112 | | - - **embeds**: |
113 | | - - **urlPlaceholder**: (string) placeholder displayed when entering URL to embed. Default: *Paste or type a link* |
114 | | - - **oembedProxy**: (string) URL to oEmbed proxy endpoint, such as Iframely, Embedly or your own. You are welcome to use "http://medium.iframe.ly/api/oembed?iframe=1" for your dev and testing needs, courtesy of [Iframely](https://iframely.com). Default: none, which will make the plugin use pre-defined set of embed rules without making server calls. |
115 | | - - **tables**: |
116 | | - - **defaultRows**: (integer) default number of rows. Default: *2* |
117 | | - - **defaultCols**: (integer) default number of columns. Default: *2* |
118 | | -- **enabled**: (boolean) plugin's state: Default *true*. |
119 | | - |
120 | | - |
121 | | -## <a name="methods"></a>Methods |
122 | | - |
123 | | -- **enable**: enables the plugin. It's connected to Medium Editor's own activate function, so if the editor is activated, so is the plugin. (The plugin is enabled automatically. Use it only if you previously disabled the plugin.) |
124 | | -- **disable**: disables the plugin. It's connected to Medium Editor's own deactivate function, so if the editor is deactivated, so is the plugin. |
125 | | -- **registerAddon**: create new addon, like images or maps or embeds. Your addon object should contain `init(options)` method to initialize your addon and `insertButton` method that contains code of button in list of available addons. |
126 | | -- **getAddon**: simple getter for available addons. |
127 | | - |
128 | | -Use example: |
129 | | - |
130 | | -```javascript |
131 | | -$('.editable').mediumInsert('disable'); |
132 | | -``` |
133 | | - |
134 | | -## <a name="development"></a>Development & Contributing |
135 | | - |
136 | | -[](http://waffle.io/orthes/medium-editor-insert-plugin) |
137 | | - |
138 | | -I'm happy when you not only use the plugin, but contribute your improvements, too. First of all, go to [waffle.io](http://waffle.io/orthes/medium-editor-insert-plugin) (that's the blue icon above), |
139 | | -where you'll find list of all work, that need to be done. Feel free to grab one issue, assign it to yourself and start working. |
140 | | - |
141 | | -The plugin uses [Grunt](http://gruntjs.com/) for automating development tasks and [Bower](http://bower.io/) for package management. To install all the necessities for development run these commands: |
142 | | - |
143 | | -``` |
144 | | -npm install |
145 | | -bower install |
146 | | -``` |
147 | | - |
148 | | -These are available Grunt tasks: |
149 | | - |
150 | | -- **js**: runs jshint, uglify and copy |
151 | | -- **css**: runs compass |
152 | | -- **test**: runs jshint and qunit |
153 | | -- **watch**: watches for modifications on script/scss files and runs js/css task |
| 70 | +## [Documentation](https://github.com/orthes/medium-editor-insert-plugin/wiki) |
154 | 71 |
|
155 | | -Please, test you're code to your best knowledge, especially if you're adding new features. |
| 72 | +- [Getting Started](https://github.com/orthes/medium-editor-insert-plugin/wiki/v1.0-Getting-Started) |
| 73 | +- [Configuration](https://github.com/orthes/medium-editor-insert-plugin/wiki/v1.0-Configuration) |
| 74 | +- [Server response](https://github.com/orthes/medium-editor-insert-plugin/wiki/Server-response) |
| 75 | +- [Custom addons](https://github.com/orthes/medium-editor-insert-plugin/wiki/v1.0-Custom-addons) |
| 76 | +- [Upgrading from v0.3](https://github.com/orthes/medium-editor-insert-plugin/wiki/v1.0-Upgrading-from-v0.3) |
| 77 | +- [Versioning](https://github.com/orthes/medium-editor-insert-plugin/wiki/Versioning) |
| 78 | +- [Development & Contributing](https://github.com/orthes/medium-editor-insert-plugin/wiki/Development-&-Contributing) |
| 79 | +- [License](https://github.com/orthes/medium-editor-insert-plugin/wiki/License) |
| 80 | +- [Author & Contributors](https://github.com/orthes/medium-editor-insert-plugin/wiki/Author-&-Contributors) |
156 | 81 |
|
157 | 82 |
|
158 | | -## <a name="author"></a>Author |
| 83 | +## Sponsors |
159 | 84 |
|
160 | | -Pavel Linkesch | [@linkesch](http://twitter.com/linkesch) | http://www.linkesch.sk |
| 85 | +[creator5](http://www.creator5.com) | [Maker](http://maker.me) | [Nusii](http://nusii.com) |
| 86 | +-------- | ----- | ----- |
| 87 | +[](http://www.creator5.com) | [](http://maker.me) | [](http://nusii.com) |
0 commit comments