@placeholderco/placeholder-ui 2.3.0 → 2.4.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.
@@ -71,6 +71,6 @@ export interface FileTreeProps {
71
71
  onChange?: (nodes: FileTreeNode[]) => void;
72
72
  class?: string;
73
73
  }
74
- declare const FileTree: import("svelte").Component<FileTreeProps, {}, "selectedId" | "nodes">;
74
+ declare const FileTree: import("svelte").Component<FileTreeProps, {}, "nodes" | "selectedId">;
75
75
  type FileTree = ReturnType<typeof FileTree>;
76
76
  export default FileTree;
@@ -15,7 +15,14 @@
15
15
  import { TextStyle } from '@tiptap/extension-text-style';
16
16
  import Collaboration from '@tiptap/extension-collaboration';
17
17
  import { CollaborationCaret } from '@tiptap/extension-collaboration-caret';
18
- import { Alert, CodeBlockEditor, Div, Span, type CodeBlocksOptions } from './extensions/index.js';
18
+ import {
19
+ Alert,
20
+ ClassAttribute,
21
+ CodeBlockEditor,
22
+ Div,
23
+ Span,
24
+ type CodeBlocksOptions
25
+ } from './extensions/index.js';
19
26
  import type { CollaborationConfig } from './collaboration.js';
20
27
  import FormGroup from '../../form/FormGroup.svelte';
21
28
  import LinkActionMenu from './LinkActionMenu.svelte';
@@ -299,6 +306,8 @@
299
306
  Alert,
300
307
  TabHandler,
301
308
  TableKit.configure({ table: { resizable: true } }),
309
+ // Keep `class` on standard nodes/marks so classes in loaded HTML survive
310
+ ClassAttribute,
302
311
  ...customExtensions
303
312
  ];
304
313
 
@@ -15,7 +15,14 @@
15
15
  import { TextStyle } from '@tiptap/extension-text-style';
16
16
  import Collaboration from '@tiptap/extension-collaboration';
17
17
  import { CollaborationCaret } from '@tiptap/extension-collaboration-caret';
18
- import { Alert, CodeBlockEditor, Div, Span, type CodeBlocksOptions } from './extensions/index.js';
18
+ import {
19
+ Alert,
20
+ ClassAttribute,
21
+ CodeBlockEditor,
22
+ Div,
23
+ Span,
24
+ type CodeBlocksOptions
25
+ } from './extensions/index.js';
19
26
  import type { CollaborationConfig } from './collaboration.js';
20
27
  import FormGroup from '../../form/FormGroup.svelte';
21
28
  import LinkActionMenu from './LinkActionMenu.svelte';
@@ -263,6 +270,8 @@
263
270
  Alert,
264
271
  TabHandler,
265
272
  TableKit.configure({ table: { resizable: true } }),
273
+ // Keep `class` on standard nodes/marks so classes in loaded HTML survive
274
+ ClassAttribute,
266
275
  ...customExtensions
267
276
  ];
268
277
 
