Naviga Writer
8.1.7
8.1.7
  • Naviga Writer
  • Release notes
    • 8.1.7
    • 8.1.6
    • 8.1.5
    • 8.1.4
    • 8.1.3
    • 8.1.2
    • 8.1.1
    • 8.1
    • 8.0
    • 7.2
    • 7.1.0
    • 7.0.0
    • 6.5.x
    • 6.5.0
    • 6.4.1
    • 6.4.0
    • 6.3.5
    • 6.3.4
    • 6.3.3
    • 6.3.2
    • 6.3.1
    • 6.2.2
    • 6.2.1
    • 6.2.0
    • 6.1.2
    • 6.1.1
    • 6.1.0
    • 6.0.0
    • 5.3.0
  • Introduction
    • Authoring
    • Developing
    • Publishing
    • History
  • User Guide
    • Writer User Guide
      • Create a new article
      • Top bar
        • Setting menu
        • Article name
        • Search and replace words
        • Version history of an article
          • List of versions
          • Changes in each version
          • Restore to an older version
        • Locked article
        • Active Users
        • Copy article url
        • Save and publish flow
        • History Button
      • Content area
        • Image gallery
        • Embed map
        • Table
        • Teaser
        • Content part
        • HTML embed
        • Upload image
        • Upload PDF
        • Textstyles
        • Lists
        • Special character
        • Marker tool
      • Right Sidebar
        • Meta
          • Author
          • Channels
        • Integrations
        • Image and Article search
      • Bottom bar
        • Article information
        • Edit metadata on linked images
        • Article size
        • Text information
        • Language menu
      • Images User Guide
        • Upload images
        • Metadata of the image
        • Cropping images
        • Download
      • Personal Writer Template
      • Writer Keyboard Shortcuts
      • Text Management
      • Common questions when starting using Writer
  • Admin Guide
    • Configuration Files
    • Configurations Guide
      • Right Sidebar
      • Text Information
      • Content menu
    • Article Templates Configuration
    • Byline configuration
    • Language Configuration
    • Publish Flow
      • Default configuration definitions
      • Publish flow config details
      • Preconditions for roles in the publish flow
    • Generic Properties
      • Configuration
    • Image Services
      • ImEngine
      • Imgix
    • Plugins
      • Naviga developed plugins
        • Plugins in earlier versions of Writer
      • Deprecated Plugins
      • Third-party plugins
  • Developer guide
    • Upgrade Guides
      • 8.0 - Image/PDF upload changes
      • 8.0 - Opening an Article
    • Writer Plugin Development
      • Quickstart
      • Type Definitions (beta)
      • Plugin overview
      • Creating a content object plugin
      • Validation and hooks
      • Interacting with external resources
    • Writer Plugin Building Blocks
      • Package
      • Component
      • Node
      • Converter
      • Events
    • Writer Plugin Style Guide
      • CSS Guidelines
      • CSS variables, colors and fonts
      • UI Components
    • Tutorials
      • Popover & text analysis
      • Search & replace
      • Concept interaction
      • Integrating External Spell Checking
    • Infomaker NewsML
      • Overview
      • Important: About inline notes
      • Document relations and types
      • Extensions XSD
      • NewsItem
      • ConceptItem
      • PlanningItem
      • Examples
        • NewsItem - Text
        • NewsItem - Picture
        • NewsItem - PDF
        • ConceptItem - Author
        • ConceptItem - Category
        • ConceptItem - Channel
        • ConceptItem - Content Profile
        • ConceptItem - Event
        • ConceptItem - Organisation
        • ConceptItem - Person
        • ConceptItem - Place (point)
        • ConceptItem - Place (polygon)
        • ConceptItem - Section
        • ConceptItem - Story
        • ConceptItem - Topic
        • PlanningItem
    • Media Enrichment
      • Images
  • API Reference
    • Writer Api
      • Api
      • Article
      • Browser
      • Concept
      • ConceptService
      • Document
      • Events
      • NewsItem
      • Router
      • Ui
      • Upload
      • User
      • settings
      • History
      • Settings
    • UI Components
      • UIAvatar
      • UIButton
      • UIByline
      • UICheckbox
      • UIChip
      • UIDatePicker
      • UIDatetimeFieldEditor
      • UIDropdown
      • UIFieldEditor
      • UIIconButton
      • UIInlineImage
      • UIPagination
      • UISelect
      • UITimePicker
      • UIToggle
      • UITooltip
      • UIInputText
      • UITextarea
      • UIButtonGroup
      • UIConceptSearch
      • UIDateTimePicker
      • UIInputSearch
      • UIIcon
      • UIPill
      • UISpinner
      • UIButtonList
      • UIIconBadge
      • UIIconButtonMenu
      • UIInputPassword
