@acrolinx/sidebar-sdk 2.0.2 → 2.1.0

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 +86 -0
  2. package/dist/index.js +3494 -1878
  3. package/package.json +18 -14
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import { DocumentSelection } from '@acrolinx/sidebar-interface';
11
11
  import { Editor } from 'tinymce';
12
12
  import { EditorFromTextArea } from 'codemirror';
13
13
  import { EditorView } from '@codemirror/view';
14
+ import { EditorView as EditorView_2 } from 'prosemirror-view';
14
15
  import { ExternalContent } from '@acrolinx/sidebar-interface';
15
16
  import { InitParameters } from '@acrolinx/sidebar-interface';
16
17
  import { InitResult } from '@acrolinx/sidebar-interface';
@@ -105,7 +106,9 @@ export declare interface AcrolinxSidebarIntegration {
105
106
  CKEditorAdapter: typeof CKEditorAdapter;
106
107
  CodeMirror6Adapter: typeof CodeMirror6Adapter;
107
108
  CodeMirrorAdapter: typeof CodeMirrorAdapter;
109
+ ProseMirrorAdapter: typeof ProseMirrorAdapter;
108
110
  ContentEditableAdapter: typeof ContentEditableAdapter;
111
+ HerettoContentEditableAdapter: typeof HerettoContentEditableAdapter;
109
112
  AsyncContentEditableAdapter: typeof StateBasedContentEditableAdapter;
110
113
  InputAdapter: typeof InputAdapter;
111
114
  MultiEditorAdapter: typeof MultiEditorAdapter;
@@ -203,6 +206,7 @@ export declare class AutoBindAdapter implements AdapterInterface {
203
206
 
204
207
  export declare interface AutobindConfig extends CommonAdapterConf {
205
208
  enableQuipAdapter?: boolean;
209
+ enableHerettoAdapter?: boolean;
206
210
  }
207
211
 
208
212
  export declare function autoBindFloatingSidebar(basicConf: AutoBindFloatingSidebarConfig): Promise<FloatingSidebar>;
@@ -468,6 +472,49 @@ export declare interface HasError {
468
472
 
469
473
  export declare function hasError(a: ContentExtractionResult): a is HasError;
470
474
 
475
+ /**
476
+ * Custom adapter for Heretto.com that extends AsyncContentEditableAdapter
477
+ * with custom selectRanges and replaceRanges implementation.
478
+ *
479
+ */
480
+ export declare class HerettoContentEditableAdapter extends StateBasedContentEditableAdapter {
481
+ constructor(conf: AdapterConf);
482
+ /**
483
+ * Override selectRanges to add Heretto-specific event dispatching.
484
+ *
485
+ * @param checkId - The check ID
486
+ * @param matches - Array of matches to select
487
+ * @returns Promise that resolves when selection is complete
488
+ */
489
+ selectRanges(checkId: string, matches: Match[]): Promise<void>;
490
+ /**
491
+ * Dispatch mouseup and selectionchange events to notify Heretto's GWT editor
492
+ * about the selection change.
493
+ */
494
+ private dispatchHerettoSelectionEvents;
495
+ /**
496
+ * Override replaceRanges with custom implementation for Heretto.com.
497
+ * Uses paste event to apply replacements in the Heretto editor.
498
+ *
499
+ * The replacement is done asynchronously:
500
+ * 1. First select the text
501
+ * 2. Wait for selection events to propagate
502
+ * 3. Apply replacement via paste event
503
+ *
504
+ * @param checkId - The check ID
505
+ * @param matchesWithReplacement - Array of matches with replacement suggestions
506
+ * @returns Promise that resolves when replacement is complete, rejects on error
507
+ */
508
+ replaceRanges(checkId: string, matchesWithReplacement: MatchWithReplacement[]): Promise<void>;
509
+ /**
510
+ * Apply replacement text using the paste event.
511
+ *
512
+ * @param replacementText - The text to insert in place of the selection
513
+ * @throws Error if editor is not found or not editable
514
+ */
515
+ private applyReplacementViaPaste;
516
+ }
517
+
471
518
  export declare function initFloatingSidebar(config: FloatingSidebarConfig): FloatingSidebar;
472
519
 
473
520
  export declare class InputAdapter implements AdapterInterface {
@@ -520,6 +567,19 @@ export declare function isDisplayed(element: Element): boolean;
520
567
 
521
568
  export declare function isFromSameOrigin(url: string): boolean;
522
569
 
570
+ /**
571
+ * Check if the element is in a Heretto.com DITA editor.
572
+ *
573
+ * Detection is based on multiple robust identifiers:
574
+ * 1. Domain check: must be on heretto.com
575
+ * 2. Iframe ID: element must be inside iframe with id "gwt-debug-PreviewViewImpl.previewFrame"
576
+ * 3. Body class: Heretto editor body has class "heretto"
577
+ *
578
+ * @param el - The element to check
579
+ * @returns true if element is in the Heretto DITA editor
580
+ */
581
+ export declare function isHeretto(el: Element): boolean;
582
+
523
583
  export declare function isIFrame(el: Element): el is HTMLIFrameElement;
524
584
 
525
585
  export declare function isProbablyUndesiredField(el: Element): boolean;
@@ -629,6 +689,32 @@ export declare interface PositionUpdate {
629
689
 
630
690
  export declare type PromiseProvider<T> = () => PromiseLike<T>;
631
691
 
692
+ export declare class ProseMirrorAdapter implements AdapterInterface {
693
+ private config;
694
+ private currentContentChecking?;
695
+ private lastContentChecked?;
696
+ private formatDetectedByCheck;
697
+ constructor(conf: ProseMirrorAdapterConf);
698
+ configure(partialConfig: Partial<ProseMirrorAdapterConf>): void;
699
+ private validateConf;
700
+ getContent(): string;
701
+ getFormat(): string;
702
+ extractContentForCheck(opts: ExtractContentForCheckOpts): ContentExtractionResult;
703
+ private getSelection;
704
+ registerCheckResult(checkResult: SuccessfulCheckResult): void;
705
+ registerCheckCall(_checkInfo: Check): void;
706
+ private lookupMatchesOrThrow;
707
+ selectRanges(_checkId: string, matches: Match[]): void;
708
+ replaceRanges(_checkId: string, matchesWithReplacement: MatchWithReplacement[]): void;
709
+ private getEscapeFunction;
710
+ private selectRangeAndScroll;
711
+ }
712
+
713
+ declare type ProseMirrorAdapterConf = {
714
+ editor: EditorView_2;
715
+ format?: string;
716
+ };
717
+
632
718
  /**
633
719
  * Just a proof of concept.
634
720
  */