在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):inacho/bootstrap-markdown-editor开源软件地址(OpenSource Url):https://github.com/inacho/bootstrap-markdown-editor开源编程语言(OpenSource Language):JavaScript 53.6%开源软件介绍(OpenSource Introduction):Bootstrap Markdown EditorMarkdown editor for Bootstrap with preview, image upload support, shortcuts and other features. Demo: http://inacho.github.io/bootstrap-markdown-editor/ Requirements
Features
ScreenshotInstallation with Bower
Example UsageInclude the CSS files of Bootstrap and Bootstrap Markdown Editor: <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="bower_components/bootstrap-markdown-editor/dist/css/bootstrap-markdown-editor.css" rel="stylesheet"> Include the scripts of jQuery, Ace and Bootstrap Markdown Editor. Optionally, include the script of Bootstrap to enable tooltips: <script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/ace-builds/src-min/ace.js"></script>
<script src="bower_components/bootstrap-markdown-editor/dist/js/bootstrap-markdown-editor.js"></script> Create a textarea for the editor with optional content in markdown format: <textarea name="text" id="myEditor"># Test</textarea> Initialize the editor: $('#myEditor').markdownEditor(); Implementing the previewYou have to implement the parsing of the Markdown. $('#myEditor').markdownEditor({
// Activate the preview:
preview: true,
// This callback is called when the user click on the preview button:
onPreview: function (content, callback) {
// Example of implementation with ajax:
$.ajax({
url: 'preview.php',
type: 'POST',
dataType: 'html',
data: {content: content},
})
.done(function(result) {
// Return the html:
callback(result);
});
}
}); Implementing the image uploadYou have to implement the server side part of the upload process. $('#myEditor').markdownEditor({
imageUpload: true, // Activate the option
uploadPath: 'upload.php' // Path of the server side script that receive the files
}); In your server side script you have to return an array of the public path of the successfully uploaded images in json format. Example in PHP: $uploadedFiles = array();
if (! empty($_FILES)) {
foreach ($_FILES as $file) {
if (superAwesomeUploadFunction($file)) {
$uploadedFiles[] = '/img/' . urlencode($file['name']);
}
}
}
echo json_encode($uploadedFiles); Response example:
ShortcutsThe following shortcuts are available.
Plugin documentationOptionsThe following options can be passed as an object at the initialization of the plugin: $('#myEditor').markdownEditor({
// Options
}); Also, you can override the plugin default options. Example: $.fn.markdownEditor.defaults.width = '250px'; widthType: string The width of the editor heightType: string The height of the editor fontSizeType: string The font size of the editor themeType: string The theme of the editor. See the available themes at the homepage of Ace (http://ace.c9.io) softTabsType: boolean Pass false to disable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character ('\t') fullscreenType: boolean Enable / disable fullscreen imageUploadType: boolean Enable / disable the upload of images. If enabled, you have to specify the option uploadPathType: uploadPath The path of the server side script that receives the images. The script has to return an array of the public path of the successfully uploaded images in json format. previewType: boolean Enable / disable the preview. If enabled, you have to specify the option onPreviewType: function function (content, callback) {
callback(content);
} This callback is called when the user clicks on the preview button and has two parameters: labelType: object Default: {
btnHeader1: 'Header 1',
btnHeader2: 'Header 2',
btnHeader3: 'Header 3',
btnBold: 'Bold',
btnItalic: 'Italic',
btnList: 'Unordered list',
btnOrderedList: 'Ordered list',
btnLink: 'Link',
btnImage: 'Insert image',
btnUpload: 'Uplaod image',
btnEdit: 'Edit',
btnPreview: 'Preview',
btnFullscreen: 'Fullscreen',
loading: 'Loading'
} This object contains the strings that can be translated MethodsThe methods are invoked passing the name of the method as string. var content = $('#myEditor').markdownEditor('content'); // Returns the content of the editor
$('#myEditor').markdownEditor('setContent', content); // Sets the content of the editor LicenseLicensed under MIT (https://github.com/inacho/bootstrap-markdown-editor/blob/master/LICENSE). Authors |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论