Closed jchen42703 closed 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.
Next steps:
LineGutter
and DisplayGutter
full of buttons that can collapse the text.collapse
state between corresponding EditorBlock
s and DisplayBlock
s 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.
toggledKeys
toggledKeys
state and whenever it changes, Display takes that quantity and passes a toggleOn
prop to the corresponding DisplayParagraph
DisplayParagraph
collapses its own DisplayBlockRight now, I have the line numbers on both sides. The # of renders is definitely not optimal tho. The TranslatedDisplay rerenders the paragraphs a lot.
Next step is to place those line numbers with a FoldButton
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:
Display
. Obviously this removes the need for EditorParagraph
because the buttons are no longer ecapsulated by EditorParagraph
.ButtonGutter
class will need to share editorState
to add a button for each paragraphNote: 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.
Made the svg the background image of the button and now, it's no longer selectable! Copy pasting into google docs is cleaner now.
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
Works now for InputEditor
:
line-text
margin is only 0.25 em
); Will look better once the FoldButton
is added to each DisplayParagraph
TranslatedDisplay
looks like:
InputEditor
TranslatedDisplay
produces a bulleted listJust 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
The feature finally works!!
Last step is write tests
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...)
Closes #2 Feature that allows collapsible paragraphs.
Select mode that lets you collapse all other paragraphs than the ones you selected.Design Choices
POST
request whenever we align paragraphs