@kopexa/extension-controlref 1.0.0 → 13.0.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.
Files changed (126) hide show
  1. package/dist/chunk-4C72VBLP.mjs +52 -0
  2. package/dist/chunk-A7FWOQDN.mjs +210 -0
  3. package/dist/chunk-AQTNFDGA.mjs +57 -0
  4. package/dist/chunk-D53W4HWR.mjs +245 -0
  5. package/dist/chunk-FTEE5U3H.mjs +37 -0
  6. package/dist/chunk-GYDJVHHG.mjs +250 -0
  7. package/dist/chunk-IMHLTRZJ.mjs +29 -0
  8. package/dist/chunk-JM66CQVD.mjs +10 -0
  9. package/dist/chunk-LMKP3DDN.mjs +189 -0
  10. package/dist/chunk-RTBFRPB3.mjs +186 -0
  11. package/dist/chunk-TEDXYIGO.mjs +38 -0
  12. package/dist/chunk-WIS7ZNTO.mjs +4 -0
  13. package/dist/chunk-X46EFFCE.mjs +148 -0
  14. package/dist/chunk-XHD2KFKQ.mjs +16 -0
  15. package/dist/chunk-ZRKYAFRY.mjs +46 -0
  16. package/dist/chunk-ZUR6XKMG.mjs +21 -0
  17. package/dist/components/control-block-view.d.mts +6 -0
  18. package/dist/components/control-block-view.d.ts +6 -0
  19. package/dist/components/control-block-view.js +789 -0
  20. package/dist/components/control-block-view.mjs +11 -0
  21. package/dist/components/control-implementation-view.d.mts +6 -0
  22. package/dist/components/control-implementation-view.d.ts +6 -0
  23. package/dist/components/control-implementation-view.js +52 -0
  24. package/dist/components/control-implementation-view.mjs +7 -0
  25. package/dist/components/control-picker.d.mts +25 -0
  26. package/dist/components/control-picker.d.ts +25 -0
  27. package/dist/components/control-picker.js +522 -0
  28. package/dist/components/control-picker.mjs +10 -0
  29. package/dist/components/control-view.js +677 -122
  30. package/dist/components/control-view.mjs +5 -5
  31. package/dist/components/use-control.d.mts +20 -0
  32. package/dist/components/use-control.d.ts +20 -0
  33. package/dist/components/use-control.js +127 -0
  34. package/dist/components/use-control.mjs +9 -0
  35. package/dist/control-block.d.mts +35 -0
  36. package/dist/control-block.d.ts +35 -0
  37. package/dist/control-block.js +1012 -0
  38. package/dist/control-block.mjs +17 -0
  39. package/dist/control-implementation.d.mts +7 -0
  40. package/dist/control-implementation.d.ts +7 -0
  41. package/dist/control-implementation.js +92 -0
  42. package/dist/control-implementation.mjs +9 -0
  43. package/dist/control.d.mts +31 -1
  44. package/dist/control.d.ts +31 -1
  45. package/dist/control.js +819 -136
  46. package/dist/control.mjs +7 -6
  47. package/dist/defaults.d.mts +3 -9
  48. package/dist/defaults.d.ts +3 -9
  49. package/dist/defaults.js +3 -20
  50. package/dist/defaults.mjs +3 -6
  51. package/dist/index.d.mts +10 -10
  52. package/dist/index.d.ts +10 -10
  53. package/dist/index.js +1229 -569
  54. package/dist/index.mjs +58 -21
  55. package/dist/messages/index.d.mts +135 -0
  56. package/dist/messages/index.d.ts +135 -0
  57. package/dist/messages/index.js +137 -2
  58. package/dist/messages/index.mjs +1 -2
  59. package/dist/role.d.mts +17 -0
  60. package/dist/role.d.ts +17 -0
  61. package/dist/role.js +5 -0
  62. package/dist/role.mjs +2 -0
  63. package/dist/types.d.mts +23 -16
  64. package/dist/types.d.ts +23 -16
  65. package/dist/utils/create-control-block.d.mts +7 -0
  66. package/dist/utils/create-control-block.d.ts +7 -0
  67. package/dist/utils/create-control-block.js +85 -0
  68. package/dist/utils/create-control-block.mjs +10 -0
  69. package/dist/utils/create-control-implementation.d.mts +8 -0
  70. package/dist/utils/create-control-implementation.d.ts +8 -0
  71. package/dist/utils/create-control-implementation.js +39 -0
  72. package/dist/utils/create-control-implementation.mjs +7 -0
  73. package/dist/utils/getControlNodeTypes.d.mts +5 -0
  74. package/dist/utils/getControlNodeTypes.d.ts +5 -0
  75. package/dist/utils/getControlNodeTypes.js +44 -0
  76. package/dist/utils/getControlNodeTypes.mjs +7 -0
  77. package/dist/utils/index.d.mts +7 -2
  78. package/dist/utils/index.d.ts +7 -2
  79. package/dist/utils/index.js +35 -3
  80. package/dist/utils/index.mjs +7 -4
  81. package/dist/utils/status-indicator.d.mts +18 -0
  82. package/dist/utils/status-indicator.d.ts +18 -0
  83. package/dist/utils/status-indicator.js +80 -0
  84. package/dist/utils/status-indicator.mjs +7 -0
  85. package/package.json +11 -11
  86. package/dist/card-variant.d.mts +0 -12
  87. package/dist/card-variant.d.ts +0 -12
  88. package/dist/card-variant.js +0 -66
  89. package/dist/card-variant.mjs +0 -8
  90. package/dist/chunk-AC4KL3WX.mjs +0 -29
  91. package/dist/chunk-AZ5M5MVC.mjs +0 -36
  92. package/dist/chunk-DTFR234X.mjs +0 -244
  93. package/dist/chunk-EDD7DYLE.mjs +0 -29
  94. package/dist/chunk-GC5EBQ7G.mjs +0 -10
  95. package/dist/chunk-H2ECPGOG.mjs +0 -81
  96. package/dist/chunk-KLX7Q3HL.mjs +0 -109
  97. package/dist/chunk-LKRTUIEV.mjs +0 -46
  98. package/dist/chunk-NAJ6IC4Y.mjs +0 -43
  99. package/dist/chunk-QI3ZPZTR.mjs +0 -26
  100. package/dist/chunk-SNRVOTF5.mjs +0 -8
  101. package/dist/chunk-VP5POY44.mjs +0 -57
  102. package/dist/chunk-WIR5FCIC.mjs +0 -110
  103. package/dist/control-ref-view.d.mts +0 -6
  104. package/dist/control-ref-view.d.ts +0 -6
  105. package/dist/control-ref-view.js +0 -615
  106. package/dist/control-ref-view.mjs +0 -15
  107. package/dist/control-ref.d.mts +0 -28
  108. package/dist/control-ref.d.ts +0 -28
  109. package/dist/control-ref.js +0 -687
  110. package/dist/control-ref.mjs +0 -16
  111. package/dist/i18n.d.mts +0 -4
  112. package/dist/i18n.d.ts +0 -4
  113. package/dist/i18n.js +0 -128
  114. package/dist/i18n.mjs +0 -10
  115. package/dist/lang/de.d.mts +0 -24
  116. package/dist/lang/de.d.ts +0 -24
  117. package/dist/lang/de.js +0 -25
  118. package/dist/lang/de.mjs +0 -8
  119. package/dist/lang/en.d.mts +0 -24
  120. package/dist/lang/en.d.ts +0 -24
  121. package/dist/lang/en.js +0 -25
  122. package/dist/lang/en.mjs +0 -8
  123. package/dist/settings-dialog.d.mts +0 -19
  124. package/dist/settings-dialog.d.ts +0 -19
  125. package/dist/settings-dialog.js +0 -371
  126. package/dist/settings-dialog.mjs +0 -9
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ // src/utils/index.ts
4
+ function firstNonEmpty(...vals) {
5
+ for (const v of vals) {
6
+ if (v != null && String(v).trim() !== "") return String(v);
7
+ }
8
+ return null;
9
+ }
10
+ function readUpdatedAt(el) {
11
+ const v = firstNonEmpty(
12
+ el.getAttribute("data-updated-at"),
13
+ el.getAttribute("data-updatedat")
14
+ );
15
+ return v;
16
+ }
17
+ function safeJSONStringify(value) {
18
+ try {
19
+ if (value == null) return null;
20
+ return JSON.stringify(value);
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+ function safeJSONParse(value) {
26
+ if (!value) return null;
27
+ try {
28
+ return JSON.parse(value);
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ export {
35
+ readUpdatedAt,
36
+ safeJSONStringify,
37
+ safeJSONParse
38
+ };
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // src/role.ts
4
+ import "@tiptap/core";
@@ -0,0 +1,148 @@
1
+ "use client";
2
+ import {
3
+ readUpdatedAt,
4
+ safeJSONParse,
5
+ safeJSONStringify
6
+ } from "./chunk-TEDXYIGO.mjs";
7
+ import {
8
+ ControlView
9
+ } from "./chunk-LMKP3DDN.mjs";
10
+
11
+ // src/control.ts
12
+ import { mergeAttributes, Node } from "@tiptap/core";
13
+ import { ReactNodeViewRenderer } from "@tiptap/react";
14
+ var Control = Node.create({
15
+ name: "control",
16
+ controlRole: "control",
17
+ group: "inline",
18
+ inline: true,
19
+ draggable: true,
20
+ atom: false,
21
+ // remais regular inline so it can be styled/selected within text
22
+ addOptions() {
23
+ return {
24
+ resolver: void 0,
25
+ fallbackLabel: "Control"
26
+ };
27
+ },
28
+ addAttributes() {
29
+ return {
30
+ id: {
31
+ default: null,
32
+ parseHTML: (element) => element.getAttribute("data-id"),
33
+ renderHTML: (attrs) => attrs.id ? { "data-id": String(attrs.id) } : {}
34
+ },
35
+ title: {
36
+ default: null,
37
+ parseHTML: (element) => element.getAttribute("data-title"),
38
+ renderHTML: (attrs) => attrs.title ? { "data-title": String(attrs.title) } : {}
39
+ },
40
+ updatedAt: {
41
+ default: null,
42
+ parseHTML: (element) => readUpdatedAt(element),
43
+ renderHTML: (attrs) => attrs.updatedAt ? { "data-updated-at": String(attrs.updatedAt) } : {}
44
+ },
45
+ status: {
46
+ default: null,
47
+ parseHTML: (element) => element.getAttribute("data-status"),
48
+ renderHTML: (attrs) => attrs.status ? { "data-status": String(attrs.status) } : {}
49
+ },
50
+ options: {
51
+ default: null,
52
+ /**
53
+ * Persist options as JSON in a single attribute.
54
+ * Keeps DOM lean and avoids attribute explosion.
55
+ */
56
+ parseHTML: (element) => safeJSONParse(
57
+ element.getAttribute("data-options")
58
+ ),
59
+ renderHTML: (attrs) => {
60
+ const json = safeJSONStringify(attrs.options);
61
+ return json ? { "data-options": json } : {};
62
+ }
63
+ }
64
+ };
65
+ },
66
+ parseHTML() {
67
+ return [{ tag: "span[data-type=control]" }];
68
+ },
69
+ /**
70
+ * Node → HTML
71
+ * Always output a single <span> with stable data-* attributes.
72
+ * Inner text falls back to title, then id, then a generic label.
73
+ */
74
+ renderHTML({ node, HTMLAttributes }) {
75
+ var _a, _b, _c, _d;
76
+ const attrs = node.attrs;
77
+ const label = (_d = (_c = (_a = attrs.title) != null ? _a : attrs.id) != null ? _c : (_b = this.options) == null ? void 0 : _b.fallbackLabel) != null ? _d : "Control";
78
+ return [
79
+ "span",
80
+ mergeAttributes(HTMLAttributes, {
81
+ "data-type": "control"
82
+ // the attribute renderers above will conditionally add id/title/etc.
83
+ }),
84
+ label
85
+ ];
86
+ },
87
+ addNodeView() {
88
+ return ReactNodeViewRenderer(ControlView, { as: "span" });
89
+ },
90
+ addCommands() {
91
+ return {
92
+ /**
93
+ * Insert a control at the current position.
94
+ */
95
+ insertControl: (attrs) => ({ chain }) => {
96
+ const {
97
+ id,
98
+ title = null,
99
+ updatedAt = null,
100
+ status = null,
101
+ options = null
102
+ } = attrs;
103
+ return chain().insertContent({
104
+ type: this.name,
105
+ attrs: { id, title, updatedAt, status, options }
106
+ }).run();
107
+ },
108
+ /**
109
+ * Update attributes of the control node at selection (if any).
110
+ */
111
+ updateControl: (attrs) => ({ state, tr, dispatch }) => {
112
+ const { from, to } = state.selection;
113
+ let updated = false;
114
+ state.doc.nodesBetween(from, to, (node, pos) => {
115
+ if (node.type.name === this.name) {
116
+ tr.setNodeMarkup(pos, void 0, { ...node.attrs, ...attrs });
117
+ updated = true;
118
+ return false;
119
+ }
120
+ return void 0;
121
+ });
122
+ if (updated && dispatch) dispatch(tr);
123
+ return updated;
124
+ },
125
+ /**
126
+ * Remove a control node at selection.
127
+ */
128
+ unsetControl: () => ({ state, tr, dispatch }) => {
129
+ const { from, to } = state.selection;
130
+ let removed = false;
131
+ state.doc.nodesBetween(from, to, (node, pos) => {
132
+ if (node.type.name === this.name) {
133
+ tr.delete(pos, pos + node.nodeSize);
134
+ removed = true;
135
+ return false;
136
+ }
137
+ return void 0;
138
+ });
139
+ if (removed && dispatch) dispatch(tr);
140
+ return removed;
141
+ }
142
+ };
143
+ }
144
+ });
145
+
146
+ export {
147
+ Control
148
+ };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+
3
+ // src/utils/create-control-implementation.ts
4
+ function createControlImplementation(nodeType, impl) {
5
+ var _a, _b, _c;
6
+ return nodeType.createAndFill({
7
+ id: impl.id,
8
+ title: (_a = impl.title) != null ? _a : "",
9
+ status: (_b = impl.status) != null ? _b : null,
10
+ updatedAt: (_c = impl.updatedAt) != null ? _c : null
11
+ });
12
+ }
13
+
14
+ export {
15
+ createControlImplementation
16
+ };
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import {
3
+ ControlImplementationView
4
+ } from "./chunk-IMHLTRZJ.mjs";
5
+
6
+ // src/control-implementation.ts
7
+ import { mergeAttributes, Node } from "@tiptap/core";
8
+ import { ReactNodeViewRenderer } from "@tiptap/react";
9
+ var ControlImplementation = Node.create({
10
+ name: "controlImplementation",
11
+ controlRole: "controlImplementation",
12
+ group: "block",
13
+ content: "",
14
+ // keine Kinder, Zeile ist atomar
15
+ atom: true,
16
+ // Row als unteilbarer Block
17
+ selectable: true,
18
+ draggable: false,
19
+ addAttributes() {
20
+ return {
21
+ id: { default: null },
22
+ title: { default: "" },
23
+ status: { default: null },
24
+ updatedAt: { default: null }
25
+ };
26
+ },
27
+ parseHTML() {
28
+ return [{ tag: 'div[data-type="control-implementation"]' }];
29
+ },
30
+ renderHTML({ node, HTMLAttributes }) {
31
+ return [
32
+ "div",
33
+ mergeAttributes(HTMLAttributes, {
34
+ "data-type": "control-implementation",
35
+ "data-id": node.attrs.id
36
+ })
37
+ ];
38
+ },
39
+ addNodeView() {
40
+ return ReactNodeViewRenderer(ControlImplementationView, { as: "div" });
41
+ }
42
+ });
43
+
44
+ export {
45
+ ControlImplementation
46
+ };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+
3
+ // src/utils/getControlNodeTypes.ts
4
+ function getControlNodeTypes(schema) {
5
+ if (schema.cached.controlNodeTypes) {
6
+ return schema.cached.controlNodeTypes;
7
+ }
8
+ const roles = {};
9
+ Object.keys(schema.nodes).forEach((type) => {
10
+ const nodeType = schema.nodes[type];
11
+ if (nodeType.spec.controlRole) {
12
+ roles[nodeType.spec.controlRole] = nodeType;
13
+ }
14
+ });
15
+ schema.cached.controlNodeTypes = roles;
16
+ return roles;
17
+ }
18
+
19
+ export {
20
+ getControlNodeTypes
21
+ };
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNodeViewProps } from '@tiptap/react';
3
+
4
+ declare const ControlBlockView: (props: ReactNodeViewProps) => react_jsx_runtime.JSX.Element;
5
+
6
+ export { ControlBlockView };
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNodeViewProps } from '@tiptap/react';
3
+
4
+ declare const ControlBlockView: (props: ReactNodeViewProps) => react_jsx_runtime.JSX.Element;
5
+
6
+ export { ControlBlockView };