Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"playground": true,
"docs": true,
"author": "areknawo",
"tags": [
"Intermediate",
"UI Components",
"Formatting Toolbar",
"Appearance & Styling"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import "@blocknote/core/fonts/inter.css";
import {
ExperimentalMobileFormattingToolbarController,
useCreateBlockNote,
} from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

import "./style.css";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
initialContent: [
{
type: "paragraph",
content: "Welcome to this demo!",
},
{
type: "paragraph",
content:
"Check out the experimental mobile formatting toolbar by selecting some text (best experienced on a mobile device).",
},
{
type: "paragraph",
},
],
});

// Renders the editor instance using a React component.
return (
// Disables the default formatting toolbar and re-adds it without the
// `FormattingToolbarController` component. You may have seen
// `FormattingToolbarController` used in other examples, but we omit it here
// as we want to control the position and visibility ourselves. BlockNote
// also uses the `FormattingToolbarController` when displaying the
// Formatting Toolbar by default.
<BlockNoteView editor={editor} formattingToolbar={false}>
<ExperimentalMobileFormattingToolbarController />
</BlockNoteView>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Experimental Mobile Formatting Toolbar

This example shows how to use the experimental mobile formatting toolbar, which uses [Visual Viewport API](https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API) to position the toolbar right above the virtual keyboard on mobile devices.

Controller is currently marked **experimental** due to the flickering issue with positioning (caused by delays of the Visual Viewport API)

**Relevant Docs:**

- [Changing the Formatting Toolbar](/docs/ui-components/formatting-toolbar#changing-the-formatting-toolbar)
- [Editor Setup](/docs/editor-basics/setup)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
<head>
<script>
<!-- AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY -->
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Experimental Mobile Formatting Toolbar</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@blocknote/example-experimental-mobile-formatting-toolbar",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "latest",
"@blocknote/react": "latest",
"@blocknote/ariakit": "latest",
"@blocknote/mantine": "latest",
"@blocknote/shadcn": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8.10.0",
"vite": "^5.3.4"
},
"eslintConfig": {
"extends": [
"../../../.eslintrc.js"
]
},
"eslintIgnore": [
"dist"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.bn-container {
display: flex;
flex-direction: column-reverse;
gap: 8px;
}

.bn-formatting-toolbar {
margin-inline: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"__comment": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"composite": true
},
"include": [
"."
],
"__ADD_FOR_LOCAL_DEV_references": [
{
"path": "../../../packages/core/"
},
{
"path": "../../../packages/react/"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import react from "@vitejs/plugin-react";
import * as fs from "fs";
import * as path from "path";
import { defineConfig } from "vite";
// import eslintPlugin from "vite-plugin-eslint";
// https://vitejs.dev/config/
export default defineConfig((conf) => ({
plugins: [react()],
optimizeDeps: {},
build: {
sourcemap: true,
},
resolve: {
alias:
conf.command === "build" ||
!fs.existsSync(path.resolve(__dirname, "../../packages/core/src"))
? {}
: ({
// Comment out the lines below to load a built version of blocknote
// or, keep as is to load live from sources with live reload working
"@blocknote/core": path.resolve(
__dirname,
"../../packages/core/src/"
),
"@blocknote/react": path.resolve(
__dirname,
"../../packages/react/src/"
),
} as any),
},
}));
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/ariakit/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
gap: 0.5rem;
}

.bn-toolbar.bn-ak-toolbar {
overflow-x: auto;
max-width: 100vw;
}
.bn-toolbar .bn-ak-button {
width: unset;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"prosemirror-state": "^1.4.3",
"prosemirror-tables": "^1.6.1",
"prosemirror-transform": "^1.9.0",
"prosemirror-view": "^1.33.7",
"prosemirror-view": "^1.38.0",
"rehype-format": "^5.0.0",
"rehype-parse": "^8.0.4",
"rehype-remark": "^9.1.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/api/clipboard/toClipboard/copyExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ export function selectedFragmentToHTML<
}

// Uses default ProseMirror clipboard serialization.
const clipboardHTML: string = (pmView as any).__serializeForClipboard(
view,
const clipboardHTML: string = view.serializeForClipboard(
view.state.selection.content()
).dom.innerHTML;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TableRow } from "@tiptap/extension-table-row";
import { Node as PMNode } from "prosemirror-model";
import { TableView } from "prosemirror-tables";

import { NodeView } from "prosemirror-view";
import {
createBlockSpecFromStronglyTypedTiptapNode,
createStronglyTypedTiptapNode,
Expand Down Expand Up @@ -101,7 +102,7 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
return new BlockNoteTableView(node, EMPTY_CELL_WIDTH, {
...(this.options.domAttributes?.blockContent || {}),
...HTMLAttributes,
});
}) as NodeView;
};
},
});
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/extensions/SideMenu/dragging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Node } from "prosemirror-model";
import { NodeSelection, Selection } from "prosemirror-state";
import * as pmView from "prosemirror-view";
import { EditorView } from "prosemirror-view";

import { createExternalHTMLExporter } from "../../api/exporters/html/externalHTMLExporter.js";
Expand Down Expand Up @@ -177,10 +176,8 @@ export function dragStart<
const selectedSlice = view.state.selection.content();
const schema = editor.pmSchema;

const clipboardHTML = (pmView as any).__serializeForClipboard(
view,
selectedSlice
).dom.innerHTML;
const clipboardHTML =
view.serializeForClipboard(selectedSlice).dom.innerHTML;

const externalHTMLExporter = createExternalHTMLExporter(schema, editor);

Expand Down
6 changes: 6 additions & 0 deletions packages/mantine/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
overflow: auto;
}

.bn-mantine .mantine-Button-root[aria-controls*="dropdown"] {
min-width: fit-content;
}

/* Toolbar styling */
.bn-mantine .bn-toolbar {
background-color: var(--bn-colors-menu-background);
Expand All @@ -144,6 +148,8 @@
gap: 2px;
padding: 2px;
width: fit-content;
overflow-x: auto;
max-width: 100vw;
}

.bn-mantine .bn-toolbar:empty {
Expand Down
Loading