Skip to content

Instantly share code, notes, and snippets.

View kmoskwiak's full-sized avatar
🦄
woof!

Kasper Moskwiak kmoskwiak

🦄
woof!
View GitHub Profile
@kmoskwiak
kmoskwiak / convert-html-to-mobiledoc.js
Last active September 30, 2019 11:10
Parse HTML into mobiledoc format. Just run `npm install` and `npm start`. Original code in issue: https://github.com/bustle/mobiledoc-kit/issues/631
//import refetchMediaCards from './refetch-media-cards' //refetch media cards is our logic for rehosting images and refetching embeds. Totally up to you what to do here
function refetchMediaCards(item) {
return Promise.resolve(item);
}
export async function convertHTMLToMobiledoc(post, domContext) {
try {
return domContext.evaluate(postObject => window.tzrPostContentToMobiledoc(postObject), post)
.then((bodies) => {
@kmoskwiak
kmoskwiak / app.js
Created July 14, 2018 21:36
Create HTML element
class MyCustomElement {
constructor(id) {
let html = this.getHtml(id);
let temporaryContainer = document.createElement('div');
temporaryContainer.innerHTML = html.trim();
this.element = temporaryContainer.firstChild;
}
getElement() {
return this.element;