Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redturtle/volto-slate-extras

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redturtle/volto-slate-extras

volto-slate-extras: Volto add-on with RedTurtle's Slate customizations

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Volto Slate Extras (@redturtle/volto-slate-extras)

A Volto addon to add base Slate configuration to your site. Basic Slate configuration from this addon

npm Code analysis checks Unit tests

Settings

config.settings['volto-slate-extras'] = {
  link_button_class: 'ui primary button', //bootstrap classes: 'btn btn-primary',
  link_enhancer: (element) => {},
};
  • link_button_class: class to apply to style button links
  • link_enhancer: component to henance link, for example with filename and file size extension

Widgets

TextEditorWidget

Widget to create a text editor in Volto's blocks. You could decide to use a

  • simple text editor widget (without text formatting) (into the example below is the 'title' field)
  • a Slate editor widget (with text formatting) with prop showToolbar (into the example below is the 'text' field)
import {
  TextEditorWidget,
  useHandleDetachedBlockFocus,
} from '@redturtle/volto-slate-extras';

const Edit = (props) => {
  const { data, onChangeBlock, block, selected, onSelectBlock, ...otherProps } =
    props;
  const { intl } = props;
  const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
    props,
    'title',
  );

  return (
    <>
      {/* Simple text editor widget */}
      <TextEditorWidget
        {...otherProps}
        as="h3"
        showToolbar={false}
        data={data} //block's data
        block={block} //block id
        fieldName="title"
        onChangeBlock={onChangeBlock}
        selected={selectedField === 'title'}
        placeholder={intl.formatMessage(messages.title)}
        setSelected={setSelectedField}
        focusNextField={() => {
          setSelectedField('text');
        }}
        onSelectBlock={onSelectBlock}
      />

      {/* Slate text editor widget */}
      <TextEditorWidget
        {...otherProps}
        data={data}
        fieldName="text"
        block={block}
        onSelectBlock={onSelectBlock}
        selected={selectedField === 'text'}
        placeholder={intl.formatMessage(messages.text)}
        onChangeBlock={onChangeBlock}
        setSelected={setSelectedField}
        focusPrevField={() => {
          setSelectedField('title');
        }}
      />
    </>
  );
};

View value of TextEditorWidget in View components:

To view the value edited from TextEditorWidget:

  • if it's a simple text (showToolbar=false) you simply do it with jsx {data.title}
  • if it's a Slate widget (showToolbar=true) you could use TextBlockView from Volto:
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
<TextBlockView data={{ value: data.text }} />;

Keywords

FAQs

Package last updated on 04 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc