Draft-js: isSoftNewlineEvent is not available in exports

Created on 27 Mar 2019  路  6Comments  路  Source: facebook/draft-js

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Currently I have to do the following to use isSoftNewlineEvent:

import isSoftNewlineEvent from 'draft-js/lib/isSoftNewlineEvent';

What is the expected behavior?
I should be able to use this function like so:

import { isSoftNewlineEvent } from 'draft-js';

or
it should be attached to RichUtils,

import { RichUtils } from 'draft-js';
...
RichUtils.isSoftNewlineEvent(...);

or KeyBindingUtil

import { KeyBindingUtil } from 'draft-js'
...
KeyBindingUtils.isSoftNewlineEvent(...);
enhancement

All 6 comments

I created a pull request here: https://github.com/facebook/draft-js/pull/2045
Let me know if anything else is needed. Thanks!

I've had to do the exact same thing in my editor to build newline handling that's more advanced than the built-in behavior, using isSoftNewlineEvent in combination with RichUtils.insertSoftNewline, so would really welcome that change as well.

KeyBindingUtil does sound like the right place for this to be, as it inspects a keyboard event like all of the other functions there.

It also appears that I'll need to update @types/draft-js? I'm unsure if I need to do this?

Hey @khawkinson, thanks for bringing up this limitation and proposing a fix. I don't see any reason against exporting this module. Let's follow up on the PR, where I see @thibaudcolas has initiated a code review.

It also appears that I'll need to update @types/draft-js? I'm unsure if I need to do this?

Yes, that's highly desirable if you want to make your change consumable by typescript users.

Cool thank @claudiopro ! I created a PR there: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/34307

Closing since he PR landed

Was this page helpful?
0 / 5 - 0 ratings