
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
tiptap-extension-pagination
Advanced tools
npm install tiptap-extension-pagination
/**
* @file /src/Tiptap/Editor.tsx
* @name Editor
* @description Example Tiptap editor with pagination plugin.
*/
import React from "react";
import { Stack } from "@mui/material";
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import PaginationExtension, { PageNode, HeaderFooterNode, BodyNode } from "tiptap-extension-pagination";
type DispatchOrFunction<T> = Dispatch<T> | ((value: T) => void);
type EditorProps = {
content: string;
setContent: DispatchOrFunction<string>;
editable?: boolean;
};
const Editor: React.FC<EditorProps> = ({ content, setContent, editable = true }) => {
const extensions = [
StarterKit,
PaginationExtension.configure({ ... }), // See configuration options below.
PageNode,
HeaderFooterNode,
BodyNode];
const editor = useEditor({
extensions,
content,
onUpdate({ editor }) {
const editorContent = editor.getHTML();
handleChange(editorContent);
},
editable,
onSelectionUpdate({ editor }) {
const { state } = editor;
const { selection } = state;
const { $from, $to } = selection;
console.log("Selection updated:", $from.pos, $to.pos);
},
});
// ====== Event Handlers ======
/**
* Handles change in text.
*
* @param value - new text value
* @returns {void}
*/
const handleChange = (value: string): void => {
setContent(value);
};
// ====== Render ======
return (
<Stack direction="column" flexGrow={1} paddingX={2} overflow="auto">
<EditorContent editor={editor} />
</Stack>
);
};
export default Editor;
This extension comes with a number of configuration options to tailor the editor to your usage. If specified, these configuration options should be placed with the .configuration()
method when specifying the PaginationExtension
in your extension array. See below example.
defaultPaperSize: PaperSize
PaperSize
"A4"
"A3"
defaultPaperColour: string
string
"#fff"
"#f0f0f0"
useDeviceThemeForPaperColour: boolean
boolean
false
true | false
defaultPaperOrientation: PaperOrientation
PaperOrientation
"portrait"
"portrait" | "landscape"
defaultMarginConfig: MarginConfig
MarginConfig
{ top: 25.4, right: 25.4, bottom: 25.4, left: 25.4 }
{ top: 10, right: 10, bottom: 10, left: 10 }
defaultPageBorders: BorderConfig
BorderConfig
{ top: 1, right: 1, bottom: 1, left: 1 }
{ top: 2, right: 2, bottom: 2, left: 2 }
pageAmendmentOptions: PageAmendmentOptions
PageAmendmentOptions
{ enableHeader: true, enableFooter: false }
You can specify as little or as much of the configuration as you like. For example:
import PaginationExtension from "tiptap-extension-pagination";
// Then in your extension array (within your component)
PaginationExtension.configure({
defaultPaperSize: "A3",
pageAmendmentOptions: {
enableHeader: false,
enableFooter: false,
},
}),
Improved from clemente-xyz's comment here in TipTap discussion #5719.
FAQs
Add pagination to your Tiptap editor
The npm package tiptap-extension-pagination receives a total of 377 weekly downloads. As such, tiptap-extension-pagination popularity was classified as not popular.
We found that tiptap-extension-pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.