@myrmidon/cadmus-text-ed-md
TypeScript icon, indicating that this package has built-in type declarations

5.1.0 • Public • Published

Cadmus Text Editor Service - Markdown

This library was generated with Angular CLI version 17.3.0.

This library contains Markdown-related plugins for the Cadmus text editing service.

These plugins can be used to provide shortcuts to frequent edit tasks like toggling bold or italic, or providing more complex logic in assisting edits.

Plugins

Toggle Bold

  • 🔑 md.bold (MdBoldCtePlugin)

This plugin toggles bold text on or off using two asterisks for it. It expects a text, and if it finds a bold span inside it it removes the wrapper asterisks; else, it wraps the text in them.

Toggle Italic

  • 🔑 md.italic (MdItalicCtePlugin)

This plugin toggles italic text on or off using one asterisk for it. It expects a text, and if it finds a bold span inside it it removes the wrapper asterisks; else, it wraps the text in them.

Insert Link

  • 🔑 md.link (MdLinkCtePlugin)

This plugin assists in inserting or editing Markdown links via lookup. These links have a JSON string as their target, where ) is rendered as \) to avoid issues with Markdown parsers.

The JSON target is built from an asserted composite ID UI, so it can represent an internal or an external link. For external links, you can configure the lookup providers via a storage service (RamStorageService) with key ASSERTED_COMPOSITE_ID_CONFIGS_KEY , e.g.:

// assuming we got RamStorageService via injection

storage.store(ASSERTED_COMPOSITE_ID_CONFIGS_KEY, [
  {
    name: 'colors',
    iconUrl: '/assets/img/colors128.png',
    description: 'Colors',
    label: 'color',
    service: new WebColorLookup(),
    itemIdGetter: (item: any) => item?.value,
    itemLabelGetter: (item: any) => item?.name,
  },
  {
    name: 'VIAF',
    iconUrl: '/assets/img/viaf128.png',
    description: 'Virtual International Authority File',
    label: 'ID',
    service: viaf,
    itemIdGetter: (item: any) => item?.viafid,
    itemLabelGetter: (item: any) => item?.term,
  },
  {
    name: 'geonames',
    iconUrl: '/assets/img/geonames128.png',
    description: 'GeoNames',
    label: 'ID',
    service: geonames,
    itemIdGetter: (item: any) => item?.geonameId,
    itemLabelGetter: (item: any) => item?.name,
  },
] as RefLookupConfig[]);

Example

For an example usage with a Monaco editor instance see the text editor service demo page.

Readme

Keywords

Package Sidebar

Install

npm i @myrmidon/cadmus-text-ed-md

Weekly Downloads

5

Version

5.1.0

License

none

Unpacked Size

91.3 kB

Total Files

16

Last publish

Collaborators

  • myrmidon