npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@halloverden/ngx-directus-content-handler

v1.0.0-rc.5

Published

This package simplifies handling the content delivered from the [Flexible Editor Extension](https://github.com/formfcw/directus-extension-flexible-editor) for Directus. It supports some of the most common content and mark types, and allows you to provide

Readme

@halloverden/ngx-directus-content-handler

This package simplifies handling the content delivered from the Flexible Editor Extension for Directus. It supports some of the most common content and mark types, and allows you to provide your own implementations of both content handlers and mark handlers for any content type you like.

The flexible editor content service

This service is used when handling content from the Flexible Editor Extension. It has the following public methods:

| Signature | Description | |---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | static prioritySorterFunction(a: ContentHandlerInterface | MarkHandlerInterface, b: ContentHandlerInterface | MarkHandlerInterface): 0 | 1 | -1 | An array sorter function used for sorting by the priority property. | | static getTypeName(content: any): string | Returns the type name of any given content. | | getSupportedContentHandler(type: string, contentHandlers: ContentHandlerInterface[]): ContentHandlerInterface | Returns the first content handler, by priority, that supports the given type. Throws an error if no content handler was found for the given type. | | getSupportedMarkHandler(type: string, markHandlers: MarkHandlerInterface[]): MarkHandlerInterface | Returns the first mark handler, by priority, that supports the given type. Throws an error if no mark handler was found for the given type. | | static getCommentPlaceholder(comment: string, sanitizer: DomSanitizer): DynamicContentInterface | Returns an instance of DynamicContentInterface with a safeHtml comment instance. Used internally when handlers are missing. | | addContentHandler(contentHandler: ContentHandlerInterface): void | Adds a content handler to the service. Use this if you want to add a content handler without providing it through the config. | | removeContentHandler(contentHandler: ContentHandlerInterface): void | Removes a content handler from the service. | | getContentHandlers(): ContentHandlerInterface[] | Returns all content handlers. | | addMarkHandler(markHandler: MarkHandlerInterface): void | Adds a mark handler to the service. Use this if you want to add a mark handler without providing it through the config. | | removeMarkHandler(markHandler: MarkHandlerInterface): void | Removes a mark handler from the service. | | getMarkHandlers(): MarkHandlerInterface[] | Returns all mark handlers. | | handleFlexibleEditorDoc(doc: any, editorNodes?: EditorNode[]): DynamicContentInterface[] | Takes the doc and editor nodes from the Flexible Editor, and returns an array of DynamicContentInterface. This array can be provided directly to the dynamic container component. |

The dynamic container component

This component has a single input, content, that is an array of DynamicContentInterface. The interface looks like this:

interface DynamicContentInterface {
  component?: {
    type: Type<any>,
    inputs?: { [key: string]: any }
  };
  htmlElement?: HTMLElement;
  safeHtml?: SafeHtml;
  text?: string;
}

The component will output to the DOM, an instance of whatever component or SafeHtml the interface contains. It can even handle instances of the interface that contain a component reference to itself:

const content = {
  component: {
    type: DynamicContainerComponent,
    inputs: {
      content: somethingSomethingContent,
    },
  },
};
<hv-ngx-directus-dynamic-content-container [content]="content" />

Content Handlers

Provided by using the NGX_DIRECTUS_CONTENT_HANDLER_CONTENT_HANDLERS_INJECTION_TOKEN injection token:

export function provideContentHandlers(): EnvironmentProviders {
  return makeEnvironmentProviders([
    {
      provide: NGX_DIRECTUS_CONTENT_HANDLER_CONTENT_HANDLERS_INJECTION_TOKEN,
      multi: true,
      useClass: ImageWithAltTextContentHandler
    },
    {
      provide: NGX_DIRECTUS_CONTENT_HANDLER_CONTENT_HANDLERS_INJECTION_TOKEN,
      multi: true,
      useClass: SalaryTableReferenceContentHandler
    }
  ]);
}

If you've got a lot of custom content types, you can provide a single content handler that has support for all your custom content types, that delegates to whatever classes or functions you might want to use.

Mark Handlers

Provided by using the NGX_DIRECTUS_CONTENT_HANDLER_MARK_HANDLERS_INJECTION_TOKEN injection token:

export function provideContentHandlers(): EnvironmentProviders {
  return makeEnvironmentProviders([
    {
      provide: NGX_DIRECTUS_CONTENT_HANDLER_MARK_HANDLERS_INJECTION_TOKEN,
      multi: true,
      useClass: MyMarkHandler
    },
  ]);
}

If you've got a lot of custom mark types, you can provide a single mark handler that has support for all your custom mark types, that delegates to whatever classes or functions you might want to use.