在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sofish/pen开源软件地址(OpenSource Url):https://github.com/sofish/pen开源编程语言(OpenSource Language):JavaScript 66.7%开源软件介绍(OpenSource Introduction):Pen Editor
0. source codeYou can clone the source code from github, or using bower.
1. installation1.1 init with id attributevar editor = new Pen('#editor'); 1.2 init with an elementvar editor = new Pen(document.getElementById('editor')); 1.3 init with optionsvar options = {
editor: document.body, // {DOM Element} [required]
class: 'pen', // {String} class of the editor,
debug: false, // {Boolean} false by default
textarea: '<textarea name="content"></textarea>', // fallback for old browsers
list: ['bold', 'italic', 'underline'], // editor menu list
linksInNewWindow: true // open hyperlinks in a new windows/tab
}
var editor = new Pen(options); 2. configureThe following object sets up the default settings of Pen: defaults = {
class: 'pen',
debug: false,
textarea: '<textarea name="content"></textarea>',
list: [
'blockquote', 'h2', 'h3', 'p', 'insertorderedlist', 'insertunorderedlist',
'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink'
],
stay: true,
linksInNewWindow: false
} If you want to customize the toolbar to fit your own project, you can instanciate 2.1 Fallback for old browserYou can set 2.2 Change the editor classPen will add 2.3 Enable debug modeIf 2.4 Customize the toolbarYou can set
2.5 Add tooltips to the toolbar iconsYou can set options.title = {
'blockquote': 'Blockquote'
'createlink': 'Hyperlink'
'insertimage': 'Image'
} If you are using Bootstrap or jQueryUI, you can standardize the tooltip style by adding 2.6 Prevent unsafe page redirectBy default, Pen will prevent unsafe page redirect when editing, to shut down it, specific NOTE: if 2.7 Disable and Re-enable editorYou can disable the pen editor by call var pen = new Pen('#editor');
pen.destroy(); // return itself And, there's a corresponding method called pen.rebuild(); // return itself 2.8 Export content as markdownIt's an experimental feature var pen = new Pen('#editor');
pen.toMd(); // return a markdown string 3. markdown syntax support3.1 installThe syntax convertor will be enabled automatically by linking <script src="src/pen.js"></script>
<script src="src/markdown.js"></script> 3.2 usageTo use it, you can type
The following cmds are allowed:
4. licenseLicensed under MIT. 5. trusted by * |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论