Skip to content

Commit

Permalink
Merge branch 'main' into optional-props
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefED committed Dec 16, 2024
2 parents 8dd93d9 + 3b5af24 commit 4e42e74
Show file tree
Hide file tree
Showing 132 changed files with 1,736 additions and 1,263 deletions.
14 changes: 7 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.20.0",
"version": "0.21.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -9,12 +9,12 @@
"lint": "next lint"
},
"dependencies": {
"@blocknote/ariakit": "^0.20.0",
"@blocknote/core": "^0.20.0",
"@blocknote/mantine": "^0.20.0",
"@blocknote/react": "^0.20.0",
"@blocknote/shadcn": "^0.20.0",
"@blocknote/xl-multi-column": "^0.20.0",
"@blocknote/ariakit": "^0.21.0",
"@blocknote/core": "^0.21.0",
"@blocknote/mantine": "^0.21.0",
"@blocknote/react": "^0.21.0",
"@blocknote/shadcn": "^0.21.0",
"@blocknote/xl-multi-column": "^0.21.0",
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.4",
"@mantine/core": "^7.10.1",
Expand Down
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),
},
}));
35 changes: 7 additions & 28 deletions examples/06-custom-schema/04-pdf-file-block/PDF.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { FileBlockConfig } from "@blocknote/core";
import {
AddFileButton,
createReactBlockSpec,
DefaultFilePreview,
FileAndCaptionWrapper,
ReactCustomBlockRenderProps,
ResizableFileBlockWrapper,
} from "@blocknote/react";

import { RiFilePdfFill } from "react-icons/ri";
Expand Down Expand Up @@ -53,31 +51,12 @@ export const PDF = createReactBlockSpec(
},
{
render: (props) => (
<div className={"bn-file-block-content-wrapper"}>
{props.block.props.url === "" ? (
<AddFileButton
{...props}
editor={props.editor as any}
buttonText={"Add PDF"}
buttonIcon={<RiFilePdfFill size={24} />}
/>
) : !props.block.props.showPreview ? (
<FileAndCaptionWrapper
block={props.block}
editor={props.editor as any}>
<DefaultFilePreview
block={props.block}
editor={props.editor as any}
/>
</FileAndCaptionWrapper>
) : (
<FileAndCaptionWrapper
block={props.block}
editor={props.editor as any}>
<PDFPreview block={props.block} editor={props.editor as any} />
</FileAndCaptionWrapper>
)}
</div>
<ResizableFileBlockWrapper
{...(props as any)}
bbuttonText={"Add PDF"}
buttonIcon={<RiFilePdfFill size={24} />}>
<PDFPreview {...(props as any)} />
</ResizableFileBlockWrapper>
),
}
);
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": false,
"useWorkspaces": true,
"version": "0.20.0"
"version": "0.21.0"
}
Loading

0 comments on commit 4e42e74

Please sign in to comment.