@acrolinx/sidebar-sdk 2.0.2 → 2.0.3

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +58 -0
  2. package/dist/index.js +1089 -988
  3. package/package.json +14 -14
package/dist/index.d.ts CHANGED
@@ -106,6 +106,7 @@ export declare interface AcrolinxSidebarIntegration {
106
106
  CodeMirror6Adapter: typeof CodeMirror6Adapter;
107
107
  CodeMirrorAdapter: typeof CodeMirrorAdapter;
108
108
  ContentEditableAdapter: typeof ContentEditableAdapter;
109
+ HerettoContentEditableAdapter: typeof HerettoContentEditableAdapter;
109
110
  AsyncContentEditableAdapter: typeof StateBasedContentEditableAdapter;
110
111
  InputAdapter: typeof InputAdapter;
111
112
  MultiEditorAdapter: typeof MultiEditorAdapter;
@@ -203,6 +204,7 @@ export declare class AutoBindAdapter implements AdapterInterface {
203
204
 
204
205
  export declare interface AutobindConfig extends CommonAdapterConf {
205
206
  enableQuipAdapter?: boolean;
207
+ enableHerettoAdapter?: boolean;
206
208
  }
207
209
 
208
210
  export declare function autoBindFloatingSidebar(basicConf: AutoBindFloatingSidebarConfig): Promise<FloatingSidebar>;
@@ -468,6 +470,49 @@ export declare interface HasError {
468
470
 
469
471
  export declare function hasError(a: ContentExtractionResult): a is HasError;
470
472
 
473
+ /**
474
+ * Custom adapter for Heretto.com that extends AsyncContentEditableAdapter
475
+ * with custom selectRanges and replaceRanges implementation.
476
+ *
477
+ */
478
+ export declare class HerettoContentEditableAdapter extends StateBasedContentEditableAdapter {
479
+ constructor(conf: AdapterConf);
480
+ /**
481
+ * Override selectRanges to add Heretto-specific event dispatching.
482
+ *
483
+ * @param checkId - The check ID
484
+ * @param matches - Array of matches to select
485
+ * @returns Promise that resolves when selection is complete
486
+ */
487
+ selectRanges(checkId: string, matches: Match[]): Promise<void>;
488
+ /**
489
+ * Dispatch mouseup and selectionchange events to notify Heretto's GWT editor
490
+ * about the selection change.
491
+ */
492
+ private dispatchHerettoSelectionEvents;
493
+ /**
494
+ * Override replaceRanges with custom implementation for Heretto.com.
495
+ * Uses paste event to apply replacements in the Heretto editor.
496
+ *
497
+ * The replacement is done asynchronously:
498
+ * 1. First select the text
499
+ * 2. Wait for selection events to propagate
500
+ * 3. Apply replacement via paste event
501
+ *
502
+ * @param checkId - The check ID
503
+ * @param matchesWithReplacement - Array of matches with replacement suggestions
504
+ * @returns Promise that resolves when replacement is complete, rejects on error
505
+ */
506
+ replaceRanges(checkId: string, matchesWithReplacement: MatchWithReplacement[]): Promise<void>;
507
+ /**
508
+ * Apply replacement text using the paste event.
509
+ *
510
+ * @param replacementText - The text to insert in place of the selection
511
+ * @throws Error if editor is not found or not editable
512
+ */
513
+ private applyReplacementViaPaste;
514
+ }
515
+
471
516
  export declare function initFloatingSidebar(config: FloatingSidebarConfig): FloatingSidebar;
472
517
 
473
518
  export declare class InputAdapter implements AdapterInterface {
@@ -520,6 +565,19 @@ export declare function isDisplayed(element: Element): boolean;
520
565
 
521
566
  export declare function isFromSameOrigin(url: string): boolean;
522
567
 
568
+ /**
569
+ * Check if the element is in a Heretto.com DITA editor.
570
+ *
571
+ * Detection is based on multiple robust identifiers:
572
+ * 1. Domain check: must be on heretto.com
573
+ * 2. Iframe ID: element must be inside iframe with id "gwt-debug-PreviewViewImpl.previewFrame"
574
+ * 3. Body class: Heretto editor body has class "heretto"
575
+ *
576
+ * @param el - The element to check
577
+ * @returns true if element is in the Heretto DITA editor
578
+ */
579
+ export declare function isHeretto(el: Element): boolean;
580
+
523
581
  export declare function isIFrame(el: Element): el is HTMLIFrameElement;
524
582
 
525
583
  export declare function isProbablyUndesiredField(el: Element): boolean;