Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion assets/js/autocomplete/autocomplete-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ export function moveAutocompleteSelection (offset) {
setAutocompleteSelection(newAutocompleteIndex(offset))
}

function handlePreviewMessage (event) {
if (event.origin !== 'null' && event.origin !== window.location.origin) return

if (event.data.type === 'preview') {
const { maxHeight, contentHeight } = event.data
const previewContainer = qs('.autocomplete-preview')
if (previewContainer) {
previewContainer.style.height = `${Math.min(maxHeight, contentHeight + 32)}px`
}
}
}

export function setAutocompleteSelection (index) {
state.selectedIdx = index
const suggestionList = qs(AUTOCOMPLETE_SUGGESTION_LIST_SELECTOR)
Expand Down Expand Up @@ -150,12 +162,16 @@ export function showPreview (elementToSelect) {

if (elementToSelect) {
setAutocompleteSelection(parseInt(elementToSelect.dataset.index))
window.addEventListener('message', handlePreviewMessage)
}
}

function removePreview () {
const preview = qs('.autocomplete-preview')
if (preview) { preview.remove() }
if (preview) {
preview.remove()
window.removeEventListener('message', handlePreviewMessage)
}
}

function newAutocompleteIndex (offset) {
Expand Down
12 changes: 12 additions & 0 deletions assets/js/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ function preview (previewing) {
replaceContents(previewing)
makeLinksOpenInParent()
scrollToTop()
sendPreviewInfoToParent()
}

function sendPreviewInfoToParent () {
const maxHeight = document.body.scrollHeight
const contentHeight = document.getElementById('content').scrollHeight
const message = {
type: 'preview',
maxHeight,
contentHeight
}
window.parent.postMessage(message, '*')
}

function makeLinksOpenInParent () {
Expand Down
56 changes: 56 additions & 0 deletions formatters/html/dist/html-EN2IJ2EZ.js

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions formatters/html/dist/html-Y7ASKYHF.js

This file was deleted.