Skip to content

Commit 6b2b0b3

Browse files
committed
added hook for yafowil.widget.array
1 parent b968a96 commit 6b2b0b3

File tree

3 files changed

+12276
-10947
lines changed

3 files changed

+12276
-10947
lines changed

js/src/widget.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,36 @@ export class TiptapWidget {
135135
}
136136
}
137137
}
138-
}
138+
}
139+
140+
141+
//////////////////////////////////////////////////////////////////////////////
142+
// yafowil.widget.array integration
143+
//////////////////////////////////////////////////////////////////////////////
144+
145+
function tiptap_on_array_add(inst, context) {
146+
TiptapWidget.initialize(context);
147+
}
148+
149+
function tiptap_on_array_index(inst, row, index) {
150+
$('.div.tiptap-editor', row).each(function() {
151+
let trigger = $(this),
152+
ref_name = trigger.data('reference-name'),
153+
base_id = inst.base_id(row),
154+
base_name = base_id.replace(/\-/g, '.');
155+
trigger.data('reference-name', inst.set_value_index(
156+
ref_name,
157+
base_name,
158+
index,
159+
'.'
160+
));
161+
});
162+
}
163+
164+
$(function() {
165+
if (yafowil_array === undefined) {
166+
return;
167+
}
168+
yafowil_array.on_array_event('on_add', tiptap_on_array_add);
169+
yafowil_array.on_array_event('on_index', tiptap_on_array_index);
170+
});

0 commit comments

Comments
 (0)