@@ -0,0 +1,16 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /**
3
+ * Node and mark types that keep their `class` attribute by default. Types that
4
+ * already manage `class` themselves (div, span, alert, link) are left alone.
5
+ */
6
+ export declare const defaultClassAttributeTypes: readonly ["paragraph", "heading", "blockquote", "bulletList", "orderedList", "listItem", "codeBlock", "horizontalRule", "image", "table", "tableRow", "tableHeader", "tableCell", "bold", "italic", "strike", "code", "underline", "subscript", "superscript", "textStyle"];
7
+ export interface ClassAttributeOptions {
8
+ /** Node and mark type names that should preserve `class` (default: all standard types) */
9
+ types: string[];
10
+ }
11
+ /**
12
+ * Preserves the `class` attribute on standard nodes and marks so classes in
13
+ * loaded or pasted HTML survive the round-trip through the editor instead of
14
+ * being stripped by the schema.
15
+ */
16
+ export declare const ClassAttribute: Extension<ClassAttributeOptions, any>;
@@ -0,0 +1,59 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /**
3
+ * Node and mark types that keep their `class` attribute by default. Types that
4
+ * already manage `class` themselves (div, span, alert, link) are left alone.
5
+ */
6
+ export const defaultClassAttributeTypes = [
7
+ 'paragraph',
8
+ 'heading',
9
+ 'blockquote',
10
+ 'bulletList',
11
+ 'orderedList',
12
+ 'listItem',
13
+ 'codeBlock',
14
+ 'horizontalRule',
15
+ 'image',
16
+ 'table',
17
+ 'tableRow',
18
+ 'tableHeader',
19
+ 'tableCell',
20
+ 'bold',
21
+ 'italic',
22
+ 'strike',
23
+ 'code',
24
+ 'underline',
25
+ 'subscript',
26
+ 'superscript',
27
+ 'textStyle'
28
+ ];
29
+ /**
30
+ * Preserves the `class` attribute on standard nodes and marks so classes in
31
+ * loaded or pasted HTML survive the round-trip through the editor instead of
32
+ * being stripped by the schema.
33
+ */
34
+ export const ClassAttribute = Extension.create({
35
+ name: 'classAttribute',
36
+ addOptions() {
37
+ return {
38
+ types: [...defaultClassAttributeTypes]
39
+ };
40
+ },
41
+ addGlobalAttributes() {
42
+ return [
43
+ {
44
+ types: this.options.types,
45
+ attributes: {
46
+ class: {
47
+ default: null,
48
+ parseHTML: (element) => element.getAttribute('class') || null,
49
+ renderHTML: (attributes) => {
50
+ if (!attributes.class)
51
+ return {};
52
+ return { class: attributes.class };
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ];
58
+ }
59
+ });
@@ -1,6 +1,8 @@
1
1
  export { Alert } from './Alert.js';
2
2
  export { Div } from './Div.js';
3
3
  export { Span } from './Span.js';
4
+ export { ClassAttribute, defaultClassAttributeTypes } from './ClassAttribute.js';
5
+ export type { ClassAttributeOptions } from './ClassAttribute.js';
4
6
  export { CodeBlockEditor } from './CodeBlockEditor.js';
5
7
  export type { CodeBlockEditorOptions, CodeBlocksOptions } from './CodeBlockEditor.js';
6
8
  export { codeBlockLanguages, resolveCodeBlockLanguage } from './codeBlockLanguages.js';
@@ -1,5 +1,6 @@
1
1
  export { Alert } from './Alert.js';
2
2
  export { Div } from './Div.js';
3
3
  export { Span } from './Span.js';
4
+ export { ClassAttribute, defaultClassAttributeTypes } from './ClassAttribute.js';
4
5
  export { CodeBlockEditor } from './CodeBlockEditor.js';
5
6
  export { codeBlockLanguages, resolveCodeBlockLanguage } from './codeBlockLanguages.js';
package/dist/index.d.ts CHANGED
@@ -114,8 +114,8 @@ export type { TipTapProps, DocumentUploadResult } from './editors/tiptap/TipTap.
114
114
  export { default as TipTapBubble } from './editors/tiptap/TipTapBubble.svelte';
115
115
  export type { TipTapBubbleProps } from './editors/tiptap/TipTapBubble.svelte';
116
116
  export type { CollaborationConfig, CollaborationUser } from './editors/tiptap/collaboration.js';
117
- export { CodeBlockEditor, codeBlockLanguages, resolveCodeBlockLanguage } from './editors/tiptap/extensions/index.js';
118
- export type { CodeBlocksOptions, CodeBlockEditorOptions, CodeBlockLanguageDef, CodeBlockLanguageId } from './editors/tiptap/extensions/index.js';
117
+ export { ClassAttribute, defaultClassAttributeTypes, CodeBlockEditor, codeBlockLanguages, resolveCodeBlockLanguage } from './editors/tiptap/extensions/index.js';
118
+ export type { ClassAttributeOptions, CodeBlocksOptions, CodeBlockEditorOptions, CodeBlockLanguageDef, CodeBlockLanguageId } from './editors/tiptap/extensions/index.js';
119
119
  export type { AnyExtension } from '@tiptap/core';
120
120
  export { editorButtonVariants, editorButtonSizes, editorButtonClass, parseEditorButtonClass } from './editors/tiptap/buttonLink.js';
121
121
  export type { EditorButtonVariant, EditorButtonSize, EditorButtonStyle } from './editors/tiptap/buttonLink.js';
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ export { default as ColorPicker } from './form/ColorPicker.svelte';
56
56
  export { parseColor, parseHex, toHex, formatColor, rgbToHsv, hsvToRgb, rgbToHsl } from './form/ColorPicker.svelte';
57
57
  export { default as TipTap } from './editors/tiptap/TipTap.svelte';
58
58
  export { default as TipTapBubble } from './editors/tiptap/TipTapBubble.svelte';
59
- export { CodeBlockEditor, codeBlockLanguages, resolveCodeBlockLanguage } from './editors/tiptap/extensions/index.js';
59
+ export { ClassAttribute, defaultClassAttributeTypes, CodeBlockEditor, codeBlockLanguages, resolveCodeBlockLanguage } from './editors/tiptap/extensions/index.js';
60
60
  export { editorButtonVariants, editorButtonSizes, editorButtonClass, parseEditorButtonClass } from './editors/tiptap/buttonLink.js';
61
61
  export { default as CodeMirror } from './editors/CodeMirror.svelte';
62
62
  export { default as GitCard } from './cards/GitCard.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@placeholderco/placeholder-ui",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "A modern, customizable Svelte 5 UI component library with comprehensive theming support. Re-brand it with a single config object.",
5
5
  "license": "MIT",
6
6
  "author": "Placeholderco",