GithubHelp home page GithubHelp logo

springload / draftail Goto Github PK

View Code? Open in Web Editor NEW
603.0 24.0 68.0 19.19 MB

📝🍸 A configurable rich text editor built with Draft.js

Home Page: https://www.draftail.org/

License: MIT License

CSS 0.86% JavaScript 7.61% Shell 1.17% HTML 0.34% SCSS 5.78% TypeScript 84.24%
draft-js editor wagtail react wysiwyg

draftail's Introduction

npm Build status Coverage Status Netlify Status

📝🍸 A configurable rich text editor built with Draft.js. Check out our demos!

Screenshot of Draftail

Features

Draftail aims for a mouse-free, keyboard-centric experience. Here are important features worth highlighting:

  • Support for keyboard shortcuts. Lots of them!
  • Paste from Word. Or any other editor. It just works.
  • Autolists – start a line with - , * , 1. to create a list item.
  • Shortcuts for heading levels ##, code blocks ```, text formats **, and more.
  • Undo / redo – until the end of times.
  • Common text types: headings, paragraphs, quotes, lists.
  • Common text styles: Bold, italic, and many more.
  • API to build custom controls for links, images, and more.
  • Compatibility with the draft-js-plugins ecosystem to build more advanced extensions.

This project adheres to Semantic Versioning, and measures performance and code coverage. We also try to follow accessibility best practices (tested with aXe) – please get in touch if you can help us do better in this area.

Documentation

Contributing

See anything you like in here? Anything missing? We welcome all support, whether on bug reports, feature requests, code, design, reviews, tests, documentation, and more. Please have a look at our contribution guidelines.

If you just want to set up the project on your own computer, the contribution guidelines also contain all of the setup commands.

Credits

Draftail is made possible by the work of Springload. View the full list of contributors. MIT licensed. The draftail.org documentation and demos are powered by Netlify.

draftail's People

Contributors

allcaps avatar alotor avatar alvinthen avatar callmeberzerker avatar dwjohnston avatar greenkeeper[bot] avatar jacobtoppm avatar renovate-bot avatar rlingineni avatar simobasso avatar thespicymeatball avatar thi-bot avatar thibaudcolas avatar vincentaudebert 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

draftail's Issues

Add keyboard shortcuts in `title` attribute of all buttons

Use the following code to display the right shortcut.

const { isOptionKeyCommand, hasCommandModifier } = KeyBindingUtil;
const isOSX = isOptionKeyCommand({ altKey: 'test' }) === 'test';
const COMMAND_MODIFIER_CHAR = isOSX ? '\u2318' : 'Ctrl';

Add editor UI with Medium-style controls

That is:

  • No toolbar at the top of the editor. Instead,
  • Controls on the sides of the editor to add block-level formats and content blocks.
  • Inline "hover" toolbar to add inline formats and content entities.

UI audit

Below is a list of improvements that could be made to improve usability:

