npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mercuriya/slate-gallery-read-only

v0.8.0-alpha.4

Published

A read-only image gallery for slate-js

Downloads

8

Readme

Slate gallery (read-only)

An image gallery for slate editor

Installation

yarn add @mercuriya/slate-gallery-read-only
npm install @mercuriya/slate-gallery-read-only --save

Configuration

In your file with Slate component:

import React from 'react';
import { createEditor } from 'slate';
import { Slate, Editable, withReact } from 'slate-react';
import { withGallery, } from '@mercuriya/slate-gallery';

const initialValue = Value.fromJSON({ ... });
const plugins = [galleryPlugin({ ...options })];

export default function EditorComponent(props) {
  const [value, setValue] = useState([ /* some initial state here */ ]);
  const editor = useMemo(
    () =>
      withGallery(withReact(createEditor()), {
        // slate-gallery options        
      }),
    [],
  );   
  const renderElement = useCallback(({ attributes, children, element }) => {
    switch (element.type) {
      case 'gallery':
        return editor.galleryElementType({
          attributes,
          children,
          element,
          // ❗️ we use this prop internally, so you must provide it here
          readOnly: false, // or true
        });
      default:
        return <p {...attributes}>{children}</p>;
    }
  }, []);

  return (
    <Slate editor={editor} value={value} onChange={value => setValue(value)}>
      <Editable renderElement={renderElement} />
    </Slate>
  );
}

Description

This plugin adds a void block which can show images as an image grid. It allows to cover each image in something like image lightbox if you want.

Each image can have a description, which is not related with image tag alt props. It is stored as data of this gallery block.

readOnly: false mode:

readOnly: false

readOnly: true mode:

readOnly: true

Please, see stories for more usage examples.

Options

|Name|Type|Description| |---|---|---| |size? (default: 9)|number|Min: 1, max: 9. It represents a grid size. A number of images which will be visible within readOnly: true mode. The remaining images will be hidden, but user will see them in the images lightbox if you will implement this.| |dropzoneProps?|object|An object of react-dropzone props which is applies to Dropzone component| |sortableContainerProps?|object|An object of react-sortable-hoc props which is applies to SortableContainer's component| |renderControls?|args => React.ReactNode|A render function that allows you to customize controls block. See types definitions for more example| |renderEditModal?|args => React.ReactNode|A render function that allows you to use custom modal while editing images descriptions| |renderExtra?|args => React.ReactNode|A render function that allows you to place additional component near image gallery. It could be handy to build image-lightbox functionality| |renderImage?|args => React.ReactNode|A render function that allows you to customize and image component| |gridClassName?|string|Grid component custom class name| |imageClassName?|string|Image component custom class name| |imageWrapperClassName?|string|Image wrapper custom class name| |leftClassName?|string|Number of left images (+x) custom className|