Date

Insert and format dates in your document.

Loading...
Files
components/demo.tsx
'use client';

import React from 'react';

import { Plate } from '@udecode/plate-common/react';

import { editorPlugins } from '@/components/editor/plugins/editor-plugins';
import { useCreateEditor } from '@/components/editor/use-create-editor';
import { Editor, EditorContainer } from '@/components/plate-ui/editor';

import { DEMO_VALUES } from './values/demo-values';

export default function Demo({ id }: { id: string }) {
  const editor = useCreateEditor({
    plugins: [...editorPlugins],
    value: DEMO_VALUES[id],
  });

  return (
    <Plate editor={editor}>
      <EditorContainer variant="demo">
        <Editor />
      </EditorContainer>
    </Plate>
  );
}

Features

  • Insert and display dates within your text using inline date elements.
  • These dates can be easily selected and modified using a calendar interface.

Installation

npm install @udecode/plate-date

Usage

import { DatePlugin } from '@udecode/plate-date/react';
 
const plugins = [
  // ...otherPlugins,
  DatePlugin,
];

Plugins

DatePlugin

Add Date Plugin to your document.

API

isPointNextToNode

Check if a point is next to a specific node type.

Parameters

Collapse all

    The editor instance.

    The type of node to check for adjacency. This should be a string representing the node type, such as 'date' for inline date elements.

    The options for checking adjacency:

Plugin Transforms

editor.tf.insert.date

Insert a date into the editor.

Parameters

Collapse all

    The date string to insert, in the format 'YYYY-MM-DD' (e.g., '2024-04-22'). If not provided, the current date will be used as the default.

    The options for inserting nodes.