@tryghost/kg-parser-plugins
Advanced tools
Comparing version 2.9.1 to 2.10.0
@@ -15,3 +15,3 @@ 'use strict'; | ||
function fromKoenigCard$4() { | ||
function fromKoenigCard$5() { | ||
return function kgButtonCardToCard(node, builder, {addSection, nodeFinished}) { | ||
@@ -353,3 +353,3 @@ if (node.nodeType !== 1 || !node.classList.contains('kg-button-card')) { | ||
// into a HTML card rather than being put through the normal parse+plugins | ||
function fromKoenigCard$3() { | ||
function fromKoenigCard$4() { | ||
return function kgHtmlCardToCard(node, builder, {addSection, nodeFinished}) { | ||
@@ -404,3 +404,3 @@ if (node.nodeType !== 8 || node.nodeValue !== 'kg-card-begin: html') { | ||
function fromKoenigCard$2() { | ||
function fromKoenigCard$3() { | ||
return function kgButtonCardToCard(node, builder, {addSection, nodeFinished}) { | ||
@@ -458,3 +458,3 @@ if (node.nodeType !== 1 || !node.classList.contains('kg-product-card')) { | ||
function fromKoenigCard$1() { | ||
function fromKoenigCard$2() { | ||
return function kgAudioCardToCard(node, builder, {addSection, nodeFinished}) { | ||
@@ -501,3 +501,3 @@ if (node.nodeType !== 1 || !node.classList.contains('kg-audio-card')) { | ||
function fromKoenigCard() { | ||
function fromKoenigCard$1() { | ||
return function kgVideoCardToCard(node, builder, {addSection, nodeFinished}) { | ||
@@ -537,2 +537,76 @@ if (node.nodeType !== 1 || !node.classList.contains('kg-video-card')) { | ||
function fromKoenigCard(options) { | ||
return function kgBeforeAfterCardToCard(node, builder, {addSection, nodeFinished}) { | ||
if (node.nodeType !== 1 || !node.classList.contains('kg-before-after-card')) { | ||
return; | ||
} | ||
const cardWidth = node.classList.contains('kg-width-full') ? 'full' : 'wide'; | ||
const images = node.querySelectorAll('img'); | ||
const beforeImage = images[1]; | ||
const afterImage = images[0]; | ||
if (!beforeImage || !afterImage) { | ||
return; | ||
} | ||
const payload = { | ||
cardWidth, | ||
beforeImage: { | ||
width: beforeImage.width, | ||
src: beforeImage.src | ||
}, | ||
afterImage: { | ||
width: afterImage.width, | ||
src: afterImage.src | ||
} | ||
}; | ||
addFigCaptionToPayload(node, payload, {options}); | ||
const cardSection = builder.createCardSection('before-after', payload); | ||
addSection(cardSection); | ||
nodeFinished(); | ||
}; | ||
} | ||
function fromJetpackCard(options) { | ||
return function jetpackJuxtaposeToCard(node, builder, {addSection, nodeFinished}) { | ||
if (node.nodeType !== 1 || !node.classList.contains('wp-block-jetpack-image-compare')) { | ||
return; | ||
} | ||
const cardWidth = 'wide'; | ||
const images = node.querySelectorAll('img'); | ||
const beforeImage = images[0]; | ||
const afterImage = images[1]; | ||
if (!beforeImage || !afterImage) { | ||
return; | ||
} | ||
const payload = { | ||
cardWidth, | ||
beforeImage: { | ||
width: 1000, | ||
src: beforeImage.src | ||
}, | ||
afterImage: { | ||
width: 1000, | ||
src: afterImage.src | ||
} | ||
}; | ||
addFigCaptionToPayload(node, payload, {options}); | ||
const cardSection = builder.createCardSection('before-after', payload); | ||
addSection(cardSection); | ||
nodeFinished(); | ||
}; | ||
} | ||
/* global DOMParser, window */ | ||
@@ -983,6 +1057,8 @@ | ||
return [ | ||
fromKoenigCard(options), | ||
fromJetpackCard(options), | ||
fromNFTEmbed(), | ||
fromMixtape(options), | ||
fromKoenigCard$3(), | ||
fromKoenigCard$4(), | ||
fromKoenigCard$5(), | ||
fromWordpressButton(), | ||
@@ -992,5 +1068,5 @@ fromSubstackButton(), | ||
kgToggleCardToCard, | ||
fromKoenigCard$3(), | ||
fromKoenigCard$2(), | ||
fromKoenigCard$1(), | ||
fromKoenigCard(), | ||
blockquoteWithChildren, | ||
@@ -997,0 +1073,0 @@ fromBr(), |
@@ -13,3 +13,3 @@ import cleanBasicHtml from '@tryghost/kg-clean-basic-html'; | ||
function fromKoenigCard$4() { | ||
function fromKoenigCard$5() { | ||
return function kgButtonCardToCard(node, builder, _ref) { | ||
@@ -384,3 +384,3 @@ let { | ||
// into a HTML card rather than being put through the normal parse+plugins | ||
function fromKoenigCard$3() { | ||
function fromKoenigCard$4() { | ||
return function kgHtmlCardToCard(node, builder, _ref) { | ||
@@ -449,3 +449,3 @@ let { | ||
function fromKoenigCard$2() { | ||
function fromKoenigCard$3() { | ||
return function kgButtonCardToCard(node, builder, _ref) { | ||
@@ -508,3 +508,3 @@ let { | ||
function fromKoenigCard$1() { | ||
function fromKoenigCard$2() { | ||
return function kgAudioCardToCard(node, builder, _ref) { | ||
@@ -560,3 +560,3 @@ let { | ||
function fromKoenigCard() { | ||
function fromKoenigCard$1() { | ||
return function kgVideoCardToCard(node, builder, _ref) { | ||
@@ -604,2 +604,81 @@ let { | ||
function fromKoenigCard(options) { | ||
return function kgBeforeAfterCardToCard(node, builder, _ref) { | ||
let { | ||
addSection, | ||
nodeFinished | ||
} = _ref; | ||
if (node.nodeType !== 1 || !node.classList.contains('kg-before-after-card')) { | ||
return; | ||
} | ||
const cardWidth = node.classList.contains('kg-width-full') ? 'full' : 'wide'; | ||
const images = node.querySelectorAll('img'); | ||
const beforeImage = images[1]; | ||
const afterImage = images[0]; | ||
if (!beforeImage || !afterImage) { | ||
return; | ||
} | ||
const payload = { | ||
cardWidth, | ||
beforeImage: { | ||
width: beforeImage.width, | ||
src: beforeImage.src | ||
}, | ||
afterImage: { | ||
width: afterImage.width, | ||
src: afterImage.src | ||
} | ||
}; | ||
addFigCaptionToPayload(node, payload, { | ||
options | ||
}); | ||
const cardSection = builder.createCardSection('before-after', payload); | ||
addSection(cardSection); | ||
nodeFinished(); | ||
}; | ||
} | ||
function fromJetpackCard(options) { | ||
return function jetpackJuxtaposeToCard(node, builder, _ref2) { | ||
let { | ||
addSection, | ||
nodeFinished | ||
} = _ref2; | ||
if (node.nodeType !== 1 || !node.classList.contains('wp-block-jetpack-image-compare')) { | ||
return; | ||
} | ||
const cardWidth = 'wide'; | ||
const images = node.querySelectorAll('img'); | ||
const beforeImage = images[0]; | ||
const afterImage = images[1]; | ||
if (!beforeImage || !afterImage) { | ||
return; | ||
} | ||
const payload = { | ||
cardWidth, | ||
beforeImage: { | ||
width: 1000, | ||
src: beforeImage.src | ||
}, | ||
afterImage: { | ||
width: 1000, | ||
src: afterImage.src | ||
} | ||
}; | ||
addFigCaptionToPayload(node, payload, { | ||
options | ||
}); | ||
const cardSection = builder.createCardSection('before-after', payload); | ||
addSection(cardSection); | ||
nodeFinished(); | ||
}; | ||
} | ||
/* global DOMParser, window */ | ||
@@ -1100,3 +1179,3 @@ function createParserPlugins() { | ||
return [fromNFTEmbed(), fromMixtape(options), fromKoenigCard$3(), fromKoenigCard$4(), fromWordpressButton(), fromSubstackButton(), kgCalloutCardToCard, kgToggleCardToCard, fromKoenigCard$2(), fromKoenigCard$1(), fromKoenigCard(), blockquoteWithChildren, fromBr(), removeLeadingNewline, kgGalleryCardToCard, fromFigureBlockquote(options), // I think these can contain images | ||
return [fromKoenigCard(options), fromJetpackCard(options), fromNFTEmbed(), fromMixtape(options), fromKoenigCard$4(), fromKoenigCard$5(), fromWordpressButton(), fromSubstackButton(), kgCalloutCardToCard, kgToggleCardToCard, fromKoenigCard$3(), fromKoenigCard$2(), fromKoenigCard$1(), blockquoteWithChildren, fromBr(), removeLeadingNewline, kgGalleryCardToCard, fromFigureBlockquote(options), // I think these can contain images | ||
grafGalleryToCard, sqsGalleriesToCard, figureToImageCard, imgToCard, hrToCard, figureToCodeCard, preCodeToCard, fromFigureIframe(options), fromIframe(), // Process iFrames without figures after ones with | ||
@@ -1103,0 +1182,0 @@ figureScriptToHtmlCard, altBlockquoteToAside, tableToHtmlCard]; |
@@ -21,2 +21,3 @@ /* global DOMParser, window */ | ||
import * as videoCard from './cards/video'; | ||
import * as beforeAfterCard from './cards/before-after'; | ||
@@ -466,2 +467,4 @@ export function createParserPlugins(_options = {}) { | ||
return [ | ||
beforeAfterCard.fromKoenigCard(options), | ||
beforeAfterCard.fromJetpackCard(options), | ||
embedCard.fromNFTEmbed(), | ||
@@ -468,0 +471,0 @@ embedCard.fromMixtape(options), |
{ | ||
"name": "@tryghost/kg-parser-plugins", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"repository": "https://github.com/TryGhost/Koenig/tree/master/packages/kg-parser-plugins", | ||
@@ -47,3 +47,3 @@ "author": "Ghost Foundation", | ||
}, | ||
"gitHead": "1840081f92c136ed5f411740cc2bdebabf0957ae" | ||
"gitHead": "a650a72b05772eb2c14488c22806e5fb8a5fdbbf" | ||
} |
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
177416
16
2686