@phuong-tran-redoc/document-engine-core 0.0.35 → 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
|
@@ -93,10 +93,29 @@ import { Node, mergeAttributes } from '@tiptap/core';
|
|
|
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 {
|