Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

lblod/ember-rdfa-editor-table-of-contents-plugin

Repository files navigation

ember-rdfa-editor-table-of-contents-plugin

⚠️ This ember addon is no longer maintained. Please use @lblod/ember-rdfa-editor-lblod-plugins instead.

This plugin implements an auto-refreshing table of contents using an ember-rdfa-editor inline component.

How to configure the plugin

In order to enable the plugin you need to add 'rdfa-toc' to the list of plugins passed to the rdfa-editor. You can configure the plugin with a custom table of contents configuration like this:

plugins = [
  { name: 'rdfa-toc', 
    options: { 
      config: {
        sectionPredicate: 'https://say.data.gift/ns/hasPart',
        value: {
          predicate: 'https://say.data.gift/ns/heading',
        },
      },
      {
        sectionPredicate: 'https://say.data.gift/ns/hasParagraph',
        value: '§',
      }, 
    } 
  },
]

A table of contents component instance with a custom config can be inserted into the editor using:

controller.executeCommand(
      'insert-component',
      'inline-components/table-of-contents',
      {
        config: [
          {
            sectionPredicate: 'https://say.data.gift/ns/hasPart',
            value: {
              predicate: 'https://say.data.gift/ns/heading',
            },
          },
          {
            sectionPredicate: 'https://say.data.gift/ns/hasParagraph',
            value: '§',
          },
        ],
      },
      {},
      false
    );

The dummy application of this plugin contains a working example with custom configuration.