yeditor
v1.0.1
Published
Front-end editor for web page
Downloads
2
Readme
Yeditor
Front-End Editor for web page
npm
$npm install yeditor --save
Init
Add Yeditor file into your html file
<head>
<link rel="stylesheet" href="Yeditor.min.css" />
<script src="Yeditor.min.js"></script>
</head>
Yeditor includes two parts:
- Main function
- Editable elements
Main function
Initialize Yeditor (add Element prototype and plugin navigations)
var Editor = new Yeditor({
// OPTIONS
});
Options
openNavigation: (Boolean) (default: true) - if the main navigation is open in the begining
uploadImage: (function) (defalut: null) - when the user using images (as backgound or image) what to do with the src (image url) ? if this value is empty (null) - the src will be base64 data url. but if do you want to upload the image to your server and get the url from there, use this function see example below:
uploadImage: function(file, callback){
// Demo jquery ajax
// send the @file
<SEND THE @FILE TO YOUR SERVER>.then(function(url){
// the server response is the file url
// call to @callback fn with @url as argument
callback(url);
});
}
url: (String) (default: null) - the ajax url (for save function) - if this value is empty (null) the save button will stay hidden and dont show up
method: (String) (default: 'POST') the ajax request method
done: (Function) (defalut: null) the ajax requset done status
success: (Function) (defalut: null) the ajax requset success status
failed: (Function) (defalut: null) the ajax requset failed status
navMainOrder: (Array) (defalut: null) the order of main navigation button the order is by buttons name (use navigation api), (optional: insert html into the navigation). see example below:
// regular order
navMainOrder: ['button 1', 'button 2']
// with html
navMainOrder: ['button 1', 'button 2', ['<span>THE HTML NEED TO BE INSIDE ARRAY</span>'], 'button 3']
** IMPORTANT **
You must use in the button name for this options,
get all the navigation buttons name by using the api
navImageOrder: the order of image navigation - use it same as navMainOrder
navBackgroundOrder: the order of background navigation - use it same as navMainOrder
Editable function
For editing Element:
// element
var title = document.getElementById('title');
// edit
title.editable({
// OPTIONS
});
Options
- name: (String) (default: null) the name of the editable element. the name is 'key', the 'value' = this element content, for ajax request - sending it to the server