Edit File by line
/home/zeestwma/richards.../wp-inclu.../js/dist
File: block-serialization-default-parser.js
/******/ (() => { // webpackBootstrap
[0] Fix | Delete
/******/ "use strict";
[1] Fix | Delete
/******/ // The require scope
[2] Fix | Delete
/******/ var __webpack_require__ = {};
[3] Fix | Delete
/******/
[4] Fix | Delete
/************************************************************************/
[5] Fix | Delete
/******/ /* webpack/runtime/define property getters */
[6] Fix | Delete
/******/ (() => {
[7] Fix | Delete
/******/ // define getter functions for harmony exports
[8] Fix | Delete
/******/ __webpack_require__.d = (exports, definition) => {
[9] Fix | Delete
/******/ for(var key in definition) {
[10] Fix | Delete
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
[11] Fix | Delete
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
[12] Fix | Delete
/******/ }
[13] Fix | Delete
/******/ }
[14] Fix | Delete
/******/ };
[15] Fix | Delete
/******/ })();
[16] Fix | Delete
/******/
[17] Fix | Delete
/******/ /* webpack/runtime/hasOwnProperty shorthand */
[18] Fix | Delete
/******/ (() => {
[19] Fix | Delete
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
[20] Fix | Delete
/******/ })();
[21] Fix | Delete
/******/
[22] Fix | Delete
/******/ /* webpack/runtime/make namespace object */
[23] Fix | Delete
/******/ (() => {
[24] Fix | Delete
/******/ // define __esModule on exports
[25] Fix | Delete
/******/ __webpack_require__.r = (exports) => {
[26] Fix | Delete
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
[27] Fix | Delete
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
[28] Fix | Delete
/******/ }
[29] Fix | Delete
/******/ Object.defineProperty(exports, '__esModule', { value: true });
[30] Fix | Delete
/******/ };
[31] Fix | Delete
/******/ })();
[32] Fix | Delete
/******/
[33] Fix | Delete
/************************************************************************/
[34] Fix | Delete
var __webpack_exports__ = {};
[35] Fix | Delete
__webpack_require__.r(__webpack_exports__);
[36] Fix | Delete
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
[37] Fix | Delete
/* harmony export */ parse: () => (/* binding */ parse)
[38] Fix | Delete
/* harmony export */ });
[39] Fix | Delete
/**
[40] Fix | Delete
* @type {string}
[41] Fix | Delete
*/
[42] Fix | Delete
let document;
[43] Fix | Delete
/**
[44] Fix | Delete
* @type {number}
[45] Fix | Delete
*/
[46] Fix | Delete
let offset;
[47] Fix | Delete
/**
[48] Fix | Delete
* @type {ParsedBlock[]}
[49] Fix | Delete
*/
[50] Fix | Delete
let output;
[51] Fix | Delete
/**
[52] Fix | Delete
* @type {ParsedFrame[]}
[53] Fix | Delete
*/
[54] Fix | Delete
let stack;
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* @typedef {Object|null} Attributes
[58] Fix | Delete
*/
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* @typedef {Object} ParsedBlock
[62] Fix | Delete
* @property {string|null} blockName Block name.
[63] Fix | Delete
* @property {Attributes} attrs Block attributes.
[64] Fix | Delete
* @property {ParsedBlock[]} innerBlocks Inner blocks.
[65] Fix | Delete
* @property {string} innerHTML Inner HTML.
[66] Fix | Delete
* @property {Array<string|null>} innerContent Inner content.
[67] Fix | Delete
*/
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* @typedef {Object} ParsedFrame
[71] Fix | Delete
* @property {ParsedBlock} block Block.
[72] Fix | Delete
* @property {number} tokenStart Token start.
[73] Fix | Delete
* @property {number} tokenLength Token length.
[74] Fix | Delete
* @property {number} prevOffset Previous offset.
[75] Fix | Delete
* @property {number|null} leadingHtmlStart Leading HTML start.
[76] Fix | Delete
*/
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType
[80] Fix | Delete
*/
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* @typedef {[TokenType, string, Attributes, number, number]} Token
[84] Fix | Delete
*/
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Matches block comment delimiters
[88] Fix | Delete
*
[89] Fix | Delete
* While most of this pattern is straightforward the attribute parsing
[90] Fix | Delete
* incorporates a tricks to make sure we don't choke on specific input
[91] Fix | Delete
*
[92] Fix | Delete
* - since JavaScript has no possessive quantifier or atomic grouping
[93] Fix | Delete
* we are emulating it with a trick
[94] Fix | Delete
*
[95] Fix | Delete
* we want a possessive quantifier or atomic group to prevent backtracking
[96] Fix | Delete
* on the `}`s should we fail to match the remainder of the pattern
[97] Fix | Delete
*
[98] Fix | Delete
* we can emulate this with a positive lookahead and back reference
[99] Fix | Delete
* (a++)*c === ((?=(a+))\1)*c
[100] Fix | Delete
*
[101] Fix | Delete
* let's examine an example:
[102] Fix | Delete
* - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps
[103] Fix | Delete
* - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps
[104] Fix | Delete
* - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps
[105] Fix | Delete
*
[106] Fix | Delete
* this is because the possessive `++` and the atomic group `(?>)`
[107] Fix | Delete
* tell the engine that all those `a`s belong together as a single group
[108] Fix | Delete
* and so it won't split it up when stepping backwards to try and match
[109] Fix | Delete
*
[110] Fix | Delete
* if we use /((?=(a+))\1)*c/ then we get the same behavior as the atomic group
[111] Fix | Delete
* or possessive and prevent the backtracking because the `a+` is matched but
[112] Fix | Delete
* not captured. thus, we find the long string of `a`s and remember it, then
[113] Fix | Delete
* reference it as a whole unit inside our pattern
[114] Fix | Delete
*
[115] Fix | Delete
* @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead
[116] Fix | Delete
* @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups
[117] Fix | Delete
* @see https://javascript.info/regexp-infinite-backtracking-problem
[118] Fix | Delete
*
[119] Fix | Delete
* once browsers reliably support atomic grouping or possessive
[120] Fix | Delete
* quantifiers natively we should remove this trick and simplify
[121] Fix | Delete
*
[122] Fix | Delete
* @type {RegExp}
[123] Fix | Delete
*
[124] Fix | Delete
* @since 3.8.0
[125] Fix | Delete
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
[126] Fix | Delete
*/
[127] Fix | Delete
const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Constructs a block object.
[131] Fix | Delete
*
[132] Fix | Delete
* @param {string|null} blockName
[133] Fix | Delete
* @param {Attributes} attrs
[134] Fix | Delete
* @param {ParsedBlock[]} innerBlocks
[135] Fix | Delete
* @param {string} innerHTML
[136] Fix | Delete
* @param {string[]} innerContent
[137] Fix | Delete
* @return {ParsedBlock} The block object.
[138] Fix | Delete
*/
[139] Fix | Delete
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
[140] Fix | Delete
return {
[141] Fix | Delete
blockName,
[142] Fix | Delete
attrs,
[143] Fix | Delete
innerBlocks,
[144] Fix | Delete
innerHTML,
[145] Fix | Delete
innerContent
[146] Fix | Delete
};
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Constructs a freeform block object.
[151] Fix | Delete
*
[152] Fix | Delete
* @param {string} innerHTML
[153] Fix | Delete
* @return {ParsedBlock} The freeform block object.
[154] Fix | Delete
*/
[155] Fix | Delete
function Freeform(innerHTML) {
[156] Fix | Delete
return Block(null, {}, [], innerHTML, [innerHTML]);
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
/**
[160] Fix | Delete
* Constructs a frame object.
[161] Fix | Delete
*
[162] Fix | Delete
* @param {ParsedBlock} block
[163] Fix | Delete
* @param {number} tokenStart
[164] Fix | Delete
* @param {number} tokenLength
[165] Fix | Delete
* @param {number} prevOffset
[166] Fix | Delete
* @param {number|null} leadingHtmlStart
[167] Fix | Delete
* @return {ParsedFrame} The frame object.
[168] Fix | Delete
*/
[169] Fix | Delete
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
[170] Fix | Delete
return {
[171] Fix | Delete
block,
[172] Fix | Delete
tokenStart,
[173] Fix | Delete
tokenLength,
[174] Fix | Delete
prevOffset: prevOffset || tokenStart + tokenLength,
[175] Fix | Delete
leadingHtmlStart
[176] Fix | Delete
};
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Parser function, that converts input HTML into a block based structure.
[181] Fix | Delete
*
[182] Fix | Delete
* @param {string} doc The HTML document to parse.
[183] Fix | Delete
*
[184] Fix | Delete
* @example
[185] Fix | Delete
* Input post:
[186] Fix | Delete
* ```html
[187] Fix | Delete
* <!-- wp:columns {"columns":3} -->
[188] Fix | Delete
* <div class="wp-block-columns has-3-columns"><!-- wp:column -->
[189] Fix | Delete
* <div class="wp-block-column"><!-- wp:paragraph -->
[190] Fix | Delete
* <p>Left</p>
[191] Fix | Delete
* <!-- /wp:paragraph --></div>
[192] Fix | Delete
* <!-- /wp:column -->
[193] Fix | Delete
*
[194] Fix | Delete
* <!-- wp:column -->
[195] Fix | Delete
* <div class="wp-block-column"><!-- wp:paragraph -->
[196] Fix | Delete
* <p><strong>Middle</strong></p>
[197] Fix | Delete
* <!-- /wp:paragraph --></div>
[198] Fix | Delete
* <!-- /wp:column -->
[199] Fix | Delete
*
[200] Fix | Delete
* <!-- wp:column -->
[201] Fix | Delete
* <div class="wp-block-column"></div>
[202] Fix | Delete
* <!-- /wp:column --></div>
[203] Fix | Delete
* <!-- /wp:columns -->
[204] Fix | Delete
* ```
[205] Fix | Delete
*
[206] Fix | Delete
* Parsing code:
[207] Fix | Delete
* ```js
[208] Fix | Delete
* import { parse } from '@wordpress/block-serialization-default-parser';
[209] Fix | Delete
*
[210] Fix | Delete
* parse( post ) === [
[211] Fix | Delete
* {
[212] Fix | Delete
* blockName: "core/columns",
[213] Fix | Delete
* attrs: {
[214] Fix | Delete
* columns: 3
[215] Fix | Delete
* },
[216] Fix | Delete
* innerBlocks: [
[217] Fix | Delete
* {
[218] Fix | Delete
* blockName: "core/column",
[219] Fix | Delete
* attrs: null,
[220] Fix | Delete
* innerBlocks: [
[221] Fix | Delete
* {
[222] Fix | Delete
* blockName: "core/paragraph",
[223] Fix | Delete
* attrs: null,
[224] Fix | Delete
* innerBlocks: [],
[225] Fix | Delete
* innerHTML: "\n<p>Left</p>\n"
[226] Fix | Delete
* }
[227] Fix | Delete
* ],
[228] Fix | Delete
* innerHTML: '\n<div class="wp-block-column"></div>\n'
[229] Fix | Delete
* },
[230] Fix | Delete
* {
[231] Fix | Delete
* blockName: "core/column",
[232] Fix | Delete
* attrs: null,
[233] Fix | Delete
* innerBlocks: [
[234] Fix | Delete
* {
[235] Fix | Delete
* blockName: "core/paragraph",
[236] Fix | Delete
* attrs: null,
[237] Fix | Delete
* innerBlocks: [],
[238] Fix | Delete
* innerHTML: "\n<p><strong>Middle</strong></p>\n"
[239] Fix | Delete
* }
[240] Fix | Delete
* ],
[241] Fix | Delete
* innerHTML: '\n<div class="wp-block-column"></div>\n'
[242] Fix | Delete
* },
[243] Fix | Delete
* {
[244] Fix | Delete
* blockName: "core/column",
[245] Fix | Delete
* attrs: null,
[246] Fix | Delete
* innerBlocks: [],
[247] Fix | Delete
* innerHTML: '\n<div class="wp-block-column"></div>\n'
[248] Fix | Delete
* }
[249] Fix | Delete
* ],
[250] Fix | Delete
* innerHTML: '\n<div class="wp-block-columns has-3-columns">\n\n\n\n</div>\n'
[251] Fix | Delete
* }
[252] Fix | Delete
* ];
[253] Fix | Delete
* ```
[254] Fix | Delete
* @return {ParsedBlock[]} A block-based representation of the input HTML.
[255] Fix | Delete
*/
[256] Fix | Delete
const parse = doc => {
[257] Fix | Delete
document = doc;
[258] Fix | Delete
offset = 0;
[259] Fix | Delete
output = [];
[260] Fix | Delete
stack = [];
[261] Fix | Delete
tokenizer.lastIndex = 0;
[262] Fix | Delete
do {
[263] Fix | Delete
// twiddle our thumbs
[264] Fix | Delete
} while (proceed());
[265] Fix | Delete
return output;
[266] Fix | Delete
};
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
* Parses the next token in the input document.
[270] Fix | Delete
*
[271] Fix | Delete
* @return {boolean} Returns true when there is more tokens to parse.
[272] Fix | Delete
*/
[273] Fix | Delete
function proceed() {
[274] Fix | Delete
const stackDepth = stack.length;
[275] Fix | Delete
const next = nextToken();
[276] Fix | Delete
const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
[277] Fix | Delete
[278] Fix | Delete
// We may have some HTML soup before the next block.
[279] Fix | Delete
const leadingHtmlStart = startOffset > offset ? offset : null;
[280] Fix | Delete
switch (tokenType) {
[281] Fix | Delete
case 'no-more-tokens':
[282] Fix | Delete
// If not in a block then flush output.
[283] Fix | Delete
if (0 === stackDepth) {
[284] Fix | Delete
addFreeform();
[285] Fix | Delete
return false;
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
// Otherwise we have a problem
[289] Fix | Delete
// This is an error
[290] Fix | Delete
// we have options
[291] Fix | Delete
// - treat it all as freeform text
[292] Fix | Delete
// - assume an implicit closer (easiest when not nesting)
[293] Fix | Delete
[294] Fix | Delete
// For the easy case we'll assume an implicit closer.
[295] Fix | Delete
if (1 === stackDepth) {
[296] Fix | Delete
addBlockFromStack();
[297] Fix | Delete
return false;
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
// For the nested case where it's more difficult we'll
[301] Fix | Delete
// have to assume that multiple closers are missing
[302] Fix | Delete
// and so we'll collapse the whole stack piecewise.
[303] Fix | Delete
while (0 < stack.length) {
[304] Fix | Delete
addBlockFromStack();
[305] Fix | Delete
}
[306] Fix | Delete
return false;
[307] Fix | Delete
case 'void-block':
[308] Fix | Delete
// easy case is if we stumbled upon a void block
[309] Fix | Delete
// in the top-level of the document.
[310] Fix | Delete
if (0 === stackDepth) {
[311] Fix | Delete
if (null !== leadingHtmlStart) {
[312] Fix | Delete
output.push(Freeform(document.substr(leadingHtmlStart, startOffset - leadingHtmlStart)));
[313] Fix | Delete
}
[314] Fix | Delete
output.push(Block(blockName, attrs, [], '', []));
[315] Fix | Delete
offset = startOffset + tokenLength;
[316] Fix | Delete
return true;
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
// Otherwise we found an inner block.
[320] Fix | Delete
addInnerBlock(Block(blockName, attrs, [], '', []), startOffset, tokenLength);
[321] Fix | Delete
offset = startOffset + tokenLength;
[322] Fix | Delete
return true;
[323] Fix | Delete
case 'block-opener':
[324] Fix | Delete
// Track all newly-opened blocks on the stack.
[325] Fix | Delete
stack.push(Frame(Block(blockName, attrs, [], '', []), startOffset, tokenLength, startOffset + tokenLength, leadingHtmlStart));
[326] Fix | Delete
offset = startOffset + tokenLength;
[327] Fix | Delete
return true;
[328] Fix | Delete
case 'block-closer':
[329] Fix | Delete
// If we're missing an opener we're in trouble
[330] Fix | Delete
// This is an error.
[331] Fix | Delete
if (0 === stackDepth) {
[332] Fix | Delete
// We have options
[333] Fix | Delete
// - assume an implicit opener
[334] Fix | Delete
// - assume _this_ is the opener
[335] Fix | Delete
// - give up and close out the document.
[336] Fix | Delete
addFreeform();
[337] Fix | Delete
return false;
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
// If we're not nesting then this is easy - close the block.
[341] Fix | Delete
if (1 === stackDepth) {
[342] Fix | Delete
addBlockFromStack(startOffset);
[343] Fix | Delete
offset = startOffset + tokenLength;
[344] Fix | Delete
return true;
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
// Otherwise we're nested and we have to close out the current
[348] Fix | Delete
// block and add it as a innerBlock to the parent.
[349] Fix | Delete
const stackTop = /** @type {ParsedFrame} */stack.pop();
[350] Fix | Delete
const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
[351] Fix | Delete
stackTop.block.innerHTML += html;
[352] Fix | Delete
stackTop.block.innerContent.push(html);
[353] Fix | Delete
stackTop.prevOffset = startOffset + tokenLength;
[354] Fix | Delete
addInnerBlock(stackTop.block, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
[355] Fix | Delete
offset = startOffset + tokenLength;
[356] Fix | Delete
return true;
[357] Fix | Delete
default:
[358] Fix | Delete
// This is an error.
[359] Fix | Delete
addFreeform();
[360] Fix | Delete
return false;
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
/**
[365] Fix | Delete
* Parse JSON if valid, otherwise return null
[366] Fix | Delete
*
[367] Fix | Delete
* Note that JSON coming from the block comment
[368] Fix | Delete
* delimiters is constrained to be an object
[369] Fix | Delete
* and cannot be things like `true` or `null`
[370] Fix | Delete
*
[371] Fix | Delete
* @param {string} input JSON input string to parse
[372] Fix | Delete
* @return {Object|null} parsed JSON if valid
[373] Fix | Delete
*/
[374] Fix | Delete
function parseJSON(input) {
[375] Fix | Delete
try {
[376] Fix | Delete
return JSON.parse(input);
[377] Fix | Delete
} catch (e) {
[378] Fix | Delete
return null;
[379] Fix | Delete
}
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
/**
[383] Fix | Delete
* Finds the next token in the document.
[384] Fix | Delete
*
[385] Fix | Delete
* @return {Token} The next matched token.
[386] Fix | Delete
*/
[387] Fix | Delete
function nextToken() {
[388] Fix | Delete
// Aye the magic
[389] Fix | Delete
// we're using a single RegExp to tokenize the block comment delimiters
[390] Fix | Delete
// we're also using a trick here because the only difference between a
[391] Fix | Delete
// block opener and a block closer is the leading `/` before `wp:` (and
[392] Fix | Delete
// a closer has no attributes). we can trap them both and process the
[393] Fix | Delete
// match back in JavaScript to see which one it was.
[394] Fix | Delete
const matches = tokenizer.exec(document);
[395] Fix | Delete
[396] Fix | Delete
// We have no more tokens.
[397] Fix | Delete
if (null === matches) {
[398] Fix | Delete
return ['no-more-tokens', '', null, 0, 0];
[399] Fix | Delete
}
[400] Fix | Delete
const startedAt = matches.index;
[401] Fix | Delete
const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch /* Internal/unused. */,, voidMatch] = matches;
[402] Fix | Delete
const length = match.length;
[403] Fix | Delete
const isCloser = !!closerMatch;
[404] Fix | Delete
const isVoid = !!voidMatch;
[405] Fix | Delete
const namespace = namespaceMatch || 'core/';
[406] Fix | Delete
const name = namespace + nameMatch;
[407] Fix | Delete
const hasAttrs = !!attrsMatch;
[408] Fix | Delete
const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
[409] Fix | Delete
[410] Fix | Delete
// This state isn't allowed
[411] Fix | Delete
// This is an error.
[412] Fix | Delete
if (isCloser && (isVoid || hasAttrs)) {
[413] Fix | Delete
// We can ignore them since they don't hurt anything
[414] Fix | Delete
// we may warn against this at some point or reject it.
[415] Fix | Delete
}
[416] Fix | Delete
if (isVoid) {
[417] Fix | Delete
return ['void-block', name, attrs, startedAt, length];
[418] Fix | Delete
}
[419] Fix | Delete
if (isCloser) {
[420] Fix | Delete
return ['block-closer', name, null, startedAt, length];
[421] Fix | Delete
}
[422] Fix | Delete
return ['block-opener', name, attrs, startedAt, length];
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
/**
[426] Fix | Delete
* Adds a freeform block to the output.
[427] Fix | Delete
*
[428] Fix | Delete
* @param {number} [rawLength]
[429] Fix | Delete
*/
[430] Fix | Delete
function addFreeform(rawLength) {
[431] Fix | Delete
const length = rawLength ? rawLength : document.length - offset;
[432] Fix | Delete
if (0 === length) {
[433] Fix | Delete
return;
[434] Fix | Delete
}
[435] Fix | Delete
output.push(Freeform(document.substr(offset, length)));
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
/**
[439] Fix | Delete
* Adds inner block to the parent block.
[440] Fix | Delete
*
[441] Fix | Delete
* @param {ParsedBlock} block
[442] Fix | Delete
* @param {number} tokenStart
[443] Fix | Delete
* @param {number} tokenLength
[444] Fix | Delete
* @param {number} [lastOffset]
[445] Fix | Delete
*/
[446] Fix | Delete
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
[447] Fix | Delete
const parent = stack[stack.length - 1];
[448] Fix | Delete
parent.block.innerBlocks.push(block);
[449] Fix | Delete
const html = document.substr(parent.prevOffset, tokenStart - parent.prevOffset);
[450] Fix | Delete
if (html) {
[451] Fix | Delete
parent.block.innerHTML += html;
[452] Fix | Delete
parent.block.innerContent.push(html);
[453] Fix | Delete
}
[454] Fix | Delete
parent.block.innerContent.push(null);
[455] Fix | Delete
parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
/**
[459] Fix | Delete
* Adds block from the stack to the output.
[460] Fix | Delete
*
[461] Fix | Delete
* @param {number} [endOffset]
[462] Fix | Delete
*/
[463] Fix | Delete
function addBlockFromStack(endOffset) {
[464] Fix | Delete
const {
[465] Fix | Delete
block,
[466] Fix | Delete
leadingHtmlStart,
[467] Fix | Delete
prevOffset,
[468] Fix | Delete
tokenStart
[469] Fix | Delete
} = /** @type {ParsedFrame} */stack.pop();
[470] Fix | Delete
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
[471] Fix | Delete
if (html) {
[472] Fix | Delete
block.innerHTML += html;
[473] Fix | Delete
block.innerContent.push(html);
[474] Fix | Delete
}
[475] Fix | Delete
if (null !== leadingHtmlStart) {
[476] Fix | Delete
output.push(Freeform(document.substr(leadingHtmlStart, tokenStart - leadingHtmlStart)));
[477] Fix | Delete
}
[478] Fix | Delete
output.push(block);
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
(window.wp = window.wp || {}).blockSerializationDefaultParser = __webpack_exports__;
[482] Fix | Delete
/******/ })()
[483] Fix | Delete
;
[484] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function