Giter Club home page Giter Club logo

polymer-quill's Introduction

Published on webcomponents.org Build Status

<polymer-quill>

Polymer 2.x Quill Rich Text Editor (does not work Polymer 1.x)

WIP progress converting to pure Polymer 2.x. It requires support by Quill to support ShadowDOM see Quill pr: slab/quill#1805. Once this is working this should work.

Status:

[x] Display content works [x] Demos selecting and display content [] Snow: changing formats does not work [] Bubble: popup menu does not work, so no chaning formating

  • <polymer-quill> element creates a Polymer Quill Rich Text Editor using the Snow Theme.
  • <polymer-quill-bubble> element creates a Polymer Quill Rich Text Editor using the Bubble Theme (popup toolbar like Medium).
  • <polymer-quill-bubble-firebase> element creates a Polymer Quill Rich Text Editor using the Bubble Theme using Firebase (popup toolbar like Medium).
  • <polymer-quill-html-render> element creates a Polymer Quill HTML Render

Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need. Learn more at http://quilljs.com/

Screenshot Snow Theme

polymer-quill screenshot

<polymer-quill content="Hello World"></polymer-quill>
<polymer-quill-bubble content="Hello World (click text to see toolbar)" show-results></polymer-quill-bubble>    
<polymer-quill-html-render content='<h2 class="ql-align-center">Hello World</h2>'></polymer-quill-html-render>

Demo and API docs

If your are viewing this from webcomponents.org, use the below links for API and demos, not the links on right sidebar.

Examples

Defaults (stores as Deltas every 2 seconds, does not show results, 50px height)

<polymer-quill content="Hello World"></polymer-quill>

Defaults (stores as Deltas every 2 seconds, does not show results, 50px height)

<polymer-quill-bubble content="Hello World (click text to see toolbar)"></polymer-quill-bubble>    

Custom (stores as HTML every 5 seconds, show results)

<polymer-quill content="Hello World" store-as="html" store-interval="5000" show-results></polymer-quill>

Custom (stores as HTML every 5 seconds, show results)

<polymer-quill-html-render content="<h2 class="ql-align-center">Hello World</h2>"></polymer-quill-html-render>

Demo example

<style is="custom-style">
  polymer-quill.full {
    --polymer-quill-editor-max-height: 300px;
    --polymer-quill-editor-min-height: 100px;
  }
</style>
<h2>Full Toolbar, Show Results, Max Height (300px), Min Height (100px), Save as Deltas, Save every 1 second</h2>
<polymer-quill content='{"ops":[{"insert":"Hello World! - Store as Delta"},{"attributes":{"header":2},"insert":"\n"}]}'
  class='full'
  store-as="delta"
  save-interval="1000"
  toolbar-type="full"
  show-results>
</polymer-quill>
<h2>Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save every 2 seconds</h2>
<polymer-quill content="<h2>Hello World! - Store as HTML</h2>" store-as="html"></polymer-quill>

Styling

The following custom properties and mixins are available for styling. This allows the editor auto grow to the max-height.:

polymer-quill (Snow theme)

Also had to make editor have padding-bottom: 50px to have link popup show.

Custom property Description Default
--polymer-quill-editor-max-height Custom max-height for editor 400px
--polymer-quill-editor-min-height Custom max-height for editor 50px
--polymer-quill-editor-overflow Custom overflow for editor scroll
--polymer-quill-editor-border Custom min-height for editor solid 1px #ccc
--polymer-quill Mixin applied to the editor {}

Below is example of setting the editor to max-height of 260px less then the viewport height and min-height of 150px. So any content greater then the max-height with scroll otherwise it will auto grow.

polymer-quill {
  --polymer-quill-editor-max-height: calc(100vh - 260px);
  --polymer-quill-editor-min-height: 150px;
  max-width: 870px;
  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
  padding: 0;
  margin-left: auto;
  margin-bottom: 5px;
  margin-right: auto;
  border-radius: 5px;
  background-color: #fff;
  color: #212121;
}

polymer-quill-bubble (Bubble theme)

Max-height needs to be set for bubble popup toolbar to work with is default. Also had to make editor have padding-bottom: 50px so toolbar displays for last line.

Custom property Description Default
--polymer-quill-editor-max-height Custom max-height for editor auto
--polymer-quill-editor-min-height Custom min-height for editor 50px
--polymer-quill-editor-overflow Custom overflow for editor scroll
--polymer-quill-editor-border Custom min-height for editor solid 1px #ccc
--polymer-quill Mixin applied to the editor {}

Install

bower install --save polymer-quill

Polymer Starter Kit 2

If you are using Polymer Starter Kit 2 or like as the bases of your app you will need to change dom: 'shadow' to dom: 'shady' like below. Otherwise the Polymer Quill Editor will not display.

  // Setup Polymer options
  window.Polymer = {
    dom: 'shady',
    lazyRegister: true
  };

License

The MIT License (MIT)

Copyright (c) 2016 Chuck Horton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

open source initiative

polymer-quill's People

Contributors

chuckh avatar danielhmarinho avatar marcus7777 avatar

Watchers

James Cloos avatar Arthur Jahn Sturzbecher avatar David Carlos de Araujo Silva avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.