@react-email/editor 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.cjs +3 -3
- package/dist/{core-D7AzzMLI.cjs → core-x9hglA_7.cjs} +2 -2
- package/dist/{email-node-hLU5bGnX.cjs → email-node-BFhsqjxz.cjs} +1 -1
- package/dist/{event-bus-CIJ___tH.cjs → event-bus-DbKKne9G.cjs} +1 -1
- package/dist/{extension-BdIuM7po.cjs → extension-DadHTZr7.cjs} +2 -2
- package/dist/{extension-DRd-7Enf.cjs → extension-KPXoxV9s.cjs} +2 -2
- package/dist/extensions/index.cjs +14 -10
- package/dist/extensions/index.d.cts +3 -1
- package/dist/extensions/index.d.cts.map +1 -1
- package/dist/extensions/index.d.mts +3 -1
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-D0ASDGwU.cjs → extensions-OWBg5IcG.cjs} +52 -50
- package/dist/{extensions-P230KRxk.mjs → extensions-embyYB59.mjs} +6 -4
- package/dist/{extensions-P230KRxk.mjs.map → extensions-embyYB59.mjs.map} +1 -1
- package/dist/{columns-BItFgD76.mjs → focus-scopes-8q9tO1ue.mjs} +110 -4
- package/dist/focus-scopes-8q9tO1ue.mjs.map +1 -0
- package/dist/focus-scopes-BLTX2pJU.d.cts +31 -0
- package/dist/focus-scopes-BLTX2pJU.d.cts.map +1 -0
- package/dist/{columns-DqFvXgmK.cjs → focus-scopes-CGUz8PLF.cjs} +131 -1
- package/dist/focus-scopes-CKTuaMk3.d.mts +31 -0
- package/dist/focus-scopes-CKTuaMk3.d.mts.map +1 -0
- package/dist/{image-B7AFZcee.cjs → image-Td_Smj-b.cjs} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.cjs +4 -4
- package/dist/plugins/index.d.cts +2 -2
- package/dist/plugins/index.d.mts +2 -2
- package/dist/{root-CtxOGDXP.cjs → root--eD8m9YM.cjs} +99 -10
- package/dist/{root-D4oiPckX.mjs → root-BPWrOnKS.mjs} +72 -7
- package/dist/root-BPWrOnKS.mjs.map +1 -0
- package/dist/{types-BMFC8G4N.d.mts → types-ALwc36ll.d.cts} +2 -2
- package/dist/{types-BMFC8G4N.d.mts.map → types-ALwc36ll.d.cts.map} +1 -1
- package/dist/{types-CPfNU4D9.d.cts → types-B2yr4rz3.d.cts} +1 -1
- package/dist/{types-CPfNU4D9.d.cts.map → types-B2yr4rz3.d.cts.map} +1 -1
- package/dist/{types-hURXpEIO.d.cts → types-BG5XsXt9.d.mts} +2 -2
- package/dist/{types-hURXpEIO.d.cts.map → types-BG5XsXt9.d.mts.map} +1 -1
- package/dist/{types-S2DvzFom.d.mts → types-DzqGGKXD.d.mts} +1 -1
- package/dist/{types-S2DvzFom.d.mts.map → types-DzqGGKXD.d.mts.map} +1 -1
- package/dist/ui/index.cjs +14 -96
- package/dist/ui/index.d.cts +11 -9
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +10 -8
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +4 -86
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/columns-BItFgD76.mjs.map +0 -1
- package/dist/root-D4oiPckX.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as inlineCssToJs, t as EmailNode } from "./email-node-B-_g4X-S.mjs";
|
|
2
2
|
import { Column, Row } from "react-email";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { mergeAttributes } from "@tiptap/core";
|
|
5
|
-
import { TextSelection } from "@tiptap/pm/state";
|
|
4
|
+
import { Extension, extensions, mergeAttributes } from "@tiptap/core";
|
|
5
|
+
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
6
6
|
//#region src/utils/attribute-helpers.ts
|
|
7
7
|
/**
|
|
8
8
|
* Creates TipTap attribute definitions for a list of HTML attributes.
|
|
@@ -268,6 +268,112 @@ const ColumnsColumn = EmailNode.create({
|
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
//#endregion
|
|
271
|
-
|
|
271
|
+
//#region src/extensions/focus-scopes.ts
|
|
272
|
+
const focusScopePluginKey = new PluginKey("reactEmailFocusScopes");
|
|
273
|
+
const noop = () => {};
|
|
274
|
+
function createFocusScopesStorage() {
|
|
275
|
+
return {
|
|
276
|
+
registerScope: noop,
|
|
277
|
+
unregisterScope: noop
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function createFocusScopePlugin({ editor, storage, clearSelectionOnBlur }) {
|
|
281
|
+
const scopeRefs = /* @__PURE__ */ new Set();
|
|
282
|
+
const isInsideScope = (node) => Boolean(node && [...scopeRefs].some((el) => el.contains(node)));
|
|
283
|
+
const getClosestScope = (node) => {
|
|
284
|
+
if (!node) return null;
|
|
285
|
+
let closest = null;
|
|
286
|
+
for (const scope of scopeRefs) {
|
|
287
|
+
if (!scope.contains(node)) continue;
|
|
288
|
+
if (!closest || closest.contains(scope)) closest = scope;
|
|
289
|
+
}
|
|
290
|
+
return closest;
|
|
291
|
+
};
|
|
292
|
+
const handleFocusIn = (event) => {
|
|
293
|
+
const target = event.target;
|
|
294
|
+
if (!(target instanceof Node) || !editor.view.dom.contains(target)) return;
|
|
295
|
+
const previous = editor.isFocused;
|
|
296
|
+
editor.isFocused = true;
|
|
297
|
+
if (previous !== editor.isFocused) {
|
|
298
|
+
const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
|
|
299
|
+
editor.view.dispatch(transaction);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const handleFocusOut = (event) => {
|
|
303
|
+
const blur = () => {
|
|
304
|
+
const previous = editor.isFocused;
|
|
305
|
+
editor.isFocused = false;
|
|
306
|
+
if (previous !== editor.isFocused) {
|
|
307
|
+
const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
|
|
308
|
+
if (clearSelectionOnBlur) transaction.setSelection(TextSelection.create(transaction.doc, 0));
|
|
309
|
+
editor.view.dispatch(transaction);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const nextFocus = event.relatedTarget;
|
|
313
|
+
if (!nextFocus) {
|
|
314
|
+
const previousFocus = event.target;
|
|
315
|
+
const fallbackScope = getClosestScope(previousFocus);
|
|
316
|
+
queueMicrotask(() => {
|
|
317
|
+
if (isInsideScope(event.view?.document.activeElement ?? null)) return;
|
|
318
|
+
if (!previousFocus?.isConnected && fallbackScope?.isConnected) {
|
|
319
|
+
fallbackScope.focus({ preventScroll: true });
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
blur();
|
|
323
|
+
});
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (isInsideScope(nextFocus)) return;
|
|
327
|
+
blur();
|
|
328
|
+
};
|
|
329
|
+
const registerScope = (el) => {
|
|
330
|
+
if (!el || scopeRefs.has(el)) return;
|
|
331
|
+
scopeRefs.add(el);
|
|
332
|
+
el.addEventListener("focusin", handleFocusIn);
|
|
333
|
+
el.addEventListener("focusout", handleFocusOut);
|
|
334
|
+
};
|
|
335
|
+
const unregisterScope = (el) => {
|
|
336
|
+
if (!el || !scopeRefs.has(el)) return;
|
|
337
|
+
scopeRefs.delete(el);
|
|
338
|
+
el.removeEventListener("focusin", handleFocusIn);
|
|
339
|
+
el.removeEventListener("focusout", handleFocusOut);
|
|
340
|
+
};
|
|
341
|
+
storage.registerScope = registerScope;
|
|
342
|
+
storage.unregisterScope = unregisterScope;
|
|
343
|
+
return new Plugin({
|
|
344
|
+
key: focusScopePluginKey,
|
|
345
|
+
view(view) {
|
|
346
|
+
storage.registerScope = registerScope;
|
|
347
|
+
storage.unregisterScope = unregisterScope;
|
|
348
|
+
registerScope(view.dom);
|
|
349
|
+
return { destroy() {
|
|
350
|
+
for (const scope of [...scopeRefs]) unregisterScope(scope);
|
|
351
|
+
storage.registerScope = noop;
|
|
352
|
+
storage.unregisterScope = noop;
|
|
353
|
+
} };
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
const FocusScopes = Extension.create({
|
|
358
|
+
name: "focusScope",
|
|
359
|
+
addOptions() {
|
|
360
|
+
return { clearSelectionOnBlur: true };
|
|
361
|
+
},
|
|
362
|
+
addStorage() {
|
|
363
|
+
return createFocusScopesStorage();
|
|
364
|
+
},
|
|
365
|
+
onCreate() {
|
|
366
|
+
this.editor.unregisterPlugin(extensions.focusEventsPluginKey);
|
|
367
|
+
},
|
|
368
|
+
addProseMirrorPlugins() {
|
|
369
|
+
return [createFocusScopePlugin({
|
|
370
|
+
editor: this.editor,
|
|
371
|
+
storage: this.storage,
|
|
372
|
+
clearSelectionOnBlur: this.options.clearSelectionOnBlur
|
|
373
|
+
})];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
//#endregion
|
|
377
|
+
export { TABLE_ATTRIBUTES as _, COLUMN_PARENT_TYPES as a, createStandardAttributes as b, MAX_COLUMNS_DEPTH as c, getColumnsDepth as d, hasPrismThemeLoaded as f, LAYOUT_ATTRIBUTES as g, COMMON_HTML_ATTRIBUTES as h, focusScopePluginKey as i, ThreeColumns as l, removePrismTheme as m, createFocusScopePlugin as n, ColumnsColumn as o, loadPrismTheme as p, createFocusScopesStorage as r, FourColumns as s, FocusScopes as t, TwoColumns as u, TABLE_CELL_ATTRIBUTES as v, TABLE_HEADER_ATTRIBUTES as y };
|
|
272
378
|
|
|
273
|
-
//# sourceMappingURL=
|
|
379
|
+
//# sourceMappingURL=focus-scopes-8q9tO1ue.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-scopes-8q9tO1ue.mjs","names":["nativeTiptapExtensions"],"sources":["../src/utils/attribute-helpers.ts","../src/utils/prism-utils.ts","../src/extensions/columns.tsx","../src/extensions/focus-scopes.ts"],"sourcesContent":["/**\n * Creates TipTap attribute definitions for a list of HTML attributes.\n * Each attribute will have the same pattern:\n * - default: null\n * - parseHTML: extracts the attribute from the element\n * - renderHTML: conditionally renders the attribute if it has a value\n *\n * @param attributeNames - Array of HTML attribute names to create definitions for\n * @returns Object with TipTap attribute definitions\n *\n * @example\n * const attrs = createStandardAttributes(['class', 'id', 'title']);\n * // Returns:\n * // {\n * // class: {\n * // default: null,\n * // parseHTML: (element) => element.getAttribute('class'),\n * // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}\n * // },\n * // ...\n * // }\n */\nexport function createStandardAttributes(attributeNames: readonly string[]) {\n return Object.fromEntries(\n attributeNames.map((attr) => [\n attr,\n {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute(attr),\n renderHTML: (attributes: Record<string, unknown>) => {\n if (!attributes[attr]) {\n return {};\n }\n\n return {\n [attr]: attributes[attr],\n };\n },\n },\n ]),\n );\n}\n\n/**\n * Common HTML attributes used across multiple extensions.\n * These preserve attributes during HTML import and editing for better\n * fidelity when importing existing email templates.\n */\nexport const COMMON_HTML_ATTRIBUTES = [\n 'id',\n 'class',\n 'title',\n 'lang',\n 'dir',\n 'data-id',\n] as const;\n\n/**\n * Layout-specific HTML attributes used for positioning and sizing.\n */\nexport const LAYOUT_ATTRIBUTES = ['align', 'width', 'height'] as const;\n\n/**\n * Table-specific HTML attributes used for table layout and styling.\n */\nexport const TABLE_ATTRIBUTES = [\n 'border',\n 'cellpadding',\n 'cellspacing',\n] as const;\n\n/**\n * Table cell-specific HTML attributes.\n */\nexport const TABLE_CELL_ATTRIBUTES = [\n 'valign',\n 'bgcolor',\n 'colspan',\n 'rowspan',\n] as const;\n\n/**\n * Table header cell-specific HTML attributes.\n * These are additional attributes that only apply to <th> elements.\n */\nexport const TABLE_HEADER_ATTRIBUTES = [\n ...TABLE_CELL_ATTRIBUTES,\n 'scope',\n] as const;\n","const publicURL = '/styles/prism';\n\nexport function loadPrismTheme(theme: string) {\n // Create new link element for the new theme\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = `${publicURL}/prism-${theme}.css`;\n link.setAttribute('data-prism-theme', ''); // Mark this link as the Prism theme\n\n // Append the new link element to the head\n document.head.appendChild(link);\n}\n\nexport function removePrismTheme() {\n const existingTheme = document.querySelectorAll(\n 'link[rel=\"stylesheet\"][data-prism-theme]',\n );\n if (existingTheme.length > 0) {\n existingTheme.forEach((cssLinkTag) => {\n cssLinkTag.remove();\n });\n }\n}\n\nexport function hasPrismThemeLoaded(theme: string) {\n const existingTheme = document.querySelector(\n `link[rel=\"stylesheet\"][data-prism-theme][href=\"${publicURL}/prism-${theme}.css\"]`,\n );\n return !!existingTheme;\n}\n","import { type CommandProps, mergeAttributes } from '@tiptap/core';\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model';\nimport { TextSelection } from '@tiptap/pm/state';\nimport { Column, Row } from 'react-email';\nimport { EmailNode } from '../core/serializer/email-node';\nimport {\n COMMON_HTML_ATTRIBUTES,\n createStandardAttributes,\n LAYOUT_ATTRIBUTES,\n} from '../utils/attribute-helpers';\nimport { inlineCssToJs } from '../utils/styles';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n columns: {\n insertColumns: (count: 2 | 3 | 4) => ReturnType;\n };\n }\n}\n\nexport const COLUMN_PARENT_TYPES = [\n 'twoColumns',\n 'threeColumns',\n 'fourColumns',\n] as const;\n\nconst COLUMN_PARENT_SET = new Set<string>(COLUMN_PARENT_TYPES);\n\nexport const MAX_COLUMNS_DEPTH = 3;\n\nexport function getColumnsDepth(doc: ProseMirrorNode, from: number): number {\n const $from = doc.resolve(from);\n let depth = 0;\n for (let d = $from.depth; d > 0; d--) {\n if (COLUMN_PARENT_SET.has($from.node(d).type.name)) {\n depth++;\n }\n }\n return depth;\n}\n\ninterface ColumnsVariantConfig {\n name: (typeof COLUMN_PARENT_TYPES)[number];\n columnCount: number;\n content: string;\n dataType: string;\n}\n\nconst VARIANTS: ColumnsVariantConfig[] = [\n {\n name: 'twoColumns',\n columnCount: 2,\n content: 'columnsColumn columnsColumn',\n dataType: 'two-columns',\n },\n {\n name: 'threeColumns',\n columnCount: 3,\n content: 'columnsColumn columnsColumn columnsColumn',\n dataType: 'three-columns',\n },\n {\n name: 'fourColumns',\n columnCount: 4,\n content: 'columnsColumn{4}',\n dataType: 'four-columns',\n },\n];\n\nconst NODE_TYPE_MAP: Record<number, (typeof COLUMN_PARENT_TYPES)[number]> = {\n 2: 'twoColumns',\n 3: 'threeColumns',\n 4: 'fourColumns',\n};\n\nfunction createColumnsNode(\n config: ColumnsVariantConfig,\n includeCommands: boolean,\n) {\n return EmailNode.create({\n name: config.name,\n group: 'block',\n content: config.content,\n isolating: true,\n defining: true,\n\n addAttributes() {\n return createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]);\n },\n\n parseHTML() {\n return [{ tag: `div[data-type=\"${config.dataType}\"]` }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': config.dataType, class: 'node-columns' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n ...(includeCommands && {\n addCommands() {\n return {\n insertColumns:\n (count: 2 | 3 | 4) =>\n ({\n commands,\n state,\n }: CommandProps & {\n state: { doc: ProseMirrorNode; selection: { from: number } };\n }) => {\n if (\n getColumnsDepth(state.doc, state.selection.from) >=\n MAX_COLUMNS_DEPTH\n ) {\n return false;\n }\n const nodeType = NODE_TYPE_MAP[count];\n const children = Array.from({ length: count }, () => ({\n type: 'columnsColumn',\n content: [{ type: 'paragraph', content: [] }],\n }));\n return commands.insertContent({\n type: nodeType,\n content: children,\n });\n },\n };\n },\n }),\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n return (\n <Row\n className={node.attrs?.class || undefined}\n style={{ ...style, ...inlineStyles }}\n >\n {children}\n </Row>\n );\n },\n });\n}\n\nexport const TwoColumns = createColumnsNode(VARIANTS[0], true);\nexport const ThreeColumns = createColumnsNode(VARIANTS[1], false);\nexport const FourColumns = createColumnsNode(VARIANTS[2], false);\n\nexport const ColumnsColumn = EmailNode.create({\n name: 'columnsColumn',\n group: 'columnsColumn',\n content: 'block+',\n isolating: true,\n\n addAttributes() {\n return {\n ...createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]),\n };\n },\n\n parseHTML() {\n return [{ tag: 'div[data-type=\"column\"]' }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': 'column', class: 'node-column' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: ({ editor }) => {\n const { state } = editor;\n const { selection } = state;\n const { empty, $from } = selection;\n\n if (!empty) return false;\n\n for (let depth = $from.depth; depth >= 1; depth--) {\n if ($from.pos !== $from.start(depth)) break;\n\n const indexInParent = $from.index(depth - 1);\n\n if (indexInParent === 0) continue;\n\n const parent = $from.node(depth - 1);\n const prevNode = parent.child(indexInParent - 1);\n\n if (COLUMN_PARENT_SET.has(prevNode.type.name)) {\n const deleteFrom = $from.before(depth) - prevNode.nodeSize;\n const deleteTo = $from.before(depth);\n editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));\n return true;\n }\n\n break;\n }\n\n return false;\n },\n 'Mod-a': ({ editor }) => {\n const { state } = editor;\n const { $from } = state.selection;\n\n for (let d = $from.depth; d > 0; d--) {\n if ($from.node(d).type.name !== 'columnsColumn') {\n continue;\n }\n\n const columnStart = $from.start(d);\n const columnEnd = $from.end(d);\n const { from, to } = state.selection;\n\n if (from === columnStart && to === columnEnd) {\n return false;\n }\n\n editor.view.dispatch(\n state.tr.setSelection(\n TextSelection.create(state.doc, columnStart, columnEnd),\n ),\n );\n return true;\n }\n\n return false;\n },\n };\n },\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n const width = node.attrs?.width;\n return (\n <Column\n className={node.attrs?.class || undefined}\n style={{\n ...style,\n ...inlineStyles,\n ...(width ? { width } : {}),\n }}\n >\n {children}\n </Column>\n );\n },\n});\n","import {\n type Editor,\n Extension,\n extensions as nativeTiptapExtensions,\n} from '@tiptap/core';\nimport { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state';\n\nexport interface FocusScopesOptions {\n clearSelectionOnBlur: boolean;\n}\n\nexport interface FocusScopesStorage {\n registerScope: (el: HTMLElement | null) => void;\n unregisterScope: (el: HTMLElement | null) => void;\n}\n\ndeclare module '@tiptap/core' {\n interface Storage {\n focusScope: FocusScopesStorage;\n }\n}\n\nexport const focusScopePluginKey = new PluginKey('reactEmailFocusScopes');\n\nconst noop = () => {};\n\nexport function createFocusScopesStorage(): FocusScopesStorage {\n return {\n registerScope: noop,\n unregisterScope: noop,\n };\n}\n\nexport function createFocusScopePlugin({\n editor,\n storage,\n clearSelectionOnBlur,\n}: {\n editor: Editor;\n storage: FocusScopesStorage;\n clearSelectionOnBlur: boolean;\n}) {\n const scopeRefs = new Set<HTMLElement>();\n\n const isInsideScope = (node: Node | null) =>\n Boolean(node && [...scopeRefs].some((el) => el.contains(node)));\n\n const getClosestScope = (node: Node | null) => {\n if (!node) return null;\n\n let closest: HTMLElement | null = null;\n for (const scope of scopeRefs) {\n if (!scope.contains(node)) continue;\n if (!closest || closest.contains(scope)) {\n closest = scope;\n }\n }\n return closest;\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const target = event.target;\n if (!(target instanceof Node) || !editor.view.dom.contains(target)) {\n return;\n }\n\n const previous = editor.isFocused;\n editor.isFocused = true;\n\n if (previous !== editor.isFocused) {\n const transaction = editor.state.tr\n .setMeta('focus', { event })\n .setMeta('addToHistory', false);\n\n editor.view.dispatch(transaction);\n }\n };\n\n const handleFocusOut = (event: FocusEvent) => {\n const blur = () => {\n const previous = editor.isFocused;\n editor.isFocused = false;\n\n if (previous !== editor.isFocused) {\n const transaction = editor.state.tr\n .setMeta('blur', { event })\n .setMeta('addToHistory', false);\n\n if (clearSelectionOnBlur) {\n transaction.setSelection(TextSelection.create(transaction.doc, 0));\n }\n\n editor.view.dispatch(transaction);\n }\n };\n\n const nextFocus = event.relatedTarget as Node | null;\n if (!nextFocus) {\n const previousFocus = event.target as Node | null;\n const fallbackScope = getClosestScope(previousFocus);\n\n // queueMicrotask is needed so that we can determine reliably\n // whether or not previousFocus is inside of the DOM\n queueMicrotask(() => {\n if (isInsideScope(event.view?.document.activeElement ?? null)) {\n return;\n }\n\n if (!previousFocus?.isConnected && fallbackScope?.isConnected) {\n fallbackScope.focus({ preventScroll: true });\n return;\n }\n\n blur();\n });\n return;\n }\n\n if (isInsideScope(nextFocus)) {\n return;\n }\n\n blur();\n };\n\n const registerScope = (el: HTMLElement | null) => {\n if (!el || scopeRefs.has(el)) return;\n\n scopeRefs.add(el);\n el.addEventListener('focusin', handleFocusIn);\n el.addEventListener('focusout', handleFocusOut);\n };\n\n const unregisterScope = (el: HTMLElement | null) => {\n if (!el || !scopeRefs.has(el)) return;\n\n scopeRefs.delete(el);\n el.removeEventListener('focusin', handleFocusIn);\n el.removeEventListener('focusout', handleFocusOut);\n };\n\n storage.registerScope = registerScope;\n storage.unregisterScope = unregisterScope;\n\n return new Plugin({\n key: focusScopePluginKey,\n view(view) {\n storage.registerScope = registerScope;\n storage.unregisterScope = unregisterScope;\n registerScope(view.dom);\n\n return {\n destroy() {\n for (const scope of [...scopeRefs]) {\n unregisterScope(scope);\n }\n storage.registerScope = noop;\n storage.unregisterScope = noop;\n },\n };\n },\n });\n}\n\nexport const FocusScopes = Extension.create<\n FocusScopesOptions,\n FocusScopesStorage\n>({\n name: 'focusScope',\n\n addOptions() {\n return {\n clearSelectionOnBlur: true,\n };\n },\n\n addStorage() {\n return createFocusScopesStorage();\n },\n\n onCreate() {\n this.editor.unregisterPlugin(nativeTiptapExtensions.focusEventsPluginKey);\n },\n\n addProseMirrorPlugins() {\n return [\n createFocusScopePlugin({\n editor: this.editor,\n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G,iBAAiB,YAAY,eAAe;;CAGjD,MAAM,mBAAmB,OAA2B;AAClD,MAAI,CAAC,MAAM,CAAC,UAAU,IAAI,GAAG,CAAE;AAE/B,YAAU,OAAO,GAAG;AACpB,KAAG,oBAAoB,WAAW,cAAc;AAChD,KAAG,oBAAoB,YAAY,eAAe;;AAGpD,SAAQ,gBAAgB;AACxB,SAAQ,kBAAkB;AAE1B,QAAO,IAAI,OAAO;EAChB,KAAK;EACL,KAAK,MAAM;AACT,WAAQ,gBAAgB;AACxB,WAAQ,kBAAkB;AAC1B,iBAAc,KAAK,IAAI;AAEvB,UAAO,EACL,UAAU;AACR,SAAK,MAAM,SAAS,CAAC,GAAG,UAAU,CAChC,iBAAgB,MAAM;AAExB,YAAQ,gBAAgB;AACxB,YAAQ,kBAAkB;MAE7B;;EAEJ,CAAC;;AAGJ,MAAa,cAAc,UAAU,OAGnC;CACA,MAAM;CAEN,aAAa;AACX,SAAO,EACL,sBAAsB,MACvB;;CAGH,aAAa;AACX,SAAO,0BAA0B;;CAGnC,WAAW;AACT,OAAK,OAAO,iBAAiBA,WAAuB,qBAAqB;;CAG3E,wBAAwB;AACtB,SAAO,CACL,uBAAuB;GACrB,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,sBAAsB,KAAK,QAAQ;GACpC,CAAC,CACH;;CAEJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor, Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
|
|
4
|
+
//#region src/extensions/focus-scopes.d.ts
|
|
5
|
+
interface FocusScopesOptions {
|
|
6
|
+
clearSelectionOnBlur: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface FocusScopesStorage {
|
|
9
|
+
registerScope: (el: HTMLElement | null) => void;
|
|
10
|
+
unregisterScope: (el: HTMLElement | null) => void;
|
|
11
|
+
}
|
|
12
|
+
declare module '@tiptap/core' {
|
|
13
|
+
interface Storage {
|
|
14
|
+
focusScope: FocusScopesStorage;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare const focusScopePluginKey: PluginKey<any>;
|
|
18
|
+
declare function createFocusScopesStorage(): FocusScopesStorage;
|
|
19
|
+
declare function createFocusScopePlugin({
|
|
20
|
+
editor,
|
|
21
|
+
storage,
|
|
22
|
+
clearSelectionOnBlur
|
|
23
|
+
}: {
|
|
24
|
+
editor: Editor;
|
|
25
|
+
storage: FocusScopesStorage;
|
|
26
|
+
clearSelectionOnBlur: boolean;
|
|
27
|
+
}): Plugin<any>;
|
|
28
|
+
declare const FocusScopes: Extension<FocusScopesOptions, FocusScopesStorage>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createFocusScopesStorage as a, createFocusScopePlugin as i, FocusScopesOptions as n, focusScopePluginKey as o, FocusScopesStorage as r, FocusScopes as t };
|
|
31
|
+
//# sourceMappingURL=focus-scopes-BLTX2pJU.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-scopes-BLTX2pJU.d.cts","names":[],"sources":["../src/extensions/focus-scopes.ts"],"mappings":";;;;UAOiB,kBAAA;EACf,oBAAA;AAAA;AAAA,UAGe,kBAAA;EACf,aAAA,GAAgB,EAAA,EAAI,WAAA;EACpB,eAAA,GAAkB,EAAA,EAAI,WAAA;AAAA;AAAA;EAAA,UAIZ,OAAA;IACR,UAAA,EAAY,kBAAA;EAAA;AAAA;AAAA,cAIH,mBAAA,EAAmB,SAAA;AAAA,iBAIhB,wBAAA,CAAA,GAA4B,kBAAA;AAAA,iBAO5B,sBAAA,CAAA;EACd,MAAA;EACA,OAAA;EACA;AAAA;EAEA,MAAA,EAAQ,MAAA;EACR,OAAA,EAAS,kBAAA;EACT,oBAAA;AAAA,IACD,MAAA;AAAA,cA2HY,WAAA,EAAW,SAAA,CAAA,kBAAA,EAAA,kBAAA"}
|
|
@@ -20,7 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
//#endregion
|
|
23
|
-
const require_email_node = require("./email-node-
|
|
23
|
+
const require_email_node = require("./email-node-BFhsqjxz.cjs");
|
|
24
24
|
let react_email = require("react-email");
|
|
25
25
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
26
26
|
let _tiptap_core = require("@tiptap/core");
|
|
@@ -290,6 +290,112 @@ const ColumnsColumn = require_email_node.EmailNode.create({
|
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
//#endregion
|
|
293
|
+
//#region src/extensions/focus-scopes.ts
|
|
294
|
+
const focusScopePluginKey = new _tiptap_pm_state.PluginKey("reactEmailFocusScopes");
|
|
295
|
+
const noop = () => {};
|
|
296
|
+
function createFocusScopesStorage() {
|
|
297
|
+
return {
|
|
298
|
+
registerScope: noop,
|
|
299
|
+
unregisterScope: noop
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function createFocusScopePlugin({ editor, storage, clearSelectionOnBlur }) {
|
|
303
|
+
const scopeRefs = /* @__PURE__ */ new Set();
|
|
304
|
+
const isInsideScope = (node) => Boolean(node && [...scopeRefs].some((el) => el.contains(node)));
|
|
305
|
+
const getClosestScope = (node) => {
|
|
306
|
+
if (!node) return null;
|
|
307
|
+
let closest = null;
|
|
308
|
+
for (const scope of scopeRefs) {
|
|
309
|
+
if (!scope.contains(node)) continue;
|
|
310
|
+
if (!closest || closest.contains(scope)) closest = scope;
|
|
311
|
+
}
|
|
312
|
+
return closest;
|
|
313
|
+
};
|
|
314
|
+
const handleFocusIn = (event) => {
|
|
315
|
+
const target = event.target;
|
|
316
|
+
if (!(target instanceof Node) || !editor.view.dom.contains(target)) return;
|
|
317
|
+
const previous = editor.isFocused;
|
|
318
|
+
editor.isFocused = true;
|
|
319
|
+
if (previous !== editor.isFocused) {
|
|
320
|
+
const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
|
|
321
|
+
editor.view.dispatch(transaction);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
const handleFocusOut = (event) => {
|
|
325
|
+
const blur = () => {
|
|
326
|
+
const previous = editor.isFocused;
|
|
327
|
+
editor.isFocused = false;
|
|
328
|
+
if (previous !== editor.isFocused) {
|
|
329
|
+
const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
|
|
330
|
+
if (clearSelectionOnBlur) transaction.setSelection(_tiptap_pm_state.TextSelection.create(transaction.doc, 0));
|
|
331
|
+
editor.view.dispatch(transaction);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const nextFocus = event.relatedTarget;
|
|
335
|
+
if (!nextFocus) {
|
|
336
|
+
const previousFocus = event.target;
|
|
337
|
+
const fallbackScope = getClosestScope(previousFocus);
|
|
338
|
+
queueMicrotask(() => {
|
|
339
|
+
if (isInsideScope(event.view?.document.activeElement ?? null)) return;
|
|
340
|
+
if (!previousFocus?.isConnected && fallbackScope?.isConnected) {
|
|
341
|
+
fallbackScope.focus({ preventScroll: true });
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
blur();
|
|
345
|
+
});
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (isInsideScope(nextFocus)) return;
|
|
349
|
+
blur();
|
|
350
|
+
};
|
|
351
|
+
const registerScope = (el) => {
|
|
352
|
+
if (!el || scopeRefs.has(el)) return;
|
|
353
|
+
scopeRefs.add(el);
|
|
354
|
+
el.addEventListener("focusin", handleFocusIn);
|
|
355
|
+
el.addEventListener("focusout", handleFocusOut);
|
|
356
|
+
};
|
|
357
|
+
const unregisterScope = (el) => {
|
|
358
|
+
if (!el || !scopeRefs.has(el)) return;
|
|
359
|
+
scopeRefs.delete(el);
|
|
360
|
+
el.removeEventListener("focusin", handleFocusIn);
|
|
361
|
+
el.removeEventListener("focusout", handleFocusOut);
|
|
362
|
+
};
|
|
363
|
+
storage.registerScope = registerScope;
|
|
364
|
+
storage.unregisterScope = unregisterScope;
|
|
365
|
+
return new _tiptap_pm_state.Plugin({
|
|
366
|
+
key: focusScopePluginKey,
|
|
367
|
+
view(view) {
|
|
368
|
+
storage.registerScope = registerScope;
|
|
369
|
+
storage.unregisterScope = unregisterScope;
|
|
370
|
+
registerScope(view.dom);
|
|
371
|
+
return { destroy() {
|
|
372
|
+
for (const scope of [...scopeRefs]) unregisterScope(scope);
|
|
373
|
+
storage.registerScope = noop;
|
|
374
|
+
storage.unregisterScope = noop;
|
|
375
|
+
} };
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
const FocusScopes = _tiptap_core.Extension.create({
|
|
380
|
+
name: "focusScope",
|
|
381
|
+
addOptions() {
|
|
382
|
+
return { clearSelectionOnBlur: true };
|
|
383
|
+
},
|
|
384
|
+
addStorage() {
|
|
385
|
+
return createFocusScopesStorage();
|
|
386
|
+
},
|
|
387
|
+
onCreate() {
|
|
388
|
+
this.editor.unregisterPlugin(_tiptap_core.extensions.focusEventsPluginKey);
|
|
389
|
+
},
|
|
390
|
+
addProseMirrorPlugins() {
|
|
391
|
+
return [createFocusScopePlugin({
|
|
392
|
+
editor: this.editor,
|
|
393
|
+
storage: this.storage,
|
|
394
|
+
clearSelectionOnBlur: this.options.clearSelectionOnBlur
|
|
395
|
+
})];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
//#endregion
|
|
293
399
|
Object.defineProperty(exports, "COLUMN_PARENT_TYPES", {
|
|
294
400
|
enumerable: true,
|
|
295
401
|
get: function() {
|
|
@@ -308,6 +414,12 @@ Object.defineProperty(exports, "ColumnsColumn", {
|
|
|
308
414
|
return ColumnsColumn;
|
|
309
415
|
}
|
|
310
416
|
});
|
|
417
|
+
Object.defineProperty(exports, "FocusScopes", {
|
|
418
|
+
enumerable: true,
|
|
419
|
+
get: function() {
|
|
420
|
+
return FocusScopes;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
311
423
|
Object.defineProperty(exports, "FourColumns", {
|
|
312
424
|
enumerable: true,
|
|
313
425
|
get: function() {
|
|
@@ -362,12 +474,30 @@ Object.defineProperty(exports, "__toESM", {
|
|
|
362
474
|
return __toESM;
|
|
363
475
|
}
|
|
364
476
|
});
|
|
477
|
+
Object.defineProperty(exports, "createFocusScopePlugin", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
get: function() {
|
|
480
|
+
return createFocusScopePlugin;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
Object.defineProperty(exports, "createFocusScopesStorage", {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
get: function() {
|
|
486
|
+
return createFocusScopesStorage;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
365
489
|
Object.defineProperty(exports, "createStandardAttributes", {
|
|
366
490
|
enumerable: true,
|
|
367
491
|
get: function() {
|
|
368
492
|
return createStandardAttributes;
|
|
369
493
|
}
|
|
370
494
|
});
|
|
495
|
+
Object.defineProperty(exports, "focusScopePluginKey", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
get: function() {
|
|
498
|
+
return focusScopePluginKey;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
371
501
|
Object.defineProperty(exports, "getColumnsDepth", {
|
|
372
502
|
enumerable: true,
|
|
373
503
|
get: function() {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor, Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
|
|
4
|
+
//#region src/extensions/focus-scopes.d.ts
|
|
5
|
+
interface FocusScopesOptions {
|
|
6
|
+
clearSelectionOnBlur: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface FocusScopesStorage {
|
|
9
|
+
registerScope: (el: HTMLElement | null) => void;
|
|
10
|
+
unregisterScope: (el: HTMLElement | null) => void;
|
|
11
|
+
}
|
|
12
|
+
declare module '@tiptap/core' {
|
|
13
|
+
interface Storage {
|
|
14
|
+
focusScope: FocusScopesStorage;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare const focusScopePluginKey: PluginKey<any>;
|
|
18
|
+
declare function createFocusScopesStorage(): FocusScopesStorage;
|
|
19
|
+
declare function createFocusScopePlugin({
|
|
20
|
+
editor,
|
|
21
|
+
storage,
|
|
22
|
+
clearSelectionOnBlur
|
|
23
|
+
}: {
|
|
24
|
+
editor: Editor;
|
|
25
|
+
storage: FocusScopesStorage;
|
|
26
|
+
clearSelectionOnBlur: boolean;
|
|
27
|
+
}): Plugin<any>;
|
|
28
|
+
declare const FocusScopes: Extension<FocusScopesOptions, FocusScopesStorage>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createFocusScopesStorage as a, createFocusScopePlugin as i, FocusScopesOptions as n, focusScopePluginKey as o, FocusScopesStorage as r, FocusScopes as t };
|
|
31
|
+
//# sourceMappingURL=focus-scopes-CKTuaMk3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-scopes-CKTuaMk3.d.mts","names":[],"sources":["../src/extensions/focus-scopes.ts"],"mappings":";;;;UAOiB,kBAAA;EACf,oBAAA;AAAA;AAAA,UAGe,kBAAA;EACf,aAAA,GAAgB,EAAA,EAAI,WAAA;EACpB,eAAA,GAAkB,EAAA,EAAI,WAAA;AAAA;AAAA;EAAA,UAIZ,OAAA;IACR,UAAA,EAAY,kBAAA;EAAA;AAAA;AAAA,cAIH,mBAAA,EAAmB,SAAA;AAAA,iBAIhB,wBAAA,CAAA,GAA4B,kBAAA;AAAA,iBAO5B,sBAAA,CAAA;EACd,MAAA;EACA,OAAA;EACA;AAAA;EAEA,MAAA,EAAQ,MAAA;EACR,OAAA,EAAS,kBAAA;EACT,oBAAA;AAAA,IACD,MAAA;AAAA,cA2HY,WAAA,EAAW,SAAA,CAAA,kBAAA,EAAA,kBAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./
|
|
3
|
-
const require_core = require("./core-
|
|
4
|
-
const require_extensions = require("./extensions-
|
|
5
|
-
const require_extension = require("./extension-
|
|
6
|
-
const require_extension$1 = require("./extension-
|
|
7
|
-
const require_root = require("./root
|
|
2
|
+
require("./focus-scopes-CGUz8PLF.cjs");
|
|
3
|
+
const require_core = require("./core-x9hglA_7.cjs");
|
|
4
|
+
const require_extensions = require("./extensions-OWBg5IcG.cjs");
|
|
5
|
+
const require_extension = require("./extension-KPXoxV9s.cjs");
|
|
6
|
+
const require_extension$1 = require("./extension-DadHTZr7.cjs");
|
|
7
|
+
const require_root = require("./root--eD8m9YM.cjs");
|
|
8
8
|
let _tiptap_react = require("@tiptap/react");
|
|
9
9
|
let react = require("react");
|
|
10
10
|
let _tiptap_html = require("@tiptap/html");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as EditorThemeInput } from "./types-
|
|
1
|
+
import { r as EditorThemeInput } from "./types-B2yr4rz3.cjs";
|
|
2
2
|
import { Content, Editor, Extensions, JSONContent } from "@tiptap/core";
|
|
3
3
|
import * as _$react from "react";
|
|
4
4
|
import { ReactNode } from "react";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as EditorThemeInput } from "./types-
|
|
1
|
+
import { r as EditorThemeInput } from "./types-DzqGGKXD.mjs";
|
|
2
2
|
import * as _$react from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { Content, Editor, Extensions, JSONContent } from "@tiptap/core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as composeReactEmail } from "./core-CbSTyrV4.mjs";
|
|
2
|
-
import { t as StarterKit } from "./extensions-
|
|
2
|
+
import { t as StarterKit } from "./extensions-embyYB59.mjs";
|
|
3
3
|
import { t as EmailTheming } from "./extension-Bkm4l7_t.mjs";
|
|
4
4
|
import { t as createImageExtension } from "./extension-CDrL5i44.mjs";
|
|
5
|
-
import { t as SlashCommandRoot, x as BubbleMenu } from "./root-
|
|
5
|
+
import { t as SlashCommandRoot, x as BubbleMenu } from "./root-BPWrOnKS.mjs";
|
|
6
6
|
import { EditorProvider, useCurrentEditor } from "@tiptap/react";
|
|
7
7
|
import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { generateJSON } from "@tiptap/html";
|
package/dist/plugins/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../
|
|
3
|
-
const require_extension = require("../extension-
|
|
4
|
-
const require_extension$1 = require("../extension-
|
|
5
|
-
const require_image = require("../image-
|
|
2
|
+
require("../focus-scopes-CGUz8PLF.cjs");
|
|
3
|
+
const require_extension = require("../extension-KPXoxV9s.cjs");
|
|
4
|
+
const require_extension$1 = require("../extension-DadHTZr7.cjs");
|
|
5
|
+
const require_image = require("../image-Td_Smj-b.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
//#region src/plugins/image/slash-command.tsx
|
|
8
8
|
const imageSlashCommand = {
|
package/dist/plugins/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as EmailNode } from "../index-CHAPu71g.cjs";
|
|
2
|
-
import { a as KnownThemeComponents, c as PanelSectionId, d as ThemeComponentStyles, f as ThemeConfig, i as KnownCssProperties, l as ResetTheme, n as EditorTheme, o as PanelGroup, p as ThemeableComponent, r as EditorThemeInput, s as PanelInputProperty, t as CssJs, u as SupportedCssProperties } from "../types-
|
|
3
|
-
import { n as SlashCommandItem } from "../types-
|
|
2
|
+
import { a as KnownThemeComponents, c as PanelSectionId, d as ThemeComponentStyles, f as ThemeConfig, i as KnownCssProperties, l as ResetTheme, n as EditorTheme, o as PanelGroup, p as ThemeableComponent, r as EditorThemeInput, s as PanelInputProperty, t as CssJs, u as SupportedCssProperties } from "../types-B2yr4rz3.cjs";
|
|
3
|
+
import { n as SlashCommandItem } from "../types-ALwc36ll.cjs";
|
|
4
4
|
import { Editor, Extension, JSONContent } from "@tiptap/core";
|
|
5
5
|
import * as React$2 from "react";
|
|
6
6
|
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as EmailNode } from "../index-CacF9qQa.mjs";
|
|
2
|
-
import { a as KnownThemeComponents, c as PanelSectionId, d as ThemeComponentStyles, f as ThemeConfig, i as KnownCssProperties, l as ResetTheme, n as EditorTheme, o as PanelGroup, p as ThemeableComponent, r as EditorThemeInput, s as PanelInputProperty, t as CssJs, u as SupportedCssProperties } from "../types-
|
|
3
|
-
import { n as SlashCommandItem } from "../types-
|
|
2
|
+
import { a as KnownThemeComponents, c as PanelSectionId, d as ThemeComponentStyles, f as ThemeConfig, i as KnownCssProperties, l as ResetTheme, n as EditorTheme, o as PanelGroup, p as ThemeableComponent, r as EditorThemeInput, s as PanelInputProperty, t as CssJs, u as SupportedCssProperties } from "../types-DzqGGKXD.mjs";
|
|
3
|
+
import { n as SlashCommandItem } from "../types-BG5XsXt9.mjs";
|
|
4
4
|
import * as React$2 from "react";
|
|
5
5
|
import { Editor, Extension, JSONContent } from "@tiptap/core";
|
|
6
6
|
|