7.13.3 • Published 6 years ago

nocms-publishing v7.13.3

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

NoCMS publishing

Publishing interface for NoCMS.

semantic-release Dependency Status devDependencies

Installation

npm i nocms-publishing

Features

  • AdminContent: Provide the menu on the right hand side. Most likely not used directly, but by nocms-server.
  • EditableArea: An editable area with the provided fields wrapped in an edit menu used by templates.
  • EditableComponentWrapper: A list of editable components used by templates.
  • EditImage: An image selector where you can pick responsive images, crop, zoom, add alt text, caption and attribution. Used by templates.
  • EditPdf: Pfd selector, used by templates.
  • EditSimpleImage: Select an image, used by templates

Usage

EditableArea

Example with Editable Area. editMode is a bool indicating editMode (the menu is open), but not necessarily activeEditMode (the group of input fields are in active edit state, e.g shown as input fields and with edit menu). EditableArea adds the activeEditMode bool, so it can be used by (in this example) ReactComponent.jsx.

import React from 'react';
import PropTypes from 'prop-types';
import { EditableArea } from 'nocms-publishing';
import ReactComponent from '../components/ReactComponent.jsx';

const EditableAreaDemo = (props, context) => {
  const { content } = props;
  const { editMode} = context;
  const information = <ReactComponent scope="content.information" data={content.information} />;

  return (
    {editMode ?
      <EditableArea scope="content.information" label="Praktisk informasjon">{information}</EditableArea>
      : information}
  )
};

EditableAreaDemo.propTypes = {
  content: PropTypes.object,
};

EditableAreaDemo.defaultProps = {
  content: {},
};

EditableAreaDemo.contextTypes = {
  editMode: PropTypes.bool,
  lang: PropTypes.string,
};

export default EditableAreaDemo;

EditImage

Example with EditImage. The example is very simplified. Most likely, you will need some logic to handle displaying different images according to viewport size or some strategy to avoid image "jumping".

The component itself is responsible for displaying the image when in not edit mode. See https://github.com/miles-no/nocms-cloudinary-utils for helpers. Run the example for more options for the image dialog.

import React, { Fragment } from 'react';
import { EditImage } from 'nocms-publishing';
import cloudinary from 'nocms-cloudinary-utils';

const aspectRatio = {
  large: {
    width: 5,
    height: 4,
  },
  small: {
    width: 2,
    height: 3,
  },
};
const ImageDemo = (props, context) => {
  const { activeEditMode, data, scope } = this.props;
  const { config, editMode } = this.context;
  const image = data.image || {};
  const transformation = {
    // for available options, see Clodinary docs
    quality: 'auto:eco',
    fetch_format: 'auto',
    use_root_path: true,
    crop: 'crop',
  };
  let src = cloudinary.getImageUrl(config.cloudinaryCloudName, transformation, image, aspectRatio.large);

  return (
    <Fragment>
      {editMode ?
        <EditImage
          scope={`${scope}.image`}
          data={image}
          activeEditMode={activeEditMode}
          targetDevices
          aspectRatio={aspectRatio}
          disableCaption
        />
      : null }
      {src}
    </Fragment>
  )
};

Run the example

The example can be useful for more examples and demo. As a standalone example, most site interaction will fail in lack of a real web server, page and message api.

git clone https://github.com/miles-no/nocms-publishing.git
cd nocms-publishing
npm i
npm run dev

In another terminal window for images

npm run dev:backend

Go to http://localhost:9000/

Commit message format and publishing

This repository is published using semantic-release, with the default AngularJS Commit Message Conventions.

7.13.3

6 years ago

7.13.2

6 years ago

7.13.1

6 years ago

7.13.0

6 years ago

7.12.3

6 years ago

7.12.2

6 years ago

7.12.1

6 years ago

7.12.0

6 years ago

7.11.2

6 years ago

7.11.1

6 years ago

7.11.0

6 years ago

7.10.3

6 years ago

7.10.2

6 years ago

7.10.1

6 years ago

7.10.0

6 years ago

7.9.2

6 years ago

7.9.1

6 years ago

7.9.0

6 years ago

7.8.1

6 years ago

7.8.0

6 years ago

7.7.0

6 years ago

7.6.2

6 years ago

7.6.1

6 years ago

7.5.7

6 years ago

7.5.6

6 years ago

7.5.5

6 years ago

7.5.4

6 years ago

7.5.3

6 years ago

7.5.2

6 years ago

7.5.1

6 years ago

7.5.0

6 years ago

7.4.0

6 years ago

7.3.0

6 years ago

7.2.3

6 years ago

7.2.2

6 years ago

7.2.1

6 years ago

7.2.0

6 years ago

7.1.2

6 years ago

7.1.1

6 years ago

7.1.0

6 years ago

7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.3.0

6 years ago

6.2.10

6 years ago

6.2.9

6 years ago

6.2.8

6 years ago

6.2.7

6 years ago

6.2.6

6 years ago

6.2.5

6 years ago

6.2.4

6 years ago

6.2.3

6 years ago

6.2.2

6 years ago

6.2.1

6 years ago

6.2.0

6 years ago

6.1.4

6 years ago

6.1.3

6 years ago

6.1.2

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.0

6 years ago

5.4.4

6 years ago

5.4.3

6 years ago

5.4.2

6 years ago

5.4.1

6 years ago

5.4.0

6 years ago

5.3.1

6 years ago

5.3.0

6 years ago

5.2.3

6 years ago

5.2.2

6 years ago

5.2.1

6 years ago

5.2.0

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.3.0

6 years ago

4.2.1

6 years ago

4.2.0

6 years ago

4.1.0

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.0

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.4

6 years ago

3.4.3

6 years ago

3.4.2

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.1

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.17.2

6 years ago

1.17.1

6 years ago

1.17.0

6 years ago

1.16.5

6 years ago

1.16.4

6 years ago

1.16.3

6 years ago

1.16.2

6 years ago

1.16.1

6 years ago

1.16.0

6 years ago

1.15.3

6 years ago

1.15.2

6 years ago

1.15.1

6 years ago

1.15.0

6 years ago

1.14.1

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.0

6 years ago

1.11.2

6 years ago

1.11.1

6 years ago

1.11.0

6 years ago

1.10.0

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

0.0.0

6 years ago

1.0.0

6 years ago