Created
March 8, 2019 03:56
-
-
Save gminero/781c18f48239caafd6a01a4eb75986c8 to your computer and use it in GitHub Desktop.
lex freeze when debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track } from 'lwc'; | |
import ResourcesC from '@salesforce/resourceUrl/CoveoV2__searchUi'; | |
import { loadScript, loadStyle } from 'lightning/platformResourceLoader'; | |
/* | |
CoveoV2 resources can be found at | |
https://docs.coveo.com/en/319/javascript-search-framework/downloading-the-javascript-search-framework | |
OR http://productupdate.coveo.com/?product=coveo-search-ui | |
*/ | |
const main_html = `<div id="search" class="CoveoSearchInterface" data-design="new" data-enable-history="false" data-auto-trigger-query='false'> | |
<div class="coveo-tab-section"> | |
<a class="CoveoTab" data-id="All" data-caption="All Content"></a> | |
</div> | |
<div class="coveo-search-section"> | |
<div class="CoveoSearchbox"></div> | |
<div class="coveo-main-section"> | |
<div class="coveo-results-column"> | |
<div class="CoveoResultList"> | |
<script id="mySimpleResultTemplate" class="result-template" type="text/underscore"> | |
<div class="CoveoResultLink"></div> | |
</script> | |
</div> | |
</div> | |
</div> | |
</div>`; | |
export default class HelloWorld extends LightningElement { | |
@track error; | |
@track stack; | |
coveoInitialized = false; | |
errorCallback(error) { | |
this.error = error; | |
console.log(this.error) | |
} | |
renderedCallback() { | |
if (this.coveoInitialized) { | |
return; | |
} | |
this.coveoInitialized = true; | |
console.log('rendering renderer') | |
// initialize component | |
Promise.all([ | |
loadScript(this, ResourcesC + '/js/CoveoJsSearch.min.js'), | |
loadStyle(this, ResourcesC + '/css/CoveoFullSearchNewDesign.css'), | |
loadScript(this, ResourcesC + '/js/templates/templatesNew.js') | |
]).then(() => { | |
const container = this.template.querySelector('.container'); | |
container.innerHTML = main_html; | |
this.initCoveo(); | |
}).catch(error => { | |
console.log(error) | |
}); | |
} | |
connectedCallback(){ | |
console.log('connectedCallback'); | |
} | |
initCoveo(){ | |
console.log('initing coveo'); | |
const cardTemplate = `<div class="coveo-result-frame"> | |
<div class="coveo-result-row"> | |
<div class="coveo-result-cell" style="padding-left:15px;"> | |
<div class="coveo-result-row"> | |
<div class="coveo-result-cell" style="font-size:18px;"> | |
<a class="CoveoResultLink" > | |
</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="coveo-result-row"> | |
</div> | |
</div>`; | |
Coveo.TemplateCache.templates = {}; | |
Coveo.TemplateCache.registerTemplate("card-default", Coveo.HtmlTemplate.fromString(cardTemplate, | |
{ | |
"condition": null, | |
"layout": "card", | |
"mobile": null, | |
"role": null | |
}), true, true); | |
Coveo.SearchEndpoint.configureSampleEndpoint(); | |
const root = this.template.querySelector(".CoveoSearchInterface"); | |
Coveo.init(root); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld"> | |
<apiVersion>45.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightning__AppPage</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__HomePage</target> | |
<target>lightningCommunity__Page</target> | |
<target>lightningCommunity__Default</target> | |
</targets> | |
</LightningComponentBundle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="slds-m-around_medium"> | |
<div class="container" lwc:dom="manual"></div> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment