@phuong-tran-redoc/document-engine-core 0.0.34 → 0.0.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phuong-tran-redoc/document-engine-core",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Duc Phuong (Jack) <tdp99.business@gmail.com>",
@@ -89,14 +89,33 @@ import { Node, mergeAttributes } from '@tiptap/core';
89
89
  return [
90
90
  'span',
91
91
  mergeAttributes(HTMLAttributes, {
92
- class: 'dynamic-field',
92
+ class: 'dynamic-field red-dynamic-field',
93
93
  'data-field-id': fieldId,
94
94
  'data-label': label
95
95
  }),
96
- label || ''
96
+ // label || '',
97
+ fieldId ? `{{${fieldId}}}` : ''
97
98
  ];
98
99
  },
99
100
  /**
101
+ * NODE VIEW: Đây là phần giúp hiển thị giao diện giống CKEditor Widget
102
+ * Thay vì render ra text thuần, ta render ra một DOM element được style sẵn
103
+ */ addNodeView () {
104
+ return ({ node })=>{
105
+ // 1. Tạo thẻ bao bọc (Wrapper)
106
+ const dom = document.createElement('span');
107
+ // 2. Thêm class để style (Dùng Tailwind như techstack của bạn )
108
+ // Bạn có thể thêm class 'ck-widget' nếu muốn dùng lại CSS cũ
109
+ dom.classList.add('dynamic-field', 'red-dynamic-field');
110
+ // 3. Gán dữ liệu label vào nội dung hiển thị
111
+ const { label, fieldId } = node.attrs;
112
+ dom.textContent = label || fieldId || 'Unknown Field';
113
+ return {
114
+ dom
115
+ };
116
+ };
117
+ },
118
+ /**
100
119
  * Add custom commands for inserting dynamic fields
101
120
  */ addCommands () {
102
121
  return {