Typix LogoTypix
Extensions

Keywords

Highlight specific keywords in the editor

The Keywords extension highlights predefined keywords in the editor content using a custom KeywordNode.

Demo

Typix
Loading preview…
import {  createEditorConfig,  defaultExtensionNodes,  defaultTheme,  EditorContent,  EditorRoot,} from "@typix-editor/react";import {  KeywordsExtension,  KeywordNode,} from "@typix-editor/extension-keywords";import { Toolbar } from "./Toolbar";const config = createEditorConfig({  extensionNodes: [...defaultExtensionNodes, KeywordNode],  theme: defaultTheme,});export default function KeywordsExample() {  return (    <EditorRoot config={config}>      <div className="editor-container">        <Toolbar />        <EditorContent placeholder='Type your message… (Try "congratulations", "felicitaciones", "恭喜", "축하해")' />      </div>      <KeywordsExtension />    </EditorRoot>  );}

Installation

pnpm add @typix-editor/extension-keywords
npm install @typix-editor/extension-keywords
yarn add @typix-editor/extension-keywords

Setup

Register the KeywordNode and add the extension:

import { createEditorConfig, defaultExtensionNodes } from '@typix-editor/react';
import { KeywordsExtension, KeywordNode } from '@typix-editor/extension-keywords';

const config = createEditorConfig({
  extensionNodes: [...defaultExtensionNodes, KeywordNode],
});

function MyEditor() {
  return (
    <EditorRoot config={config}>
      <EditorContent />
      <KeywordsExtension />
    </EditorRoot>
  );
}

Exports

ExportTypeDescription
KeywordsExtensionComponentThe keyword detection plugin
KeywordNodeLexical NodeNode for highlighted keywords
$createKeywordNodeFunctionCreate a keyword node
$isKeywordNodeFunctionType guard for keyword nodes

Nodes

NodeDescription
KeywordNodeRenders keyword text with special styling. Must be registered in editor config.

On this page