GithubHelp home page GithubHelp logo

ralphtq / elm-rte-toolkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mweiss/elm-rte-toolkit

0.0 0.0 0.0 2.55 MB

A toolkit for creating rich text editors in Elm

Home Page: https://mweiss.github.io/elm-rte-toolkit/

License: BSD 3-Clause "New" or "Revised" License

Shell 0.01% JavaScript 2.34% Elm 97.65%

elm-rte-toolkit's Introduction

Rich Text Editor Toolkit

Create rich text editors in Elm.

Rich Text Editor Toolkit is an open source project to make cross platform editors on the web. This package treats contenteditable as an I/O device, and uses browser events and mutation observers to detect changes and update itself. The editor's model is defined and validated by a programmable specification that allows you to create a custom tailored editor that fits your needs.

This package was heavily inspired by other rich text editor frameworks like ProseMirror, Trix, and DraftJS.

Resources

Getting started

This package requires some webcomponents to get started.

If you can support ES6, you can include js/elmEditor.js in your project and import it along with your favorite webcomponent polyfill.

import '@webcomponents/webcomponentsjs/webcomponents-bundle.js'
import 'elmEditor.js'

The demo in this repository does it that way.

However, if you want to use a bundler and polyfill, you can import your favorite polyfill and import the npm package that has this repository's js compiled to es5 with npm, e.g:

npm install --save @webcomponents/webcomponentsjs
npm install --save elm-rte-toolkit

And in your javascript, you can import it like so:

import '@webcomponents/webcomponentsjs/webcomponents-bundle.js'
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'
import 'elm-rte-toolkit';

Starting CSS

You can use whatever styles you want for the editor, but you may want to use the following as a jumping off point. Most importantly, you'll probably want white-space: pre-wrap; to distinguish between multiple spaces:

.rte-main {
    text-align: left;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.rte-hide-caret {
    caret-color: transparent;
}

Contributing

This package is open-source software, freely distributable under the terms of an BSD-3-Clause license. The source code is hosted on GitHub.

Contributions in the form of bug reports, pull requests, or thoughtful discussions in the GitHub issue tracker are welcome. Please see the Code of Conduct for our pledge to contributors.

Running the demo

The demo was bootstrapped with create-elm-app. See that repository for instructions of how to install the elm-app command.

To debug the demo locally, run the following from the repository's root directory:

cd demo
elm-app start

To build the demo, run the following from the repository's root directory:

cd demo
./build.sh

The demo is hosted with gh-pages, so to update the demo, please update the gh-pages branch with the latest build.

Running tests

For now, because of mysterious package issues with elm-test I don't want to debug, tests for the package are in the demo app folder. To run tests:

cd demo
elm-test

elm-rte-toolkit's People

Contributors

mweiss avatar dependabot[bot] avatar lenards avatar rjdellecese avatar abradley2 avatar matsjoyce 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.