Small improvements:

  • Add placeholder "Type to get started" / "Start writing" (people have trouble knowing where to type).
  • [ ] Make text input area look more like a text area. #96
  • Sticky editor controls
  • [ ] naming of labels (non-dev people don't know what H3, BR etc mean.) #80
  • [ ] Bigger editor controls and more descriptive icons. #80

Bigger improvements:

  • [ ] Show hidden characters (more like indesign) so you can see if you have extra p tags etc #95
  • [ ] More obvious grouping controls into "things of can do to one word" vs "things you can do to a block of words" See #80.
  • [ ] Image / embed treatment – See #92, #93.
  • [ ] Add undo / redo – See #79.
  • [ ] Add word/character count and reading time – See #94.
  • [ ] Refresh editor design See #64.

Add example content with all of the following

  • Several different list types ie.
    • bulleted,
    • numbered,
    • action,
  • Need to be able to include document links
    • that will have pdf icon
    • and probably file size (auto generated).
  • May need location link that could have a location pin icon (needs to be inline with paragraph text most likely).
  • All the generic text elements like
    • headings,
    • paragraphs,
    • bold,
    • italics,
    • links.
  • Terms and conditions type thing…dunno if that means a muted text choice AND a small text option. or just a custom paragraph type for terms which would have both those styles attached.
  • Hr element probably needed all the time.

Feedback on editor UX

The UI and UX of the editor (see demo) as they stand are directly from initial prototypes, which could be refined a bit now that the editor's feature set is better understood. There will be ongoing work on the editor, so the point for now is to make it "good enough" that we don't feel bad about other people to start using it.

Here is a list of specific things to review:

  • Embed block behaviour (see below)
  • Image block behaviour (see below)
  • Undo/redo buttons – or the lack thereof. The default editor in Wagtail has them. Are they worth adding, or should we expect people to know the keyboard shortcuts?

Embed block behaviour

... or the lack thereof – how the block for embeds has two open/closed states even though there is nothing to act upon in the "open" state. We also do not have a way to edit an existing embed at the moment – instead, the user has to remove it, then add a new one. Would that be worth adding? How?

Image block behaviour

draftail-image-block

This is displayed within the editor's UI. There are two states as with the embed block. I'm not sure whether having explicit "Save" and "Cancel" actions in here is good – it dilutes the overall understanding of whether the editor's content is saved or not:

  • Within Wagtail, nothing is actually saved until you hit "Save draft" at the bottom of the page
  • Outside of Wagtail, there would either be a save mechanism for the whole content as well, or everything would be auto-saved on every change.

Edit: reading time? https://github.com/michael-lynch/reading-time

CSS stacking context can get complicated

At the moment, here are the layers we have in the editor, from "bottom" to top:

  • Editor content, where you type.
  • Tooltips
  • Disabled editor overlay
  • Active block (auto-closes tooltips)
  • Toolbar (sticky)
  • Dialogs that are opened from any of those.

This is starting to be a lot of stacking. To make matters even more complex,

  • Other third-party modals should be able to appear above all of those.
  • Should people want to use the editor inside of a modal, this should be supported too.

@samanthaksanders @laurarbunea do you have insights on how to keep this manageable? Just in terms of CSS, this is what I've done so far:

// All the z-index values are defined at the top as increments of one over the previous.
$editor-z-index: 1;
$tooltip-z-index: $editor-z-index + 1;
$overlay-z-index: $tooltip-z-index + 1;
$activeblock-z-index: $overlay-z-index + 1;
$toolbar-z-index: $activeblock-z-index + 1;

// [...]
// Those variables are referenced in the code where z-index is set.

Generally I have trouble with z-index, and how to manage sizes of this stack. Tips welcome!

Improve appearance of controls in the toolbar, with grouping

This is a subset of #75, with the goal of reaching feature parity with the current Wagtail editor.

Here is what we want:

hallo-target

Tasks:

  • Button styles
  • Button grouping / segmented buttons
  • More obvious grouping controls into "things of can do to one word" vs "things you can do to a block of words"
  • Bigger editor controls and more descriptive icons.
  • Naming of labels (non-dev people don't know what H3, BR etc mean.)

The button grouping is harder to solve than it might look – this target screenshot is what the most common editor will look like, but people may also have way less (or way more) of a given type of control, and we still need to ensure the toolbar looks good no matter how much screen real estate is available.

Provide default behavior for entity strategy

See also springload/wagtaildraftail#6. This is the behavior of all strategies I've used so far (check entity type only, not text patterns).

Some boilerplate:

const getEntityStrategy = (entityType) => {
    return (contentBlock, callback) => {
        contentBlock.findEntityRanges((character) => {
            const entityKey = character.getEntity();
            return (
                entityKey !== null &&
                Entity.get(entityKey).getType() === entityType
            );
        }, callback);
    };
};

Good copy/pasting support

Expected behavior

  • Flattens lists that are too nested.
  • Strip all blocks which aren't allowed in the current field – One needs to be careful when removing default blocks from the block map, and/or aliasing elements. If an element is missing, the editor will crash.
  • IMAGE entities are created, but come with an unstyled block instead of atomic. This should be normalised.
  • There is no built-in way to configure whether IMAGE and LINK are available in the first place. They should be removed if necessary (both from the block, and the entity map).
  • There is no way to customise which styles are available. Styles should be removed if necessary.

Unexpected behavior

  • Drops the style of the first block in the clipboard
  • Concatenates multiple paragraphs into one block (whitespace is missing)
  • Drops whitespace in front of text node right after inline entity
  • [ ] Be smart about pasting of uppercase text? IS SHOUTING ALLOWED? WHAT IF YOU COPY/PASTE AN H2?

Example big content to copy paste:

Editor styling

Hi Thibaud,

We are trialling Draftrail on a client website and there are a few styling issues in the admin section (when creating the content).

  • Links are not getting styled (they look exactly the same as the paragraph copy) - error in the JS may be causing this.
  • Heading styles could be bold to make the content more 'scanable'
  • T&Cs are not styled in the editor (look exactly the same as the paragraph copy)

Chat to me if you need anything else :)

Extract serialisation API

... so serialisation method is implementation-specific rather than built-in.

  • Demonstrate multiple scenarios via examples

Rename entity config attributes

  • component should be decorator (it's the component for the decorator)
  • control should be source (control is way too vague, source is vague too but still more descriptive)

Cannot remove link

Clicking on a link and then Remove has no effect.
draftail-cannot-remove-link

Uncaught TypeError: Cannot read property 'getSelectionEntity' of undefined at Object.getSelectedEntitySelection (http://localhost:8111/static/js/wagtailadmin.js:51528:35) at DraftailEditor.onRemoveEntity (http://localhost:8111/static/js/wagtailadmin.js:28267:62) at Object.ReactErrorUtils.invokeGuardedCallback (http://localhost:8111/static/js/wagtailadmin.js:6349:17) at executeDispatch (http://localhost:8111/static/js/wagtailadmin.js:6134:22) at Object.executeDispatchesInOrder (http://localhost:8111/static/js/wagtailadmin.js:6157:6) at executeDispatchesAndRelease (http://localhost:8111/static/js/wagtailadmin.js:5581:23) at executeDispatchesAndReleaseTopLevel (http://localhost:8111/static/js/wagtailadmin.js:5592:11) at Array.forEach (native) at forEachAccumulated (http://localhost:8111/static/js/wagtailadmin.js:6448:10) at Object.processEventQueue (http://localhost:8111/static/js/wagtailadmin.js:5768:8)

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.