Skip to content

Suggestion plugin refactor #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
Feb 8, 2023
Merged

Conversation

matthewlipski
Copy link
Collaborator

This PR refactors the suggestions plugin to hopefully make it more readable and provide better documentation.

YousefED and others added 30 commits November 22, 2022 12:26
# Conflicts:
#	packages/core/src/extensions/DraggableBlocks/DraggableBlocksPlugin.tsx
# Conflicts:
#	packages/core/src/extensions/DraggableBlocks/DraggableBlocksPlugin.tsx
…aration

# Conflicts:
#	packages/core/src/extensions/BubbleMenu/BubbleMenuPlugin.ts
Moved animation delay timeout to bubble menu plugin
# Conflicts:
#	packages/react/src/BubbleMenu/BubbleMenuFactory.tsx
#	packages/react/src/BubbleMenu/components/BubbleMenu.tsx
#	packages/react/src/BubbleMenu/components/LinkToolbarButton.tsx
#	packages/react/src/HyperlinkMenus/HyperlinkMenuFactory.tsx
@vercel
Copy link

vercel bot commented Feb 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
blocknote ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 8, 2023 at 7:23PM (UTC)

# Conflicts:
#	examples/editor/package.json
#	examples/editor/src/App.tsx
#	examples/vanilla/README.md
#	examples/vanilla/package.json
#	examples/vanilla/src/ui/blockSideMenuFactory.ts
#	examples/vanilla/src/ui/formattingToolbarFactory.ts
#	examples/vanilla/src/ui/hyperlinkToolbarFactory.ts
#	examples/vanilla/src/ui/slashMenuFactory.ts
#	package-lock.json
#	package.json
#	packages/core/package.json
#	packages/core/src/BlockNoteExtensions.ts
#	packages/core/src/extensions/Blocks/nodes/BlockContainer.ts
#	packages/core/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts
#	packages/core/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts
#	packages/core/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.ts
#	packages/core/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts
#	packages/core/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts
#	packages/core/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts
#	packages/core/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts
#	packages/core/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts
#	packages/core/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts
#	packages/core/src/extensions/Placeholder/PlaceholderExtension.ts
#	packages/core/src/extensions/SlashMenu/SlashMenuExtension.ts
#	packages/core/src/extensions/SlashMenu/SlashMenuItem.ts
#	packages/core/src/extensions/SlashMenu/defaultCommands.tsx
#	packages/core/src/index.ts
#	packages/core/src/shared/EditorElement.ts
#	packages/core/src/shared/plugins/suggestion/SuggestionItem.ts
#	packages/core/src/shared/plugins/suggestion/SuggestionPlugin.ts
#	packages/core/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts
#	packages/react/package.json
#	packages/react/src/BlockNoteView.tsx
#	packages/react/src/BlockSideMenu/BlockSideMenuFactory.tsx
#	packages/react/src/BlockSideMenu/components/BlockSideMenu.tsx
#	packages/react/src/FormattingToolbar/FormattingToolbarFactory.tsx
#	packages/react/src/FormattingToolbar/components/FormattingToolbar.tsx
#	packages/react/src/FormattingToolbar/components/LinkToolbarButton.tsx
#	packages/react/src/HyperlinkToolbar/HyperlinkToolbarFactory.tsx
#	packages/react/src/SharedComponents/Toolbar/components/ToolbarButton.tsx
#	packages/react/src/SlashMenu/SlashMenuFactory.tsx
#	packages/react/src/SlashMenu/components/SlashMenu.tsx
#	tests/end-to-end/dragdrop/dragdrop.test.ts
#	tests/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandlemenu-firefox-linux.png
#	tests/utils/const.ts
@@ -81,7 +81,7 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
}

// If slash menu is of drag type and active, show the filter placeholder
if (menuState?.type === "drag" && menuState?.active) {
if (menuState?.triggerCharacter === "" && menuState?.active) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit hacky? to check triggerCharacter === ""? Maybe not a big blocker for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok for now, the trigger character will only be "" if and only if the menu is opened by a plugin or extension by design. We might have some other extension which does this in the future, or have users be able to open it programmatically themselves, but I think it'll be easier to come up with a good solution once we reach that point.

@matthewlipski matthewlipski merged commit fdce818 into main Feb 8, 2023
fogle pushed a commit to fogle/BlockNote that referenced this pull request May 20, 2023
* upgrade to react 18

* Maybe fixed React error in build

* Added early implementation of bubble menu & editor in separate react package

* Moved all hyperlink menus to react package

* Major structural overhaul to menu factories

* Added suggestions menu factory with new (hopefully final) factory structure

* Refactored bubble menu code to use improved factory structure

* Changes to bubble menu code and documentation

* Changes to bubble menu code and documentation

* General improvements, mostly to bubble and hyperlink menus

* comments after call

* Split bubble menu props into init & update props
Moved animation delay timeout to bubble menu plugin

* clean up packaging

* fix react error

* Changed bubble menu plugin view back to use a separate class

* Split hyperlink menu props into init & update props

* Changed hyperlink menu plugin view to use a separate class

* fix gitignore

* fix tsconfig

* Major cleanup for bubble menu factory code

* Major cleanup for hyperlink menu factory code

* Minor fixes

* Converted suggestion plugin view to use a class

* Changed editor example to use React as before

* Improved file structure and minor tweaks

* Minor refactor

* Fixed hyperlink menu behaviour

* Separated drag handle UI elements to react package

* Separated drag handle UI elements to react package

* Minor improvements

* fix lint

* refactor entrypoints (TypeCellOS#77)

* refactor entrypoints

* fix packages

* fix build

* move some more files / remove root.module.css

* Fixed hyperlink edit menu bugs

* re-add font

* Removed bubble menu animation update delay hack

* Changed bubble menu placement to be at the start of the selection bounding box

* Fixed hyperlink menu naming inconsistencies

* Refactored block/drag menu to use one factory and separate view class

* Fixed bubble menu sometimes attempting to hide when already hidden

* Fixed drag preview styling

* Fixed tooltip styling

* Removed unnecessary updates from block menu

* Vanilla example (TypeCellOS#78)

* add vanilla example

* add bold toggle

* add other factories to vanilla example

* add dragging

* Updated naming for bubble, block, and hyperlink menus

* Fixed drag handle tests

* Fixed drag and drop tests

* Improved how UI element factories are passed to extensions

* Updated suggestions/slash menu naming

* Updated slash menu selector for tests

* Split factory params into static and dynamic

* Minor fix to `BNSetContentType()`

* Improved getting & setting block type in formatting toolbar factory API

* Minor typing fix

* Suggestions plugin refactor/rewrite

* Combined factory `update()` and `show()` functions into single `render()` function

* Changed item callback to delete both trigger character and query

* Minor fix

* rename props -> staticParams in vanilla example

* Changed suggestions menu behaviour when typing multiple "/" characters

* Minor change

* Fixed build error and placeholder when adding block using side menu

---------

Co-authored-by: yousefed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants