From e37add68125e9e28f31af73a63e6b9f93e6384dd Mon Sep 17 00:00:00 2001 From: iseulde Date: Wed, 4 Oct 2017 16:30:29 +0200 Subject: [PATCH 1/3] Paste caption shortcode --- blocks/api/raw-handling/index.js | 131 ++++++++++-------- .../api/raw-handling/shortcode-converter.js | 73 ++++++++++ blocks/library/image/index.js | 35 ++++- lib/client-assets.php | 2 +- test/unit/setup-wp-aliases.js | 7 +- 5 files changed, 191 insertions(+), 57 deletions(-) create mode 100644 blocks/api/raw-handling/shortcode-converter.js diff --git a/blocks/api/raw-handling/index.js b/blocks/api/raw-handling/index.js index d4d42e3790095..1c28130ff05d1 100644 --- a/blocks/api/raw-handling/index.js +++ b/blocks/api/raw-handling/index.js @@ -2,6 +2,7 @@ * External dependencies */ import { find, get } from 'lodash'; +import showdown from 'showdown'; /** * Internal dependencies @@ -22,7 +23,7 @@ import blockquoteNormaliser from './blockquote-normaliser'; import tableNormaliser from './table-normaliser'; import inlineContentConverter from './inline-content-converter'; import { deepFilterHTML, isInvalidInline, isNotWhitelisted, isPlain, isInline } from './utils'; -import showdown from 'showdown'; +import shortcodeConverter from './shortcode-converter'; /** * Converts an HTML string to known blocks. Strips everything else. @@ -33,13 +34,17 @@ import showdown from 'showdown'; * @return {Array|String} A list of blocks or a string, depending on the `inline` option. */ export default function rawHandler( { HTML, plainText = '', inline = null } ) { + // First of all, strip any meta tags. HTML = HTML.replace( /]+>/, '' ); - // Block delimiters detected. + // If we detect block delimiters, parse entirely as blocks. if ( ! inline && HTML.indexOf( '