+
+ enterSectionSelectMode() {
+ const sections = Array.from(document.querySelectorAll('.page-content [id^="bkmrk"]'));
+ for (const section of sections) {
+ section.setAttribute('tabindex', '0');
+ }
+
+ sections[0].focus();
+
+ DOM.onEnterPress(sections, event => {
+ this.showPointerAtTarget(event.target, 0, true);
+ this.pointer.focus();
+ });
+ }
+
+ createCommentAtPointer(event) {
+ if (!this.targetElement) {
+ return;
+ }
+
+ const normalisedElemHtml = this.targetElement.outerHTML.replace(/\s{2,}/g, '');
+ const refId = this.targetElement.id;
+ const hash = cyrb53(normalisedElemHtml);
+ let range = '';
+ if (this.targetSelectionRange) {
+ const commonContainer = this.targetSelectionRange.commonAncestorContainer;
+ if (this.targetElement.contains(commonContainer)) {
+ const start = normalizeNodeTextOffsetToParent(
+ this.targetSelectionRange.startContainer,
+ this.targetSelectionRange.startOffset,
+ this.targetElement
+ );
+ const end = normalizeNodeTextOffsetToParent(
+ this.targetSelectionRange.endContainer,
+ this.targetSelectionRange.endOffset,
+ this.targetElement
+ );
+ range = `${start}-${end}`;
+ }
+ }
+
+ const reference = `${refId}:${hash}:${range}`;
+ console.log(reference);
+ }
+
+}