refactor: remove extensions enum from editor package

This commit is contained in:
Aaryan Khandelwal
2026-01-16 19:22:12 +05:30
parent fa1b4a102a
commit 546198f3b6
56 changed files with 60 additions and 107 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
// plane imports
import type { ADDITIONAL_EXTENSIONS } from "@plane/utils";
// helpers
import type { TAssetMetaDataRecord } from "@/helpers/assets";
// local imports
import type { ADDITIONAL_EXTENSIONS } from "./extensions";
export const ADDITIONAL_ASSETS_META_DATA_RECORD: Partial<Record<ADDITIONAL_EXTENSIONS, TAssetMetaDataRecord>> = {};
@@ -1,3 +1 @@
export enum ADDITIONAL_EXTENSIONS {}
export const ADDITIONAL_BLOCK_NODE_TYPES = [];
@@ -6,7 +6,7 @@ import { useCallback, useEffect, useRef } from "react";
import { cn } from "@plane/utils";
// constants
import { DEFAULT_DISPLAY_CONFIG } from "@/constants/config";
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// components
import type { TCollabValue } from "@/contexts";
import { LinkContainer } from "@/plane-editor/components/link-container";
@@ -3,7 +3,7 @@ import { TableMap } from "@tiptap/pm/tables";
import type { Editor } from "@tiptap/react";
import { MoveHorizontal } from "lucide-react";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import type { BlockMenuOption } from "./block-menu";
@@ -15,7 +15,7 @@ import { CopyIcon, TrashIcon } from "@plane/propel/icons";
import type { ISvgIcons } from "@plane/propel/icons";
import { cn } from "@plane/utils";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import type { IEditorProps } from "@/types";
// components
@@ -6,7 +6,7 @@ import { LinkIcon, TrashIcon, CheckIcon } from "@plane/propel/icons";
// plane imports
import { cn } from "@plane/utils";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { isValidHttpUrl } from "@/helpers/common";
import { setLinkEditor, unsetLinkEditor } from "@/helpers/editor-commands";
@@ -22,7 +22,7 @@ import {
} from "@/components/menus";
// constants
import { COLORS_LIST } from "@/constants/common";
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import { isCellSelection } from "@/extensions/table/table/utilities/helpers";
// types
@@ -25,7 +25,7 @@ import {
import type { LucideIcon } from "lucide-react";
import { LinkIcon } from "@plane/propel/icons";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import {
insertHorizontalRule,
@@ -1,49 +1,5 @@
export enum CORE_EXTENSIONS {
BLOCKQUOTE = "blockquote",
BOLD = "bold",
BULLET_LIST = "bulletList",
CALLOUT = "calloutComponent",
CHARACTER_COUNT = "characterCount",
CODE_BLOCK = "codeBlock",
CODE_INLINE = "code",
CUSTOM_COLOR = "customColor",
CUSTOM_IMAGE = "imageComponent",
CUSTOM_LINK = "link",
DOCUMENT = "doc",
DROP_CURSOR = "dropCursor",
ENTER_KEY = "enterKey",
GAP_CURSOR = "gapCursor",
HARD_BREAK = "hardBreak",
HEADING = "heading",
HEADINGS_LIST = "headingsList",
HISTORY = "history",
HORIZONTAL_RULE = "horizontalRule",
IMAGE = "image",
ITALIC = "italic",
LIST_ITEM = "listItem",
MARKDOWN_CLIPBOARD = "markdownClipboard",
MENTION = "mention",
ORDERED_LIST = "orderedList",
PARAGRAPH = "paragraph",
PLACEHOLDER = "placeholder",
SIDE_MENU = "editorSideMenu",
SLASH_COMMANDS = "slash-command",
STRIKETHROUGH = "strike",
TABLE = "table",
TABLE_CELL = "tableCell",
TABLE_HEADER = "tableHeader",
TABLE_ROW = "tableRow",
TASK_ITEM = "taskItem",
TASK_LIST = "taskList",
TEXT_ALIGN = "textAlign",
TEXT_STYLE = "textStyle",
TYPOGRAPHY = "typography",
UNDERLINE = "underline",
UTILITY = "utility",
WORK_ITEM_EMBED = "issue-embed-component",
EMOJI = "emoji",
UNIQUE_ID = "uniqueID",
}
// plane imports
import { CORE_EXTENSIONS } from "@plane/utils";
export const BLOCK_NODE_TYPES = [
// Basic block nodes
@@ -2,7 +2,7 @@ import { Node, mergeAttributes } from "@tiptap/core";
import type { MarkdownSerializerState } from "@tiptap/pm/markdown";
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import { ECalloutAttributeNames } from "./types";
import type { CustomCalloutExtensionType, TCalloutBlockAttributes } from "./types";
@@ -1,7 +1,7 @@
import { findParentNodeClosestToPos, ReactNodeViewRenderer } from "@tiptap/react";
import type { Predicate } from "@tiptap/react";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { insertEmptyParagraphAtNodeBoundaries } from "@/helpers/insert-empty-paragraph-at-node-boundary";
// local imports
@@ -1,6 +1,6 @@
import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
type InlineCodeOptions = {
HTMLAttributes: Record<string, unknown>;
@@ -1,7 +1,7 @@
import { mergeAttributes, Node, textblockTypeInputRule } from "@tiptap/core";
import { Plugin, PluginKey } from "@tiptap/pm/state";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
export type CodeBlockOptions = {
/**
@@ -1,7 +1,7 @@
import { Mark, mergeAttributes } from "@tiptap/core";
// constants
import { COLORS_LIST } from "@/constants/common";
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
import { cn } from "@plane/utils";
// constants
import { ACCEPTED_IMAGE_MIME_TYPES } from "@/constants/config";
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import type { EFileError } from "@/helpers/file";
// hooks
@@ -1,7 +1,7 @@
import { mergeAttributes } from "@tiptap/core";
import { Image as BaseImageExtension } from "@tiptap/extension-image";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// local imports
import { ECustomImageAttributeNames } from "./types";
import type {
@@ -3,7 +3,7 @@ import { Mark, markPasteRule, mergeAttributes } from "@tiptap/core";
import type { Plugin } from "@tiptap/pm/state";
import { find, registerCustomProtocol, reset } from "linkifyjs";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { isValidHttpUrl } from "@/helpers/common";
// local imports
@@ -3,7 +3,7 @@ import { getNodeType, getNodeAtPosition, isAtEndOfNode, isAtStartOfNode, isNodeA
import type { Node, NodeType } from "@tiptap/pm/model";
import type { EditorState } from "@tiptap/pm/state";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
const findListItemPos = (typeOrName: string | NodeType, state: EditorState) => {
const { $from } = state.selection;
@@ -1,6 +1,6 @@
import { Extension } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import { handleBackspace, handleDelete } from "@/extensions/custom-list-keymap/list-helpers";
@@ -2,7 +2,7 @@ import type { EmojiOptions, EmojiStorage } from "@tiptap/extension-emoji";
import { ReactRenderer } from "@tiptap/react";
import type { Editor } from "@tiptap/react";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { updateFloatingUIFloaterPosition } from "@/helpers/floating-ui";
import type { CommandListInstance } from "@/helpers/tippy";
@@ -1,6 +1,6 @@
import { Extension } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
export const EnterKeyExtension = (onEnterKeyPress?: () => void) =>
Extension.create({
@@ -1,7 +1,7 @@
import { Extension } from "@tiptap/core";
import { Plugin, PluginKey } from "@tiptap/pm/state";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import type { IMarking } from "@/types";
@@ -1,7 +1,7 @@
import { isNodeSelection, mergeAttributes, Node, nodeInputRule } from "@tiptap/core";
import { NodeSelection, TextSelection } from "@tiptap/pm/state";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
type HorizontalRuleOptions = {
HTMLAttributes: Record<string, unknown>;
@@ -1,6 +1,6 @@
import { ReactNodeViewRenderer } from "@tiptap/react";
// constants
import type { CORE_EXTENSIONS } from "@/constants/extension";
// plane imports
import type { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { insertEmptyParagraphAtNodeBoundaries } from "@/helpers/insert-empty-paragraph-at-node-boundary";
// types
@@ -4,7 +4,7 @@ import type { Transaction } from "@tiptap/pm/state";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { canJoin } from "@tiptap/pm/transform";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
@@ -2,7 +2,7 @@ import { ReactRenderer } from "@tiptap/react";
import type { Editor } from "@tiptap/react";
import type { SuggestionOptions } from "@tiptap/suggestion";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { updateFloatingUIFloaterPosition } from "@/helpers/floating-ui";
import type { CommandListInstance } from "@/helpers/tippy";
@@ -1,6 +1,6 @@
import { Placeholder } from "@tiptap/extension-placeholder";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import type { IEditorProps } from "@/types";
+1 -1
View File
@@ -1,6 +1,6 @@
import Blockquote from "@tiptap/extension-blockquote";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
export const CustomQuoteExtension = Blockquote.extend({
addKeyboardShortcuts() {
@@ -2,7 +2,7 @@ import { Extension } from "@tiptap/core";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import type { EditorView } from "@tiptap/pm/view";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// plugins
import { AIHandlePlugin } from "@/plugins/ai-handle";
import { DragHandlePlugin, nodeDOMAtCoords } from "@/plugins/drag-handle";
@@ -4,7 +4,7 @@ import { ReactRenderer } from "@tiptap/react";
import Suggestion from "@tiptap/suggestion";
import type { SuggestionOptions } from "@tiptap/suggestion";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { updateFloatingUIFloaterPosition } from "@/helpers/floating-ui";
import type { CommandListInstance } from "@/helpers/tippy";
@@ -6,7 +6,7 @@ import { ChevronRightIcon } from "@plane/propel/icons";
import { cn } from "@plane/utils";
// constants
import { COLORS_LIST } from "@/constants/common";
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// TODO: implement text color selector
@@ -16,7 +16,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
// plane imports
import { cn } from "@plane/utils";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import {
findTable,
@@ -16,7 +16,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
// plane imports
import { cn } from "@plane/utils";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import {
findTable,
@@ -1,6 +1,6 @@
import type { Editor } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
import { CORE_EDITOR_META } from "@/constants/meta";
/**
@@ -1,7 +1,7 @@
import { mergeAttributes, Node } from "@tiptap/core";
import { TableMap } from "@tiptap/pm/tables";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { findParentNodeOfType } from "@/helpers/common";
// local imports
@@ -1,6 +1,6 @@
import { mergeAttributes, Node } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// local imports
import { DEFAULT_COLUMN_WIDTH } from "./table";
@@ -1,6 +1,6 @@
import { mergeAttributes, Node } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
type TableRowOptions = {
HTMLAttributes: Record<string, unknown>;
@@ -20,7 +20,7 @@ import {
toggleHeaderCell,
} from "@tiptap/pm/tables";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// local imports
import { TableColumnDragHandlePlugin } from "../plugins/drag-handles/column/plugin";
import { TableRowDragHandlePlugin } from "../plugins/drag-handles/row/plugin";
@@ -4,7 +4,7 @@ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
import type { CellSelection } from "@tiptap/pm/tables";
import { TableMap } from "@tiptap/pm/tables";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import { isCellEmpty, isCellSelection } from "@/extensions/table/table/utilities/helpers";
@@ -5,7 +5,7 @@ import type { EditorState, Selection, Transaction } from "@tiptap/pm/state";
import { CellSelection, TableMap } from "@tiptap/pm/tables";
import type { Rect } from "@tiptap/pm/tables";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
/**
* @description Check if the selection is a cell selection
@@ -1,6 +1,6 @@
import type { KeyboardShortcutCommand } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { findParentNodeOfType } from "@/helpers/common";
@@ -1,6 +1,6 @@
import type { KeyboardShortcutCommand } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// helpers
import { findParentNodeOfType } from "@/helpers/common";
@@ -2,7 +2,7 @@ import { Extension } from "@tiptap/core";
import type { NodeType, Node as ProseMirrorNode } from "@tiptap/pm/model";
import { Plugin, PluginKey } from "@tiptap/pm/state";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
function nodeEqualsType({ types, node }: { types: NodeType[]; node: ProseMirrorNode | null }) {
// TODO: check this logic, might be wrong
@@ -1,7 +1,7 @@
import type { InputRule } from "@tiptap/core";
import { Extension } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
import type { TypographyOptions } from "./inputRules";
import {
emDash,
@@ -3,12 +3,13 @@ import { Extension } from "@tiptap/core";
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
import type { Transaction } from "@tiptap/pm/state";
import { v4 as uuidv4 } from "uuid";
// plane imports
import { CORE_EXTENSIONS } from "@plane/utils";
// constants
import { CORE_EXTENSIONS, BLOCK_NODE_TYPES } from "@/constants/extension";
import { BLOCK_NODE_TYPES } from "@/constants/extension";
import { ADDITIONAL_BLOCK_NODE_TYPES } from "@/plane-editor/constants/extensions";
import { createUniqueIDPlugin } from "./plugin";
import { createIdsForView } from "./utils";
// plane imports
const COMBINED_BLOCK_NODE_TYPES = [...BLOCK_NODE_TYPES, ...ADDITIONAL_BLOCK_NODE_TYPES];
export type UniqueIDGenerationContext = {
@@ -1,7 +1,7 @@
import { Extension } from "@tiptap/core";
import codemark from "prosemirror-codemark";
// helpers
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
import { restorePublicImages } from "@/helpers/image-helpers";
// plugins
import type { TAdditionalActiveDropbarExtensions } from "@/plane-editor/types/utils";
@@ -1,6 +1,6 @@
import { mergeAttributes, Node } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
export const WorkItemEmbedExtensionConfig = Node.create({
name: CORE_EXTENSIONS.WORK_ITEM_EMBED,
+1 -1
View File
@@ -3,7 +3,7 @@ import type { EditorState, Selection } from "@tiptap/pm/state";
// plane imports
import { cn } from "@plane/utils";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
type EditorClassNameArgs = {
noBorder?: boolean;
@@ -1,6 +1,6 @@
import type { Editor, Range } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import { replaceCodeWithText } from "@/extensions/code/utils/replace-code-block-with-text";
import type { InsertImageComponentProps } from "@/extensions/custom-image/types";
@@ -7,7 +7,7 @@ import { convertHTMLToMarkdown } from "@plane/utils";
// components
import { getEditorMenuItems } from "@/components/menus";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
import { CORE_EDITOR_META } from "@/constants/meta";
// types
import type { EditorRefApi, IEditorProps, TEditorCommands } from "@/types";
@@ -1,6 +1,6 @@
import type { Editor } from "@tiptap/core";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// types
import type { TFileHandler } from "@/types";
@@ -1,7 +1,7 @@
import type { KeyboardShortcutCommand } from "@tiptap/core";
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
type Direction = "up" | "down";
@@ -3,7 +3,7 @@ import { Fragment, Slice } from "@tiptap/pm/model";
import { NodeSelection } from "@tiptap/pm/state";
import type { EditorView } from "@tiptap/pm/view";
// constants
import { CORE_EXTENSIONS } from "@/constants/extension";
import { CORE_EXTENSIONS } from "@plane/utils";
// extensions
import type { SideMenuHandleOptions, SideMenuPluginProps } from "@/extensions";
+2 -2
View File
@@ -1,5 +1,5 @@
// constants
import type { CORE_EXTENSIONS } from "@/constants/extension";
// plane imports
import type { CORE_EXTENSIONS } from "@plane/utils";
// plane editor imports
import type { TAdditionalEditorAsset } from "@/plane-editor/types/asset";
-3
View File
@@ -13,9 +13,6 @@ export * from "@/constants/common";
export * from "@/helpers/common";
export * from "@/helpers/yjs-utils";
export { CORE_EXTENSIONS } from "@/constants/extension";
export { ADDITIONAL_EXTENSIONS } from "@/plane-editor/constants/extensions";
// types
export * from "@/types";
+1
View File
@@ -95,6 +95,7 @@ export enum CORE_EXTENSIONS {
UTILITY = "utility",
WORK_ITEM_EMBED = "issue-embed-component",
EMOJI = "emoji",
UNIQUE_ID = "uniqueID",
}
export enum ADDITIONAL_EXTENSIONS {}