jchen42703 / translator-app

Web app for editing machine translations efficiently. [WIP]
Apache License 2.0
1 stars 0 forks source link

Align Paragraphs Feature #22

Closed jchen42703 closed 3 years ago

jchen42703 commented 3 years ago

Closes #2 Feature that allows collapsible paragraphs.

Design Choices

jchen42703 commented 3 years ago

Potential issue: DisplayBlock's keys are based on uuid which produces a different key on each render..? This can cause unnecessary re-renders since the props change.

jchen42703 commented 3 years ago

Next steps:

  1. Make LineGutter and DisplayGutter full of buttons that can collapse the text.
  2. Sync up the collapse state between corresponding EditorBlocks and DisplayBlocks
  3. Write the css for collapsing and make it smooth
  4. Create a multi-select mode.
jchen42703 commented 3 years ago
  const getKeyList = () => {
    const blocksList = props.editorState.getCurrentContent().getBlocksAsArray();
    for (let i = 0; i < blocksList.length; i++) {}
  };

Placeholder for the key parsing when a button is toggled.

jchen42703 commented 3 years ago

Right now, I have the line numbers on both sides. The # of renders is definitely not optimal tho. The TranslatedDisplay rerenders the paragraphs a lot. image

Next step is to place those line numbers with a FoldButton

jchen42703 commented 3 years ago

As of commit a5f7c17 Tried this component hierarchy:

EditorParagraph
  FoldButton
  EditorBlock

The reason why this doesn't work is because when you try to do selection, the buttons are also selected.

i.e. when you do CTRL + A: image

Proposed Fix?

jchen42703 commented 3 years ago

Note: user-select only works for text, not svgs

  -webkit-user-select: none; /* Chrome all / Safari all */
  -moz-user-select: none; /* Firefox all */
  -ms-user-select: none; /* IE 10+ */
  user-select: none; /* Likely future */

pointer-events: none only works for single line highlights. For multi-line selection, it is ineffective.

jchen42703 commented 3 years ago

Made the svg the background image of the button and now, it's no longer selectable! Copy pasting into google docs is cleaner now. image

Next is to make a toggle collapse the corresponding paragraph (based on key). After that is to do the same thing for the display. Then, to connect the buttons together with Redux and a dispatch

jchen42703 commented 3 years ago

Works now for InputEditor: image

jchen42703 commented 3 years ago

image

jchen42703 commented 3 years ago

TranslatedDisplay looks like: image

Current Bugs

jchen42703 commented 3 years ago

Just connect the toggle buttons and worry about the rest later. Edit: Nvm

Working on adding back in react-redux and redux for simultaneous button toggling across the editor and display

jchen42703 commented 3 years ago

The feature finally works!! image

Bugs

jchen42703 commented 3 years ago

Last step is write tests

jchen42703 commented 3 years ago

Screw writing tests for the components. It's so tedious with draft-js :sob: . Make this an issue and make it the next PR. (Note: The app has been extensively manually tested. Just hard to translate those manual tests to code...)