Skip to content

Commit

Permalink
Merge pull request #3194 from KorovinQuantori/main
Browse files Browse the repository at this point in the history
Export plugin keys for easier access plugin options by key
  • Loading branch information
zbeyens committed May 13, 2024
2 parents 7430c96 + b9f1204 commit 15f060a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .changeset/fresh-turkeys-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@udecode/plate-basic-elements": patch
"@udecode/plate-basic-marks": patch
"@udecode/plate-normalizers": patch
"@udecode/plate-heading": patch
"@udecode/plate-core": patch
"@udecode/plate-list": patch
---

Export plugin keys for easier access plugin options by key
4 changes: 3 additions & 1 deletion packages/basic-elements/src/createBasicElementsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { createPluginFactory } from '@udecode/plate-common/server';
import { createHeadingPlugin } from '@udecode/plate-heading';
import { createParagraphPlugin } from '@udecode/plate-paragraph';

export const KEY_BASIC_ELEMENTS = 'basicElements';

/**
* Enables support for basic elements:
*
Expand All @@ -13,7 +15,7 @@ import { createParagraphPlugin } from '@udecode/plate-paragraph';
* - Paragraph
*/
export const createBasicElementsPlugin = createPluginFactory({
key: 'basicElements',
key: KEY_BASIC_ELEMENTS,
plugins: [
createBlockquotePlugin(),
createCodeBlockPlugin(),
Expand Down
4 changes: 3 additions & 1 deletion packages/basic-marks/src/createBasicMarksPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { createSubscriptPlugin } from './createSubscriptPlugin';
import { createSuperscriptPlugin } from './createSuperscriptPlugin';
import { createUnderlinePlugin } from './createUnderlinePlugin';

export const KEY_BASIC_MARKS = 'basicMarks';

/**
* Enables support for basic marks:
*
Expand All @@ -20,7 +22,7 @@ import { createUnderlinePlugin } from './createUnderlinePlugin';
* - Underline
*/
export const createBasicMarksPlugin = createPluginFactory({
key: 'basicMarks',
key: KEY_BASIC_MARKS,
plugins: [
createBoldPlugin(),
createCodePlugin(),
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/client/plugins/react/createReactPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createPluginFactory } from '../../../shared/utils/createPluginFactory';
import { withTReact } from './withTReact';

export const KEY_REACT = 'react';

/** @see {@link withReact} */
export const createReactPlugin = createPluginFactory({
key: 'react',
key: KEY_REACT,
withOverrides: withTReact,
});
4 changes: 3 additions & 1 deletion packages/core/src/shared/plugins/createHistoryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { withHistory } from 'slate-history';

import { createPluginFactory } from '../utils/createPluginFactory';

export const KEY_HISTORY = 'history';

export const withTHistory = <
V extends Value = Value,
E extends TEditor<V> = TEditor<V>,
Expand All @@ -14,6 +16,6 @@ export const withTHistory = <

/** @see {@link withHistory} */
export const createHistoryPlugin = createPluginFactory({
key: 'history',
key: KEY_HISTORY,
withOverrides: withTHistory,
});
4 changes: 3 additions & 1 deletion packages/heading/src/createHeadingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import type { HeadingPlugin, HeadingsPlugin } from './types';

import { KEYS_HEADING } from './constants';

export const KEY_HEADING = 'heading';

/** Enables support for headings with configurable levels (from 1 to 6). */
export const createHeadingPlugin = createPluginFactory<HeadingsPlugin>({
key: 'heading',
key: KEY_HEADING,
options: {
levels: [1, 2, 3, 4, 5, 6],
},
Expand Down
4 changes: 3 additions & 1 deletion packages/list/src/createListPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { ListPlugin } from './types';
import { onKeyDownList } from './onKeyDownList';
import { withList } from './withList';

export const KEY_LIST = 'list';

export const ELEMENT_UL = 'ul';

export const ELEMENT_OL = 'ol';
Expand All @@ -20,7 +22,7 @@ export const ELEMENT_LIC = 'lic';

/** Enables support for bulleted, numbered and to-do lists. */
export const createListPlugin = createPluginFactory({
key: 'list',
key: KEY_LIST,
plugins: [
{
deserializeHtml: {
Expand Down
4 changes: 3 additions & 1 deletion packages/normalizers/src/createRemoveEmptyNodesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ export interface RemoveEmptyNodesPlugin {
types?: string | string[];
}

export const KEY_REMOVE_EMPTY_NODES = 'removeEmptyNodes'

/** @see {@link withRemoveEmptyNodes} */
export const createRemoveEmptyNodesPlugin =
createPluginFactory<RemoveEmptyNodesPlugin>({
key: 'removeEmptyNodes',
key: KEY_REMOVE_EMPTY_NODES,
withOverrides: withRemoveEmptyNodes,
});

0 comments on commit 15f060a

Please sign in to comment.