@everystack/admin 0.4.4 → 0.4.5

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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to `@everystack/admin` are documented here.
4
4
 
5
5
  Format based on [Keep a Changelog](https://keepachangelog.com/).
6
6
 
7
+ ## [0.4.5] - 2026-10-15
8
+
9
+ ### Added
10
+
11
+ - the visual editor keeps data-* attributes on every node and mark
12
+
13
+ ### Documentation
14
+
15
+ - InputContext.values is required since 0.4.3
16
+
7
17
  ## [0.4.4] - 2026-10-15
8
18
 
9
19
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everystack/admin",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Declarative admin dashboard framework for PostgREST APIs",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "Scalable Technology, Inc. <licensing@scalable.technology>",
@@ -117,8 +117,8 @@
117
117
  "react-test-renderer": "19.2.0",
118
118
  "ts-jest": "29.4.9",
119
119
  "typescript": "5.9.3",
120
- "@everystack/api": "0.4.4",
121
- "@everystack/ui": "0.4.3"
120
+ "@everystack/ui": "0.4.4",
121
+ "@everystack/api": "0.4.5"
122
122
  },
123
123
  "scripts": {
124
124
  "test": "jest",
@@ -1,4 +1,4 @@
1
- import { Node, type Extensions } from '@tiptap/react';
1
+ import { Extension, Node, getSchema, mergeAttributes, type Extensions } from '@tiptap/react';
2
2
  import type { DOMOutputSpec, TagParseRule } from '@tiptap/pm/model';
3
3
  import StarterKit from '@tiptap/starter-kit';
4
4
  import { Code } from '@tiptap/extension-code';
@@ -21,8 +21,8 @@ export const Figure = Node.create({
21
21
  getAttrs: (element: HTMLElement): null | false => element.querySelector('img[src]') ? null : false,
22
22
  }];
23
23
  },
24
- renderHTML(): DOMOutputSpec {
25
- return ['figure', 0];
24
+ renderHTML({ HTMLAttributes }): DOMOutputSpec {
25
+ return ['figure', mergeAttributes(HTMLAttributes), 0];
26
26
  },
27
27
  });
28
28
 
@@ -35,13 +35,38 @@ export const Figcaption = Node.create({
35
35
  parseHTML(): TagParseRule[] {
36
36
  return [{ tag: 'figcaption', context: 'figure/' }];
37
37
  },
38
- renderHTML(): DOMOutputSpec {
39
- return ['figcaption', 0];
38
+ renderHTML({ HTMLAttributes }): DOMOutputSpec {
39
+ return ['figcaption', mergeAttributes(HTMLAttributes), 0];
40
40
  },
41
41
  });
42
42
 
43
- export function richHtmlExtensions(): Extensions {
44
- return [
43
+ export const DataAttributes = Extension.create<{ types: string[] }>({
44
+ name: 'dataAttributes',
45
+ addOptions() {
46
+ return { types: [] };
47
+ },
48
+ addGlobalAttributes() {
49
+ return [{
50
+ types: this.options.types,
51
+ attributes: {
52
+ dataAttributes: {
53
+ default: null,
54
+ keepOnSplit: false,
55
+ parseHTML: (element: HTMLElement): Record<string, string> | null => {
56
+ const entries = Array.from(element.attributes)
57
+ .filter(attribute => attribute.name.startsWith('data-'))
58
+ .map(attribute => [attribute.name, attribute.value]);
59
+ return entries.length ? Object.fromEntries(entries) : null;
60
+ },
61
+ renderHTML: (attributes): Record<string, string> => attributes.dataAttributes ?? {},
62
+ },
63
+ },
64
+ }];
65
+ },
66
+ });
67
+
68
+ export function richHtmlExtensions(options?: { dataAttributes?: boolean }): Extensions {
69
+ const base: Extensions = [
45
70
  StarterKit.configure({
46
71
  code: false,
47
72
  codeBlock: false,
@@ -60,4 +85,10 @@ export function richHtmlExtensions(): Extensions {
60
85
  Subscript,
61
86
  Superscript,
62
87
  ];
88
+ if (options?.dataAttributes === false) return base;
89
+
90
+ const schema = getSchema(base);
91
+ const types = [...Object.keys(schema.nodes), ...Object.keys(schema.marks)]
92
+ .filter(type => type !== 'doc' && type !== 'text');
93
+ return [...base, DataAttributes.configure({ types })];
63
94
  }
package/src/types.ts CHANGED
@@ -60,6 +60,8 @@ export interface InputContext {
60
60
  /**
61
61
  * The whole form's current values, keyed by field name (what Save would
62
62
  * send). Read another field here to render a block that depends on it.
63
+ * Required since 0.4.3: code that builds an InputContext by hand, such as a
64
+ * test, must pass it.
63
65
  */
64
66
  values: Record<string, unknown>;
65
67
  }