Giter Club home page Giter Club logo

typecode / typester Goto Github PK

View Code? Open in Web Editor NEW
42.0 12.0 2.0 7.28 MB

:black_nib: A WYSIWYG that gives you predictable and clean HTML

Home Page: https://typecode.github.io/typester/

JavaScript 92.94% CSS 1.64% HTML 5.33% Shell 0.09%
wysiwyg wysiwyg-editor wysiwyg-js-editor javascript npm yarn es6 awesome clean html html-editor rich-text-editor awesome-editor awesome-text-editor text-editor medium-editor html-text-editor js-text-editor javascript-text-editor typester

typester's Introduction

A simple to use WYSIWYG text editor inspired by Medium and Medium Editor that gives you clean and predictable HTML from your user's input.

  • Single file import (batteries included): No need to import separate stylesheets and additional dependencies. Typester comes with everything it needs rolled into one JS file.
  • Engineered for modern JS modules Typester has been created using ES6+ JavaScript module patterns which means you need only import it and instantiate it. If you still prefer <script> imports that's fine too Typester will bind itself to the global scope allowing you to new window.Typester({ /* options */ }).
  • Minimal DOM footprint It wont clutter your beautifully laid out markup with multiple DOM injections for each editor instance. Need multiple editors on a single page? No problem, typester will inject single instances of its DOM requirements which will be shared between the editors.
  • Pure XSS-free DOM powered by DOMPurify Typester, thanks to the awesome power of DOMPurify, will make sure that the HTML you receive is sanitized against XSS exploits.

Try out the DEMO


Installation

Right now Typester is only available via npm. We may look into offering CDN hosted options and/or downloadable and self-hostable options. But, for now, you can:

npm install typester-editor

or for the yarn folks:

yarn add typester-editor --save

Usage

Setting up Typester on your page is as easy as:

import Typester from 'typester-editor'

const typesterInstance = new Typester({ el: document.querySelector('[contenteditable]') }) // Where document.querySelector(...) is a single DOM element.

// If you need to tear down for any reason:
typesterInstance.destroy();

Configuration

You can configure the formatters available for a specific typester instance in two ways:

  1. When you instatiate a Typester instance via the custom configs option:
new Typester({
    el: document.querySelector('[contenteditable]'),
    configs: {
        toolbar: {
            buttons: ['bold', 'italic', 'h1', 'h2', 'orderedlist', 'unorderedlist', 'quote', 'link']
        },

        styles: {
          colors: {
            flyoutBg: 'rgb(32, 31, 32)',
            menuItemIcon: 'rgb(255, 255, 255)',
            menuItemHover: 'rgb(0, 174, 239)',
            menuItemActive: 'rgb(0, 156, 215)'
          }
        }
    }
});
  1. By using a data attribute on the editable container
<div contenteditable='true' data-toolbar-buttons='["bold", "italic", "h1", "h2", "orderedlist", "unorderedlist", "quote", "link"]'></div>

The options available for the toolbar buttons are:

  • Inline formatters: bold, italic
  • Headers: h1, h2, h3, h4, h5, h6
  • Lists: orderedlist, unorderedlist
  • Blockquotes: quote
  • Links: link

License

Typester is released under the MIT license.

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.


Contributing

If you want to contribute to this project we welcome your input.

You can either:

  • Submit an issue / feature request which would help us greatly in figuring out what all this package needs to do
  • Resolve an already listed issue
  • Submit a tweak or new feature

Submit an issue / feature request

Please feel free to head over the our Issues page and submit your issue / feature request.

Resolve an issue / submit a tweak or new feature

  1. Fork this repo
    1. See below for instructions on how to setup local dev
  2. Create your feature branch (git checkout -b new-awesome-feature)
  3. Make sure all tests pass
    1. If you have added a new feature, make sure there is a test for it
    2. Run the following: ~> yarn test_unit (for unit tests) & ~>yarn test_e2e (end-to-end tests)
    3. If you have changed the codebase in a way that requires the tests to be updated please do so.
  4. Update the documentation if you've added any publicly accessible methods or options.
  5. Commit your changes as you would usually (git add -i, add changes, git commit -m "Succinct description of change")
  6. Push to your feature branch (git push origin new-awesome-feature)
  7. Create a new pull request.

Setup local dev environment

Install all the node modules

~> yarn

Run build scripts

For a one time build

~> yarn build

For a continuous reactive build that watches for changes

~> yarn watch

Run the dev server

~> yarn dev-server

You should then be able to navigate your browser to:

http://localhost:9000

Run the tests

Make sure you build first

Unit tests (Karma & Jasmine)

~> yarn test_unit

e2e tests (nightwatch)

~> yarn test_e2e

all tests (unit & e2e)

~> yarn test

Build and read the developer docs

For a once off build:

~> yarn docs

For a continuous file change reactive build

~> yarn docs_watch

Then, to read the docs:

~> yarn docs_server

And point you browser to:

http://localhost:9001

typester's People

Contributors

fredevery avatar levkanter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typester's Issues

Toggling lists breaks

Selection.js:636 Uncaught DOMException: Failed to execute 'setStart' on 'Range': The offset 4294967290 is larger than the node's length (26).
    at Context.selectByCoordinates

Content alignment options

Not sure if it is on the roadmap or not, but wondered if content alignment (left, right, centered, justified) and control over what options were shown was on the cards?

ShadowDom

Hello,
it seems typester doeasn't play well with ShadowDom. Do you have tested it with shadowdom ?
i've build a small sample https://stackblitz.com/edit/lit-demo-typester
When you select text it throw an error.
Let me know if i "can" help you, i'll like to get it worked.
thx

Shortcut keys

Investigate implementing shortcut keys to do quick formatting, i.e. ctrl+alt+1 for h1 etc.

People > inputting information into Board Info fields does not change anything on detail pages or previews

entering information on Board members into the Board Info fields—Company, Company Title, and Board—does not change anything on the bio detail pages or on the People page.

Image
to get anything to appear on the preview and detail pages, we have to fill in these fields that should apply only to the Student Advisory Council

Image
to get "Chair" and other titles to appear on the People page, we have to fill in "School Name" in Student Advisory info

FE > Metadata

It looks like no metadata for search engines or social media or even page title are appearing in the yet. Obviously, this is just a bug/oversight, but can we please get this data pushed into head? Also, please let me know when this is done since I need it for the GA integration.

Huge thanks!

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.