Diff: STRATO-apps/wordpress_03/app/wp-includes/js/dist/block-serialization-default-parser.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + /******/ (() => { // webpackBootstrap
2 + /******/ "use strict";
3 + /******/ // The require scope
4 + /******/ var __webpack_require__ = {};
5 + /******/
6 + /************************************************************************/
7 + /******/ /* webpack/runtime/define property getters */
8 + /******/ (() => {
9 + /******/ // define getter functions for harmony exports
10 + /******/ __webpack_require__.d = (exports, definition) => {
11 + /******/ for(var key in definition) {
12 + /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 + /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 + /******/ }
15 + /******/ }
16 + /******/ };
17 + /******/ })();
18 + /******/
19 + /******/ /* webpack/runtime/hasOwnProperty shorthand */
20 + /******/ (() => {
21 + /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22 + /******/ })();
23 + /******/
24 + /******/ /* webpack/runtime/make namespace object */
25 + /******/ (() => {
26 + /******/ // define __esModule on exports
27 + /******/ __webpack_require__.r = (exports) => {
28 + /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 + /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 + /******/ }
31 + /******/ Object.defineProperty(exports, '__esModule', { value: true });
32 + /******/ };
33 + /******/ })();
34 + /******/
35 + /************************************************************************/
36 + var __webpack_exports__ = {};
37 + __webpack_require__.r(__webpack_exports__);
38 + /* harmony export */ __webpack_require__.d(__webpack_exports__, {
39 + /* harmony export */ parse: () => (/* binding */ parse)
40 + /* harmony export */ });
41 + let document;
42 + let offset;
43 + let output;
44 + let stack;
45 + const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
46 + function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
47 + return {
48 + blockName,
49 + attrs,
50 + innerBlocks,
51 + innerHTML,
52 + innerContent
53 + };
54 + }
55 + function Freeform(innerHTML) {
56 + return Block(null, {}, [], innerHTML, [innerHTML]);
57 + }
58 + function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
59 + return {
60 + block,
61 + tokenStart,
62 + tokenLength,
63 + prevOffset: prevOffset || tokenStart + tokenLength,
64 + leadingHtmlStart
65 + };
66 + }
67 + const parse = (doc) => {
68 + document = doc;
69 + offset = 0;
70 + output = [];
71 + stack = [];
72 + tokenizer.lastIndex = 0;
73 + do {
74 + } while (proceed());
75 + return output;
76 + };
77 + function proceed() {
78 + const stackDepth = stack.length;
79 + const next = nextToken();
80 + const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
81 + const leadingHtmlStart = startOffset > offset ? offset : null;
82 + switch (tokenType) {
83 + case "no-more-tokens":
84 + if (0 === stackDepth) {
85 + addFreeform();
86 + return false;
87 + }
88 + if (1 === stackDepth) {
89 + addBlockFromStack();
90 + return false;
91 + }
92 + while (0 < stack.length) {
93 + addBlockFromStack();
94 + }
95 + return false;
96 + case "void-block":
97 + if (0 === stackDepth) {
98 + if (null !== leadingHtmlStart) {
99 + output.push(
100 + Freeform(
101 + document.substr(
102 + leadingHtmlStart,
103 + startOffset - leadingHtmlStart
104 + )
105 + )
106 + );
107 + }
108 + output.push(Block(blockName, attrs, [], "", []));
109 + offset = startOffset + tokenLength;
110 + return true;
111 + }
112 + addInnerBlock(
113 + Block(blockName, attrs, [], "", []),
114 + startOffset,
115 + tokenLength
116 + );
117 + offset = startOffset + tokenLength;
118 + return true;
119 + case "block-opener":
120 + stack.push(
121 + Frame(
122 + Block(blockName, attrs, [], "", []),
123 + startOffset,
124 + tokenLength,
125 + startOffset + tokenLength,
126 + leadingHtmlStart
127 + )
128 + );
129 + offset = startOffset + tokenLength;
130 + return true;
131 + case "block-closer":
132 + if (0 === stackDepth) {
133 + addFreeform();
134 + return false;
135 + }
136 + if (1 === stackDepth) {
137 + addBlockFromStack(startOffset);
138 + offset = startOffset + tokenLength;
139 + return true;
140 + }
141 + const stackTop = stack.pop();
142 + const html = document.substr(
143 + stackTop.prevOffset,
144 + startOffset - stackTop.prevOffset
145 + );
146 + stackTop.block.innerHTML += html;
147 + stackTop.block.innerContent.push(html);
148 + stackTop.prevOffset = startOffset + tokenLength;
149 + addInnerBlock(
150 + stackTop.block,
151 + stackTop.tokenStart,
152 + stackTop.tokenLength,
153 + startOffset + tokenLength
154 + );
155 + offset = startOffset + tokenLength;
156 + return true;
157 + default:
158 + addFreeform();
159 + return false;
160 + }
161 + }
162 + function parseJSON(input) {
163 + try {
164 + return JSON.parse(input);
165 + } catch (e) {
166 + return null;
167 + }
168 + }
169 + function nextToken() {
170 + const matches = tokenizer.exec(document);
171 + if (null === matches) {
172 + return ["no-more-tokens", "", null, 0, 0];
173 + }
174 + const startedAt = matches.index;
175 + const [
176 + match,
177 + closerMatch,
178 + namespaceMatch,
179 + nameMatch,
180 + attrsMatch,
181 + ,
182 + voidMatch
183 + ] = matches;
184 + const length = match.length;
185 + const isCloser = !!closerMatch;
186 + const isVoid = !!voidMatch;
187 + const namespace = namespaceMatch || "core/";
188 + const name = namespace + nameMatch;
189 + const hasAttrs = !!attrsMatch;
190 + const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
191 + if (isCloser && (isVoid || hasAttrs)) {
192 + }
193 + if (isVoid) {
194 + return ["void-block", name, attrs, startedAt, length];
195 + }
196 + if (isCloser) {
197 + return ["block-closer", name, null, startedAt, length];
198 + }
199 + return ["block-opener", name, attrs, startedAt, length];
200 + }
201 + function addFreeform(rawLength) {
202 + const length = rawLength ? rawLength : document.length - offset;
203 + if (0 === length) {
204 + return;
205 + }
206 + output.push(Freeform(document.substr(offset, length)));
207 + }
208 + function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
209 + const parent = stack[stack.length - 1];
210 + parent.block.innerBlocks.push(block);
211 + const html = document.substr(
212 + parent.prevOffset,
213 + tokenStart - parent.prevOffset
214 + );
215 + if (html) {
216 + parent.block.innerHTML += html;
217 + parent.block.innerContent.push(html);
218 + }
219 + parent.block.innerContent.push(null);
220 + parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
221 + }
222 + function addBlockFromStack(endOffset) {
223 + const { block, leadingHtmlStart, prevOffset, tokenStart } = stack.pop();
224 + const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
225 + if (html) {
226 + block.innerHTML += html;
227 + block.innerContent.push(html);
228 + }
229 + if (null !== leadingHtmlStart) {
230 + output.push(
231 + Freeform(
232 + document.substr(
233 + leadingHtmlStart,
234 + tokenStart - leadingHtmlStart
235 + )
236 + )
237 + );
238 + }
239 + output.push(block);
240 + }
241 +
242 +
243 + (window.wp = window.wp || {}).blockSerializationDefaultParser = __webpack_exports__;
244 + /******/ })()
245 + ;