Powered by GitBook
On this page
  • Defining a Node
  • Extending a Node with utility
  • Extending a Node with Generic Properties

Was this helpful?

  1. Developer guide
  2. Writer Plugin Building Blocks

Node

PreviousComponentNextConverter

Was this helpful?

There are many different types of Nodes built into Substance, e.g BlockNode, FileNode, TextBlock, Container, PropertyAnnotation, and probably more. Each Node-type has different utility and usage, but what they all have in common is their ability to transport data.

For simplicity this document will focus on the BlockNode. Check the for information about all the other types.

Defining a Node

What's needed to define a Node is a schema for the Node's data structure. In its simplest form, a node inherits some functionality from a parent Node, and then defines its properties.

Simple BlockNode Example:

// MyAmazingBlockNode.js
import {BlockNode} from 'substance'

class MyAmazingBlockNode extends BlockNode {}

MyAmazingBlockNode.schema = {
    type: 'myamazingplugin',
    uuid: {type: 'string', optional: false},
    message: {type: 'string', optional: true},
    year: {type: 'number'},
    isCool: {type: 'boolean'}
}

export {MyAmazingBlockNode}

Extending a Node with utility

Sometimes you might want to manipulate the data stored in the Node directly, or supply utility functions for your plugin which returns your data in a specific format. This is easily added to the defined Node class, and then accesses directly from the Component registered to that Node.

Node Utility Function Example:

// MyAmazingBlockNode.js
import {BlockNode} from 'substance'

class MyAmazingBlockNode extends BlockNode {

    safeMessage() {
        return this.message ? this.message : 'Oh dear, there is no message!' 
    }

}

MyAmazingBlockNode.schema = {
    type: 'myamazingplugin',
    message: {type: 'string', optional: true},
}

export {MyAmazingBlockNode}

// MyAmazingComponent.js
import {Component} from 'substance'

class MyAmazingComponent extends Component {

    render($$) {
        const {node} = this.props
        return $$('div').append(node.safeMessage())
    }
}

export {MyAmazingComponent}

Extending a Node with Generic Properties

The introduction of Generic Properties from version 6.0.0 of the Digital Writer, means that nodes should now extend the Container or BlockNode from the Writer, instead of the Substance class.

Extending the node classes from the Writer for content nodes, allow the Writer to use predefined fields for this content.

To support generic properties there are 2 requirements on the Node class.

  1. It must import and extend the Container or BlockNode from writer and the class extends this.

import {BlockNode, Container} from 'writer'

class ImageGalleryNode extends Container {
  1. It must have the GenericPropsComponent in the render function to control where to show the properties.

import {BlockNode, Container} from 'writer'

el.append([
    $$(GenericPropsComponent, {
        node: this.props.node,
        isolatedNodeState: this.props.isolatedNodeState,
        pluginName: 'im-imagegallery'
    }).ref('genericProps')
])

The input properties for the GenericPropsComponent is:

  • Node: The Node object, typically in this.props.node.

  • isolatedNodeState: This is the current state of the Node UI, meaning if it is active or not in the editor. For the nodes, this is typically available in this.props.isolatedNodeState.

  • pluginName: This is used to map the field configuration to decide which fields to show.

For content Nodes that support generic properties, it is possible to setup which fields to show in the Digital Writer configuration.

"propertiesConfig": {
    "showByDefault": ["im-ximimage"],
    "properties": [
        {
            "name": "alignment",
            "title": "Alignment",
            "plugins": [
                "im-imagegallery",
                "im-ximimage"
            ],
            "values": [
                {
                    "title": "Left",
                    "value": "left"
                },
                {
                    "title": "Right",
                    "value": "right"
                },
                {
                    "title": "Center",
                    "value": "center"
                }
            ]
        }
    ]
}

If the plugin name from the component is in the list of plugins for any of the properties, those properties will show up for the Content in the editor.

The values will be added to the NewsML under the object output for the plugin, as a properties Node:

<object id="1234..." uuid="024e..." type="x-im/content-part" title="Vivamus...">
  <properties>
    <property name="alignment" value="center"/>
  </properties>
    ...
</object>

Once a Node is defined, and , the Converter responsible for your plugin is able to import and export data from your Node and the underlying NewsML document.

Substance source code
Read more about Components
Read more about Converters
registered in the Package file