All Projects → sofish → Pen

sofish / Pen

Licence: other
enjoy live editing (+markdown)

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to Pen

Vditor
♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
Stars: ✭ 3,773 (-20.4%)
Mutual labels:  editor, wysiwyg
Text
📑 Collaborative document editing using Markdown
Stars: ✭ 282 (-94.05%)
Mutual labels:  editor, wysiwyg
Editor
A new type of WYSIWYG editor for Kirby
Stars: ✭ 209 (-95.59%)
Mutual labels:  editor, wysiwyg
Sceditor
A lightweight HTML and BBCode WYSIWYG editor
Stars: ✭ 503 (-89.39%)
Mutual labels:  editor, wysiwyg
Re Editor
一个开箱即用的React富文本编辑器 🚀re-editor
Stars: ✭ 367 (-92.26%)
Mutual labels:  editor, wysiwyg
Flutter Quill
Rich text editor for Flutter
Stars: ✭ 177 (-96.27%)
Mutual labels:  editor, wysiwyg
Medium Editor
Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
Stars: ✭ 15,421 (+225.34%)
Mutual labels:  editor, wysiwyg
Cl Editor
Lightweight text editor built with svelte, typescript
Stars: ✭ 148 (-96.88%)
Mutual labels:  editor, wysiwyg
Hyper Editor
A backend independent visual composer for web.
Stars: ✭ 332 (-93%)
Mutual labels:  editor, wysiwyg
Awesome Web Editor
🔨 Open source WEB editor summary
Stars: ✭ 306 (-93.54%)
Mutual labels:  editor, wysiwyg
Smarteditor2
Javascript WYSIWYG HTML editor
Stars: ✭ 162 (-96.58%)
Mutual labels:  editor, wysiwyg
Draftail
📝🍸 A configurable rich text editor built with Draft.js
Stars: ✭ 413 (-91.29%)
Mutual labels:  editor, wysiwyg
Pell
📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies
Stars: ✭ 11,653 (+145.84%)
Mutual labels:  editor, wysiwyg
Tui.editor
🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
Stars: ✭ 14,016 (+195.7%)
Mutual labels:  editor, wysiwyg
Rich Markdown Editor
The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
Stars: ✭ 2,468 (-47.93%)
Mutual labels:  editor, wysiwyg
Editor.js
A block-styled editor with clean JSON output
Stars: ✭ 17,061 (+259.94%)
Mutual labels:  editor, wysiwyg
Phaser3 Particle Editor
A flexible editor for building phaser particles.
Stars: ✭ 131 (-97.24%)
Mutual labels:  editor, wysiwyg
Ngx Quill Example
demo app for the advanced usage of ngx-quill module
Stars: ✭ 137 (-97.11%)
Mutual labels:  editor, wysiwyg
React Native Rich Editor
Lightweight React Native (JavaScript, H5) rich text editor
Stars: ✭ 281 (-94.07%)
Mutual labels:  editor, wysiwyg
Grapesjs Mjml
Newsletter Builder with MJML components in GrapesJS
Stars: ✭ 379 (-92%)
Mutual labels:  editor, wysiwyg

Pen Editor


pen editor - screenshot


0. source code

You can clone the source code from github, or using bower.

bower install pen

1. installation

1.1 init with id attribute

var editor = new Pen('#editor');

1.2 init with an element

var editor = new Pen(document.getElementById('editor'));

1.3 init with options

var 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. configure

The 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 Pen constructor with an options object like #1.3: init with options:

2.1 Fallback for old browser

You can set defaults.textarea to a piece of HTML string, by default, it's <textarea name="content"></textarea>。This will be set as innerHTML of your #editor.

2.2 Change the editor class

Pen will add .pen to your editor by default, if you want to change the class, make sure to replace the class name pen to your own in src/pen.css.

2.3 Enable debug mode

If options.debug is set to true, Pen will output logs to the Console of your browser.

debugger

2.4 Customize the toolbar

You can set options.list to an Array, add the following strings to make your own:

  • blockquote, h2, h3, p, pre: create a tag as its literal meaning
  • insertorderedlist: create an ol>li list
  • insertunorderedlist: create a ul>li list
  • indent: indent list / blockquote block
  • outdent: outdent list / blockquote block
  • bold: wrap the text selection in a b tag
  • italic: wrap the text selection in an i tag
  • underline: wrap the text selection in a u tag
  • createlink: insert link to the text selection
  • inserthorizontalrule: insert a hr tag
  • insertimage: insert an image (img) tag

2.5 Add tooltips to the toolbar icons

You can set options.titles to an object with properties that match the toolbar actions. The value of each property will be used as the title attribute on the icon. Most browsers will display the title attribute as a tooltip when the mouse hovers over the icon.

options.title = {
    'blockquote': 'Blockquote'
    'createlink': 'Hyperlink'
    'insertimage': 'Image'
}

If you are using Bootstrap or jQueryUI, you can standardize the tooltip style by adding $('i.pen-icon').tooltip() to your JavaScript.

2.6 Prevent unsafe page redirect

By default, Pen will prevent unsafe page redirect when editing, to shut down it, specific options.stay to false.

NOTE: if defaults.debug is set to true and default.stay is not set: defaults.stay == !defaults.debug.

2.7 Disable and Re-enable editor

You can disable the pen editor by call destroy() method of the var pen = new Pen(options) object. like:

var pen = new Pen('#editor');

pen.destroy(); // return itself

And, there's a corresponding method called rebuild() to re-enable the editor:

pen.rebuild(); // return itself

2.8 Export content as markdown

It's an experimental feature

var pen = new Pen('#editor');

pen.toMd(); // return a markdown string

3. markdown syntax support

3.1 install

The syntax convertor will be enabled automatically by linking markdown.js after `pen.js:

<script src="src/pen.js"></script>
<script src="src/markdown.js"></script>

3.2 usage

To use it, you can type action cmd + space key at a line start. like:

### This will create a h3 tag

The following cmds are allowed:

  • Headings: type 1~6 # at the line start
  • Unordered List: type - or *
  • Ordered List: type 1.
  • Code block: type ```
  • Block Quote: type >
  • Horizontal Rule: more than 3 -, *, . will create a <hr />, like ......

4. license

Licensed under MIT.

5. trusted by *

Teambition

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].