acrolinx-sidebar-sdk
Advanced tools
Comparing version 0.4.33 to 0.4.34
@@ -20,2 +20,3 @@ "use strict"; | ||
var detect_browser_1 = require("../utils/detect-browser"); | ||
var scrolling_1 = require("../utils/scrolling"); | ||
var text_dom_mapping_1 = require("../utils/text-dom-mapping"); | ||
@@ -55,3 +56,2 @@ var diff_based_1 = require("../lookup/diff-based"); | ||
text.focus(); | ||
text.scrollIntoView(); | ||
this.scrollElementIntoView(text); | ||
@@ -73,3 +73,3 @@ utils_1.removeNode(text); | ||
AbstractRichtextEditorAdapter.prototype.scrollElementIntoView = function (el) { | ||
el.scrollIntoView(); | ||
scrolling_1.scrollIntoView(el, this.config.scrollOffsetY); | ||
}; | ||
@@ -76,0 +76,0 @@ AbstractRichtextEditorAdapter.prototype.selectRanges = function (checkId, matches) { |
import { Match, MatchWithReplacement, Check, DocumentSelection, CheckedDocumentPart, CheckInformationKeyValuePair } from "../acrolinx-libs/plugin-interfaces"; | ||
export interface CommonAdapterConf { | ||
scrollOffsetY?: number; | ||
/** | ||
* Options forwarded to scrollIntoView in some adapters. | ||
* If set, scrollOffsetY might be ignored. | ||
* Experimental. | ||
*/ | ||
scrollIntoViewOptions?: ScrollIntoViewOptions; | ||
} | ||
@@ -11,0 +5,0 @@ export interface HasEditorID extends CommonAdapterConf { |
@@ -15,3 +15,2 @@ /// <reference types="ckeditor" /> | ||
isInWysiwygMode(): boolean; | ||
protected scrollElementIntoView(el: HTMLElement): void; | ||
} |
@@ -20,3 +20,2 @@ "use strict"; | ||
var AbstractRichtextEditorAdapter_1 = require("./AbstractRichtextEditorAdapter"); | ||
var scrolling_1 = require("../utils/scrolling"); | ||
var CKEditorAdapter = /** @class */ (function (_super) { | ||
@@ -70,5 +69,2 @@ tslib_1.__extends(CKEditorAdapter, _super); | ||
}; | ||
CKEditorAdapter.prototype.scrollElementIntoView = function (el) { | ||
scrolling_1.scrollIntoView(el, this.config.scrollOffsetY); | ||
}; | ||
return CKEditorAdapter; | ||
@@ -75,0 +71,0 @@ }(AbstractRichtextEditorAdapter_1.AbstractRichtextEditorAdapter)); |
@@ -1,4 +0,4 @@ | ||
import { AbstractRichtextEditorAdapter } from "./AbstractRichtextEditorAdapter"; | ||
import { AdapterConf } from "./AdapterInterface"; | ||
import { DocumentSelection } from "../acrolinx-libs/plugin-interfaces"; | ||
import { AbstractRichtextEditorAdapter } from './AbstractRichtextEditorAdapter'; | ||
import { AdapterConf } from './AdapterInterface'; | ||
import { DocumentSelection } from '../acrolinx-libs/plugin-interfaces'; | ||
export declare class ContentEditableAdapter extends AbstractRichtextEditorAdapter { | ||
@@ -11,3 +11,2 @@ element: HTMLElement; | ||
getEditorDocument(): Document; | ||
protected scrollElementIntoView(el: HTMLElement): void; | ||
} |
@@ -21,3 +21,2 @@ "use strict"; | ||
var AdapterInterface_1 = require("./AdapterInterface"); | ||
var scrolling_1 = require("../utils/scrolling"); | ||
var check_selection_1 = require("../utils/check-selection"); | ||
@@ -43,10 +42,2 @@ var ContentEditableAdapter = /** @class */ (function (_super) { | ||
}; | ||
ContentEditableAdapter.prototype.scrollElementIntoView = function (el) { | ||
if (('scrollBehavior' in document.body.style) && this.config.scrollIntoViewOptions) { | ||
el.scrollIntoView(this.config.scrollIntoViewOptions); | ||
} | ||
else { | ||
scrolling_1.scrollIntoView(el, this.config.scrollOffsetY); | ||
} | ||
}; | ||
return ContentEditableAdapter; | ||
@@ -53,0 +44,0 @@ }(AbstractRichtextEditorAdapter_1.AbstractRichtextEditorAdapter)); |
@@ -13,3 +13,2 @@ import { Editor } from 'tinymce'; | ||
getEditorDocument(): Document; | ||
scrollToCurrentSelection(): void; | ||
} |
@@ -48,23 +48,2 @@ "use strict"; | ||
}; | ||
TinyMCEAdapter.prototype.scrollToCurrentSelection = function () { | ||
var selection = this.getEditorDocument().getSelection(); | ||
if (selection) { | ||
try { | ||
var originalRange = selection.getRangeAt(0); | ||
var startContainer = originalRange.startContainer, startOffset = originalRange.startOffset, endContainer = originalRange.endContainer, endOffset = originalRange.endOffset; | ||
selection.collapseToStart(); | ||
// TODO: Does this line cause a failing selection in IE11 sometimes? | ||
this.getEditor().insertContent(''); | ||
var restoredRange = this.getEditorDocument().createRange(); | ||
restoredRange.setStart(startContainer, startOffset); | ||
restoredRange.setEnd(endContainer, endOffset); | ||
selection.removeAllRanges(); | ||
selection.addRange(restoredRange); | ||
AbstractRichtextEditorAdapter_1.removeEmptyTextNodesIfNeeded(originalRange); | ||
} | ||
catch (error) { | ||
console.log('Scrolling Error: ', error); | ||
} | ||
} | ||
}; | ||
return TinyMCEAdapter; | ||
@@ -71,0 +50,0 @@ }(AbstractRichtextEditorAdapter_1.AbstractRichtextEditorAdapter)); |
@@ -43,4 +43,18 @@ "use strict"; | ||
if (localTopOffset === void 0) { localTopOffset = 0; } | ||
// Detect if ScrollIntoViewOptions are supported. | ||
// Should be supported currently (April 2019) in chrome and firefox. | ||
if (('scrollBehavior' in document.body.style)) { | ||
try { | ||
// For Chrome and Firefox (currently). | ||
targetEl.scrollIntoView({ block: 'center' }); | ||
return; | ||
} | ||
catch (e) { | ||
// According to https://stackoverflow.com/questions/46919627/is-it-possible-to-test-for-scrollintoview-browser-compatibility | ||
// it might still fail in strange browsers like "WaterFox". | ||
} | ||
} | ||
// Here begins a dubious workaround for not-so-modern browsers. | ||
targetEl.scrollIntoView(); | ||
if (!windowTopOffset) { | ||
targetEl.scrollIntoView(); | ||
return; | ||
@@ -47,0 +61,0 @@ } |
{ | ||
"name": "acrolinx-sidebar-sdk", | ||
"description": "Acrolinx Sidebar SDK for JavaScript", | ||
"version": "0.4.33", | ||
"version": "0.4.34", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Acrolinx", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1789500
5820