@@ -24,8 +24,17 @@ import {
2424} from '@extensions/comment/comments-helpers.js' ;
2525import DocxZipper from '@core/DocxZipper.js' ;
2626
27+ /**
28+ * @typedef {Object } FieldValue
29+ * @property {string } input_id The id of the input field
30+ * @property {string } input_value The value to insert into the field
31+ */
32+
2733/**
2834 * Editor main class.
35+ *
36+ * Expects a config object.
37+ * @class
2938 */
3039export class Editor extends EventEmitter {
3140 #commandService;
@@ -1213,21 +1222,23 @@ export class Editor extends EventEmitter {
12131222 * pre-process the document as needed prior to running in the annotator.
12141223 *
12151224 * Currently this is only used for table generation but additional pre-processing can be done here.
1216- * @param {Array[Object] } annotationValues
1225+ *
1226+ * @param {FieldValue[] } annotationValues
12171227 * @returns {void }
12181228 */
1219- prepareForAnnotations ( annotationValues = [ ] , hiddenIds = [ ] ) {
1229+ prepareForAnnotations ( annotationValues = [ ] ) {
12201230 const { tr } = this . state ;
12211231 const { dispatch } = this . view ;
1222- const newTr = AnnotatorServices . processTables ( { editor : this , tr, annotationValues, hiddenIds } ) ;
1232+ const newTr = AnnotatorServices . processTables ( { editor : this , tr, annotationValues } ) ;
12231233 this . view . dispatch ( newTr ) ;
12241234 }
12251235
12261236 /**
12271237 * Annotate the document with the given annotation values.
12281238 *
1229- * @param {Array[Object] } annotationValues
1230- * @param {Array[String] } hiddenIds
1239+ * @param {FieldValue[] } annotationValues List of field values to apply.
1240+ * @param {String[] } hiddenIds List of field ids to remove from the document.
1241+ * @returns {void }
12311242 */
12321243 annotate ( annotationValues = [ ] , hiddenIds = [ ] ) {
12331244 const { state, view, schema } = this ;
@@ -1241,10 +1252,8 @@ export class Editor extends EventEmitter {
12411252 hiddenFieldIds : hiddenIds
12421253 } ) ;
12431254
1244- // 3) Finally dispatch *once*:
1245- if ( tr . docChanged ) {
1246- view . dispatch ( tr . scrollIntoView ( ) ) ;
1247- }
1255+ // Dispatch everything in a single transaction, which makes this undo-able in a single undo
1256+ if ( tr . docChanged ) view . dispatch ( tr . scrollIntoView ( ) ) ;
12481257 }
12491258
12501259}
0 commit comments