Skip to content
Snippets Groups Projects
  1. Jan 28, 2017
  2. Jan 27, 2017
  3. Dec 21, 2016
  4. Dec 20, 2016
  5. Dec 16, 2016
  6. Dec 15, 2016
  7. Dec 14, 2016
  8. Dec 11, 2016
  9. Dec 10, 2016
    • Flarnie Marchan's avatar
      Change underscore method names to bypass lint about private methods (#858) · 19172635
      Flarnie Marchan authored
      Private methods should not be called as public methods. A recent PR
      (https://github.com/facebook/draft-js/pull/814) added warnings to the
      public-but-deprecated API of DraftEntity, and then moved the logic for
      those methods into private methods that can be called within the
      Draft.js framework.
      
      These methods are "private" in the sense that we are only calling them
      within Draft. They should not be used outside of the Draft library,
      because they will be removed in an upcoming version of the library.
      
      We have a transform step that causes issues when an underscore-prefixed
      method is called outside of it's module, so changing the method names
      seems like the easiest way to deal with this issue and still send the
      message that they are private.
      
      There is a way to turn off the transformation step on a file-by-file
      basis but that would lead to touching more files than this approach, and
      this code will be deprecated in the next release anyway.
      19172635
    • Flarnie Marchan's avatar
      Fix lints and flow errors for v0.10 (#856) · 429592c3
      Flarnie Marchan authored
      * Fix trailing comma lints
      
      I'm not sure why ESLint didn't catch these at some point on Github - but
      in any case we are fixing it now.
      
      I ran the `trailing-commas.js` js-codemod and it only touched one file
      for some reason. Probably I missed something about the jscodeshift API.
      In any case, I fixed the other lints that our internal linter was
      catching.
      
      * Use DraftEntity type instead of EntityMap type in helpers
      
      While supporting both the old and new APIs in Draft.js for Entity
      manipulation, we are calling to the old DraftEntity module under the
      hood instead of using the new system that would use an Immutable.js
      OrderedMap called the EntityMap.
      
      The DraftEntity module now has private methods for entity manipulation
      that don't warn, and the public API which we are deprecating has
      warnings and then calls the private methods.
      
      In short, there are places where the flow typing wasn't right because
      it was expecting EntityMap, and not DraftEntity.
      
      I don't know why flow didn't catch this when we merged
      https://github.com/facebook/draft-js/pull/814
      
      test plan: `flow src`
      
      * Fix flow error caused by passing command to RichUtils.handleKeyCommand
      
      The 'handleKeyCommand' takes either a 'DraftEditorCommand' type or any
      string.  This allows users to have their own custom editor command
      types. I'm not sure how common this is, but our current flow typing
      allows it.
      
      The flow typing of 'RichUtils.handleKeyCommand' is more strict - it only
      allows 'DraftEditorCommand' types, and not custom strings. This causes
      an issue in one of our use cases, where we pass the 'command' received
      in 'handleKeyCommand' through to 'RichUtils.handleKeyCommand'.
      
      It seems like the 'RichUtils.handleKeyCommand' should have an API
      similar to 'DraftEditor.handleKeyCommand', and so we're loosening the
      flow type on 'RichTuils.handleKeyCommand'.
      
      Test Plan: `flow`
      
      * Fix flow error with DraftEditor.setClipboard
      
      This was causing flow errors in our internal code because we expect that
      'null' or 'undefined' is ok as an argument to 'setClipboard'.
      
      Test Plan: `flow src`
      
      * Fix flow and lint errors in CharacterMetadata
      
      Again - I'm not sure why the github CI didn't catch these issues
      earlier. I wonder if the issue with the typing of Immutable.OrderedMap
      relates to the version of Immutable.js we are using or something.
      429592c3
  10. Dec 09, 2016
  11. Dec 06, 2016
    • Ben Alpert's avatar
      Fix flow (#848) · a1817a72
      Ben Alpert authored
      My slip.
      a1817a72
    • Ben Alpert's avatar
      Fix modifying state during onChange triggered by beforeinput (#667) · 07892ba4
      Ben Alpert authored
      Fixes #92.
      
      If an onChange handler replaces every "x" with an "abc", then when you type "x", we trigger onChange from beforeinput and rerender immediately with the content "abc", then the browser still inserts an "x" character!
      
      This fix is surprisingly simple: instead of triggering an update during beforeinput, we simply wait until the input event to do so. This means that when we rerender, the browser would have already inserted the "x" character and React will correctly delete it when rerendering.
      
      Test Plan: In plaintext example, change the handler to
      
      ```
      this.onChange = (editorState) => {
        var content = editorState.getCurrentContent();
        return this.setState({
          editorState: EditorState.set(editorState, {
            currentContent: Modifier.removeInlineStyle(content, content.getSelectionAfter(), 'OVERFLOW');
          }),
        });
      };
      ```
      
      then type. Characters don't get duplicated like they did before.
      07892ba4
  12. Dec 04, 2016
    • Flarnie Marchan's avatar
      Part two deprecate but dont delete old entity api (#814) · 99bf098b
      Flarnie Marchan authored
      * Add warnings and comments about deprecating old Entity API
      
      We are deprecating the old DraftEntity API.
      
      Why? Because
       - currently changing or adding entities won't trigger a re-render
       - the use of a non-Immutable storage for entities doesn't fit well with
         the rest of the Draft architecture
       - moves Entity storage out of global module; this just makes more sense
         as an API, rather than having it globally available.
      
      This moves the logic for the old API into private methods, and adds
      warnings and comments around the public-but-deprecated API methods.
      
      We then use the private methods internally while we still support both
      APIs.
      
      A future version of Draft will actually remove the old API completely,
      and these warnings and comments will help folks make updates to their
      code to prepare.
      
      We will release more documentation about this soon.
      
      * Update syntax of tex example
      
      This example was still using the old syntax, and the new warnings we
      added alerted us to this fact when doing manual testing.
      99bf098b
    • Flarnie Marchan's avatar
      Make contentState.createFromBlockArray work with old and new API (#838) · 2dfea2a6
      Flarnie Marchan authored
      As part of the changing API the signature of
      contentState.createFromBlockArray changed.
      
      At some point (recently I think) this was changed to no longer support
      the old API, and we didn't quite have the 0.9.1 style examples in place,
      so it wasn't caught.
      
      This adjusts the 'createFromBlockArray' to work with both the old and
      new APIs.
      2dfea2a6
  13. Dec 03, 2016
  14. Dec 02, 2016
    • Tobias Andersen's avatar
      Add convertToHTML example for version 0.9.1 (#833) · 6c6946b9
      Tobias Andersen authored
      * Add convertFromHTML example for 0.9.1
      
      * Update docs with convertFromHTML example
      
      * Remove image from convertFromHTML example in 0-9-1
      
      * Update 0.9.1 convertFromHTML example to use the old Entity API
      
      * Fix link to convertToHTML example in docs
      6c6946b9
    • Tobias Andersen's avatar
      Add deprecated examples (#824) · b17eb8bb
      Tobias Andersen authored
      * Move current examples into draft-0-10-0 dir
      
      * Add examples for version 0.9.1 into draft-0-9-1 dir
      
      * Use unminified version of react in all examples
      
      * Update file paths for examples
      
      * Update paths in gitignore, 'tex' package.json, and draftjs docs
      
       - updates the .gitignore to ignore node_modules in both the new
         locations of the 'tex' example
       - updates a path in the script used for the draft js docs website,
         which pulls styles from the 'rich' example for some reason
       - updates the path for 'npm install' in the 'tex' examples
       - updates all links in the markdown used to generate the draft js docs.
      b17eb8bb
  15. Nov 29, 2016
    • Ben Alpert's avatar
      Fix merge conflict from #740 and #820 · bd3eefaa
      Ben Alpert authored
      bd3eefaa
    • Ben Alpert's avatar
      Change handlers to pass `editor` as an argument (#740) · e64c2c3f
      Ben Alpert authored
      * Change handlers to pass `editor` as an argument
      
      This allows Flow to type them better and catch bugs.
      
      * Fix Flow errors exposed by added types
      
      No behavior change.
      e64c2c3f
    • Ben Alpert's avatar
      Improve typing in Korean on Windows (#820) · d1d3defb
      Ben Alpert authored
      (Landed at Facebook as D4056089 over a month ago, copying back out.)
      
      Summary:
      If we have a state update enqueued but the rerender hasn't happened, and a select event comes in, we can't do anything useful with it because although we could compare the last rendered editor state with the DOM selection, we can't make a rational choice for how to update the latest queued editor state with the DOM selection. (Previously, this code was throwing away any content change which would lead to a loss of inserted chars in many Windows IME scenarios.)
      
      In particular, if you type in Korean w/ Windows IME then press space,
      
      * compositionend arrives, causing us to set a 20ms timeout for resolving the composition,
      * at that time, the text is already inserted in the DOM
      * then keydown 32 comes in, which (due to my recent changes) makes the composition resolve immediately
      * we enqueue a rerender with the composed text
      * our 'select' polyfill also turns the keydown into a select event, and that select event has the *new* cursor position corresponding to the text that is already inserted to the DOM
      
      Basically, the DOM has 안녕하세요, the last editorstate is "" with selection [0, 0], the queued editorstate is "안녕하세요" with selection [5, 5], and you get a selection event [5, 5].
      
      Since there's nothing useful we can do with this, we now ignore the selection event. The risk here is that we now are ignoring important selection events and the editor state selection lags behind the DOM selection. isaac and I don't know of any scenarios in which this would matter -- if we do find some, we might be able to instead change this code to re-check the selection after a rerender to make sure that we have the latest selection.
      
      Test Plan:
      Type dkssudgktpdy then Space with Korean keyboard on Windows Chrome, Windows Firefox, Windows IE, Windows Edge, Mac Chrome, Mac Firefox. It either does the right thing (inserting "안녕하세요 ") or it does the same thing as cstools which doesn't have any of my changes from this week.
      
      Type normally, move the cursor, select all, copy, backspace, repeated backspace in the same browsers.
      d1d3defb
    • Iroshan Vithanage's avatar
      Added code syntax to `\n` (#817) · 104f66e2
      Iroshan Vithanage authored
      104f66e2
  16. Nov 28, 2016
    • Flarnie Marchan's avatar
      Deprecate DraftEntity before removing (#790) · 0cf448ef
      Flarnie Marchan authored
      A previous PR had completely removed 'DraftEntity' the module and moved
      control over entities into ContentState.[1] This changed several public
      APIs of Draft.js in a non-backwards compabible way.
      
      [1]: https://github.com/facebook/draft-js/pull/376
      
      To make it easier to migrate multiple use cases to the new Draft.js API,
      and because the transition is too complex for a simple codemod, we are
      releasing a version that supports both the new and the old API and then
      later releasing a version that breaks the old API completely.
      
      In order to renew support for the old API while also supporting the new
      API, this PR
       - restores the DraftEntity module and associated tests/mocks
       - calls into DraftEntity methods under the hood of the new API
      
      We tried to leave as much of the new API code in place and unchanged as
      possible, so that things will be easier when we are fully removing
      DraftEntity and switching to the new approach.
      
      Next steps:
       - A PR to add warnings and comments about the deprecation of the old
         API
       - Add this, the warnings, and other recent PRs to 0.10.0 alpha version
       - Add documentation about migrating from deprecated to new API
       - Release 0.10.0; support both APIs
       - Make PR that basically undoes this one, moving entity control into
         ContentState, and release that as version 0.11.0, with warning that
         it no longer supports the deprecated API.
      0cf448ef
  17. Nov 27, 2016
  18. Nov 26, 2016
  19. Nov 23, 2016
  20. Nov 22, 2016
  21. Nov 16, 2016
  22. Nov 09, 2016
  23. Nov 08, 2016
    • Stefan Theard's avatar
      Include reference to example for convertFromHTML · ef5569e2
      Stefan Theard authored
      This doc page is the first place people find when looking for information on convertFromHTML but the original code sample is not very useful. This hopefully will give people a better idea of how to use the function and then a reference to where I found the code snippet.
      
      Should close #236 as well.
      ef5569e2
  24. Nov 04, 2016
Loading