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
  • insertTextNode(options)⇒ object | undefined
  • Parameters
  • Example
  • Example
  • insertBlockNode(options)⇒ object | undefined
  • Parameters
  • Example
  • Example
  • nodes(filter)⇒ array
  • Parameters
  • Example
  • node(nodeId)⇒ Node | null
  • Parameters
  • Example
  • triggerFetchResourceNode(node, info)
  • Parameters
  • Example
  • getPreviousNode(nodeId)⇒ *
  • Parameters
  • deleteNode(name, node, options)
  • Parameters
  • Example
  • getDocumentNodes()⇒ Array

Was this helpful?

  1. API Reference
  2. Writer Api

Document

insertTextNode(options)⇒ object | undefined

Insert a text node in specified place of the document using an insert strategy based on the options object. The options object and all properties are optional. Return the created node only if using an existing transaction (tx).

  • tx: Optional TransactionDocument

  • mode: Insert node where: first, last, before or after

  • refNode: If insert mode is before or after a reference node is mandatory

  • text: Optional text content

  • type: Text style type, ie paragraph, preamble, etc

Parameters

Param
Type
Description

options

Object

Required - Optional object with optional properties

Example

// Insert new empty paragraph at cursor position (or last if no cursor in text)
import {api} from 'writer'
api.document.insertTextNode()

Example

// Insert a preamble with content after the first node in the document as part of your own transaction
import {api} from 'writer'
const firstNode = api.document.nodes()
api.editorSession.transaction(tx => {
  api.document.insert({
    tx: tx,
    type: 'preamble',
    text: 'My new preamble',
    mode: 'after',
    refNode: nodes[0] // First node
  })
})

insertBlockNode(options)⇒ object | undefined

Insert a block node in specified place of the document using an insert strategy based on the options object. The data property that defines the node is mandatory. All other properties are optional. (To insert a node the node type must be defined by a plugin and known to the Writer.) Return the created node only if using an existing transaction (tx).

  • data: Mandatory object describing the node, may or may not have an id

  • tx: Optional TransactionDocument

  • mode: Insert node where: first, last, before or after

  • refNode: If insert mode is before or after a reference node is mandatory

Parameters

Param
Type
Description

options

Object | string

Required - Optional object with optional properties

Example

// Insert a new node of type "myquote"
import {api} from 'writer'

api.document.insertBlockNode({
  data: {
    type: 'myquote',
    content: 'People who deny the existence of dragons are often eaten by dragons'
    attribution: 'Ursula K. Le Guin'
  }
})

Example

// Insert a new node after the first node in the document as part of your own transaction
import {api} from 'writer'

const firstNode = api.document.nodes()
api.editorSession.transaction(tx => {
  api.document.insert({
    tx: tx,
    data: {
      type: 'myquote',
      content: 'People who deny the existence of dragons are often eaten by dragons'
      attribution: 'Ursula K. Le Guin'
    },
    mode: 'after',
    refNode: nodes[0] // First node
  })
})

nodes(filter)⇒ array

Fetch all nodes in the document, optionally filtered by type

Parameters

Param
Type
Default
Description

filter

string | null

null

Required - Optional filter returned nodes by type

Example

// Fetch all image nodes in the document
import {api} from 'writer'

const nodes = api.document.nodes('ximimage')

node(nodeId)⇒ Node | null

Fetch single node from document by id

Parameters

Param
Type

nodeId

string

Example

import {api} from 'writer'

const node = api.document.node('paragraph-ba10e7b6b56c5dbbede2e504f5ba40d6')

triggerFetchResourceNode(node, info)

Triggers a fetch resource from a nodes url property. For example when node has properties that is only referenced through an external url.

Parameters

Param
Type
Description

node

BlockNode

Required - The resource node

info

Object

Required - Object with information to created substance transaction

Example

import {api} from 'writer'

// Fetch oauth from Instagram, don't save this fetch in undo/redo history
api.document.triggerFetchResourceNode(this.props.node, { history: false })

getPreviousNode(nodeId)⇒ *

Retrieve the previous node. Uses the focused surface to get all nodes in that surface/container and then returns the previous node from the one sent in

Parameters

Param
Type

nodeId

string

deleteNode(name, node, options)

Deletes a node from the document. Triggers a 'document:changed' event to all document:changed listeners except the plugin making the change.

Parameters

Param
Type
Description

name

string

Required - Plugin name

node

object

Required - Node to delete, must contain an id

options

object

Required - Optional options object. Set replaceWithDefaultTextNode to true to replace node with default text node

Example

import {api} from 'writer'
api.deleteNode(this.props.node);

getDocumentNodes()⇒ Array

Deprecated

Get all nodes in the document

PreviousConceptServiceNextEvents

Was this helpful?