mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
4.4 KiB
4.4 KiB
Features:
- Cross-platform
- Able to render at the top & the bottom
- Aligns & adjusts different elements based on where it's located
- 4 different types of interaction elements:
- Dropdown
- Popup
- Bottom action sheet (mobile only)
- Sidebar
- The toolbar will be extensible allowing plugins to add tools into it.
API Design:
- All the tools will be defined in a seperate file
- Each tool will implement the
IToolinterface - The
IToolinterface defines:- The name
- Type: "block" | "inline" etc.
- Help text/description
- The action
- Each tool will take the
Editorinstance from its constructor - The
actionneeds to be pure i.e., it should perform the exact same action on the same data. - All the tools classes will be exported from the
index.tsfile
The Toolbar:
- The toolbar will be React rendered taking a tool definition from its props & the location.
- Based on the tool definition, the toolbar will render different items.
- The icon for each tool will be derived from the tool definition
- We will need an icon resolver that will take an icon name & find the icon associated with it.
- To this purpose, we should have an icon dictionary which the client can import & use.
- This toolbar will be exported for the client to render.
Interaction Elements:
- Inside the
actionof each tool, the action will have full control over what to render & where. - The action should take the rendered
HTMLElementas reference - In case of dropdown:
- We can use the menu from the app & move it into a module
- This menu can then be reshaped to act as a dropdown
- In case of bottom sheet:
- We should use react-spring-bottom-sheet
- Since bottom sheet will serve multiple purposes (not just a list of items), it should be possible to render anything in it.
- In case of popup: TBD
- In case of side bar: TBD
Total Tools:
- bold italic underline strikethrough inlinecode
- fontselect
- blockquote (styling left)
- codeblock
- fontsizeselect
- formatselect
- alignleft aligncenter alignright alignjustify
- [] outdent indent
- subscript superscript
- numlist
- bullist
- checklist
- forecolor backcolor
- removeformat
- hr
- link
- image
- attachment
- media
- table
- ltr rtl
- searchreplace
What's next:
- Port codeblock extension from tinymce to tiptap
- Optimize toolbar & editor UI for mobile
- Refactor & finalize UI + styling
- Write tests
Optimize toolbar & editor UI for mobile
- Refactor tools to be more easily configurable (partially done)
- Implement sub groups in toolbar (done)
- Move all popups to /popups directory (partially done)
- Implement mobile positioning logic in menu/popup presenter (done)
- Add support for repositioning toolbar (top/bottom) (done)
- Move all popups to be shown as bottom sheets on mobile (partially done)
- Figure out how to make interactive widgets selectable in editor (e.g. iframe & table)
- Create popup header for use in action sheet (done)
- Header contains title & action(s)
- Implement logic to open inline popups (image/cell properties) as an action sheet (done)
- Open search replace popup as action sheet (done)
- Improve font size menu (done)
- Move table context toolbars to bottom (done)
Refactor tools
- A tool defines it's own UI
- This gives it maximum flexibility to do whatever it wants.
- However, this also restricts the tool to be shown in specific places
- For example: if all block tools are defined as menu buttons, they can only be shown in a menu
- But since this toolbar is application specific, this is alright. We already know where a certain tool is going to be rendered. Locking things down, while reduces flexibility, also allows us to easily customize a specific tool's behavior. A generic toolbar would be great in cases where multiple apps are going to be using it.
- Some factors of a tool's UI can be defined externally
- For example, a tool's icon + title + description?
- It wouldn't be a bad idea to separate out action & toggle state of a tool as well. This can be useful in cases where we want to invoke a specific tool or get a specific tool's toggle state.
- Keyboard shouldn't close on tool click
- Handle context toolbar menus on scroll