@@ -132,7 +132,6 @@ defineOptions({
132132 name: ' PdfEditor' ,
133133})
134134
135- // PDFElements expects the worker path to be available before its own mount.
136135ensurePdfWorker ()
137136
138137const props = withDefaults (defineProps <{
@@ -151,14 +150,13 @@ const emit = defineEmits<{
151150 (event : ' pdf-editor:end-init' , payload : EndInitPayload ): void
152151 (event : ' pdf-editor:on-delete-signer' , payload : VisibleElementRecord ): void
153152 (event : ' pdf-editor:object-click' , payload : Record <string , unknown >): void
154- (event : ' pdf-editor:signer-added ' ): void
153+ (event : ' pdf-editor:adding-ended ' ): void
155154}>()
156155
157156const pdfElements = ref <PdfElementsInstance | null >(null )
158157const pendingAddedObjectCount = ref <number | null >(null )
159158
160159let pendingAddCheckTimer: ReturnType <typeof setTimeout > | null = null
161- let pendingAddCheckRetries = 0
162160
163161const ignoreClickOutsideSelectors = computed (() => [' .action-item__popper' , ' .action-item' ])
164162
@@ -275,10 +273,14 @@ function clearPendingAddCheck() {
275273 clearTimeout (pendingAddCheckTimer )
276274 pendingAddCheckTimer = null
277275 }
278- pendingAddCheckRetries = 0
279276 pendingAddedObjectCount .value = null
280277}
281278
279+ function finishPendingAddCheck() {
280+ clearPendingAddCheck ()
281+ emit (' pdf-editor:adding-ended' )
282+ }
283+
282284function checkSignerAdded() {
283285 const objectsBefore = pendingAddedObjectCount .value
284286 if (objectsBefore === null ) {
@@ -290,27 +292,14 @@ function checkSignerAdded() {
290292 const objectsAfter = getTotalObjectsCount ()
291293
292294 if (objectsAfter > objectsBefore ) {
293- clearPendingAddCheck ()
294- emit (' pdf-editor:signer-added' )
295+ finishPendingAddCheck ()
295296 return
296297 }
297298
298- // Fallback: once add mode ends, unblock the UI even if the object count
299- // comparison was not conclusive due timing/reactivity.
300299 if (! isAddingMode ) {
301- clearPendingAddCheck ()
302- emit (' pdf-editor:signer-added' )
303- return
304- }
305-
306- // Poll while the external component still processes placement.
307- if (pendingAddCheckRetries < 300 ) {
308- pendingAddCheckRetries ++
309- pendingAddCheckTimer = setTimeout (checkSignerAdded , 100 )
300+ finishPendingAddCheck ()
310301 return
311302 }
312-
313- clearPendingAddCheck ()
314303}
315304
316305function scheduleSignerAddedCheck() {
@@ -342,11 +331,9 @@ function startAddingSigner(signer: SignerSummaryRecord | SignerDetailRecord | nu
342331 signer: signerPayload ,
343332 })
344333 pendingAddedObjectCount .value = getTotalObjectsCount ()
345- pendingAddCheckRetries = 0
346334 if (pendingAddCheckTimer !== null ) {
347335 clearTimeout (pendingAddCheckTimer )
348336 }
349- pendingAddCheckTimer = setTimeout (checkSignerAdded , 100 )
350337
351338 return true
352339}
0 commit comments