Skip to content

Commit

Permalink
Feat/default spannar menu (#92)
Browse files Browse the repository at this point in the history
* chore: adjust toolbar size

* feat: adjust grab style

* feat: spannar style

* refactor: spanner menu

* feat: add transition

* feat: smart dropdown

* feat: add default spanner menu
  • Loading branch information
vincentdchan authored Nov 27, 2023
1 parent 34f8e43 commit 796abe2
Show file tree
Hide file tree
Showing 20 changed files with 361 additions and 313 deletions.
3 changes: 3 additions & 0 deletions packages/blocky-core/css/blocky-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
.blocky-editor-toolbar-delegate {
position: absolute;
z-index: 11;
transition-property: opacity, transform;
transition-duration: 200ms;
transition-timing-function: ease;
}

/* https://stackoverflow.com/questions/826782/how-to-disable-text-selection-highlighting */
Expand Down
4 changes: 4 additions & 0 deletions packages/blocky-core/src/view/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,10 @@ export class Editor {
return undefined;
}

get fontFamily(): string {
return this.themeData?.font ?? blockyDefaultFonts;
}

handleBlocksContainerMouseMove(e: MouseEvent) {
const y = e.clientY;
const blockSizes = this.#collectBlocksSize();
Expand Down
2 changes: 2 additions & 0 deletions packages/blocky-core/src/view/toolbarDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class ToolbarDelegate extends UIDelegate {
this.#debounced = undefined;
}
super.hide();
this.container.style.opacity = "0";
}

override show() {
Expand All @@ -77,6 +78,7 @@ export class ToolbarDelegate extends UIDelegate {
}
this.#debounced = undefined;
this.container.style.display = "";
this.container.style.opacity = "1";
this.shown = true;
if (this.shown) {
this.container.style.top = this.#y + "px";
Expand Down
5 changes: 2 additions & 3 deletions packages/blocky-example/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
makeImageBlockPlugin,
type SpannerRenderProps,
DefaultToolbarMenu,
DefaultSpannerMenu,
} from "blocky-react";
import SearchBox from "@pkg/components/searchBox";
import ImagePlaceholder from "@pkg/components/imagePlaceholder";
import { makeCommandPanelPlugin } from "./plugins/commandPanel";
import { makeAtPanelPlugin } from "./plugins/atPanel";
import SpannerMenu from "./spannerMenu";
// import ToolbarMenu from "./toolbarMenu";
import TianShuiWeiImage from "./tianshuiwei.jpg";
import Image from "next/image";
import { blockyExampleFont, Theme } from "./themeSwitch";
Expand Down Expand Up @@ -63,7 +62,7 @@ function makeController(userId: string, title: string): EditorController {
*/
spannerFactory: makeReactSpanner(
({ editorController, focusedNode }: SpannerRenderProps) => (
<SpannerMenu
<DefaultSpannerMenu
editorController={editorController}
focusedNode={focusedNode}
/>
Expand Down
27 changes: 0 additions & 27 deletions packages/blocky-example/app/spannerMenu.scss

This file was deleted.

177 changes: 0 additions & 177 deletions packages/blocky-example/app/spannerMenu.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions packages/blocky-example/components/dropdown/dropdown.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions packages/blocky-example/components/menu/menu.scss

This file was deleted.

43 changes: 0 additions & 43 deletions packages/blocky-example/components/menu/menu.tsx

This file was deleted.

Loading

1 comment on commit 796abe2

@vercel
Copy link

@vercel vercel bot commented on 796abe2 Nov 27, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.