@wordpress/dom 4.45.1-next.v.202605131032.0 → 4.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/phrasing-content.cjs +8 -5
- package/build/phrasing-content.cjs.map +2 -2
- package/build-module/phrasing-content.mjs +8 -5
- package/build-module/phrasing-content.mjs.map +2 -2
- package/build-types/phrasing-content.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/phrasing-content.js +16 -11
package/CHANGELOG.md
CHANGED
|
@@ -59,11 +59,6 @@ var textContentSchema = {
|
|
|
59
59
|
wbr: {},
|
|
60
60
|
"#text": {}
|
|
61
61
|
};
|
|
62
|
-
var excludedElements = ["#text", "br"];
|
|
63
|
-
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
64
|
-
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
65
|
-
textContentSchema[tag].children = restSchema;
|
|
66
|
-
});
|
|
67
62
|
var embeddedContentSchema = {
|
|
68
63
|
audio: {
|
|
69
64
|
attributes: [
|
|
@@ -119,6 +114,14 @@ var embeddedContentSchema = {
|
|
|
119
114
|
children: "*"
|
|
120
115
|
}
|
|
121
116
|
};
|
|
117
|
+
var excludedElements = ["#text", "br", "wbr"];
|
|
118
|
+
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
119
|
+
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
120
|
+
textContentSchema[tag].children = {
|
|
121
|
+
...restSchema,
|
|
122
|
+
img: embeddedContentSchema.img
|
|
123
|
+
};
|
|
124
|
+
});
|
|
122
125
|
var phrasingContentSchema = {
|
|
123
126
|
...textContentSchema,
|
|
124
127
|
...embeddedContentSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/phrasing-content.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema|'*'} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,IAAM,oBAAoB;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,GAAG,EAAE,YAAY,CAAE,QAAQ,UAAU,OAAO,IAAK,EAAE;AAAA,EACnD,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,IAAI,CAAC;AAAA,EACL,OAAO,CAAC;AAAA;AAAA;AAAA,EAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;AAAA,EAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;AAAA,EACnC,KAAK,CAAC;AAAA,EACN,MAAM,CAAC;AAAA,EACP,KAAK,CAAC;AAAA,EACN,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,IAAI,CAAC;AAAA,EACL,IAAI,CAAC;AAAA,EACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,CAAC;AAAA,EACN,SAAS,CAAC;AACX;
|
|
4
|
+
"sourcesContent": ["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema|'*'} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'playsinline',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tmath: {\n\t\tattributes: [ 'display', 'xmlns' ],\n\t\tchildren: '*',\n\t},\n};\n\nconst excludedElements = [ '#text', 'br', 'wbr' ];\n\n// Wire up children for each text-level wrapper.\n// - Recursion is needed (e.g. strong > em > strong; not strong > strong).\n// - <img> is allowed too: text-level wrappers accept phrasing content, and\n// <a>'s transparent model permits non-interactive embedded content.\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = {\n\t\t\t...restSchema,\n\t\t\timg: embeddedContentSchema.img,\n\t\t};\n\t} );\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\t/**\n\t * @type {Partial<ContentSchema>}\n\t */\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t} = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {Node} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,IAAM,oBAAoB;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,GAAG,EAAE,YAAY,CAAE,QAAQ,UAAU,OAAO,IAAK,EAAE;AAAA,EACnD,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,IAAI,CAAC;AAAA,EACL,OAAO,CAAC;AAAA;AAAA;AAAA,EAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;AAAA,EAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;AAAA,EACnC,KAAK,CAAC;AAAA,EACN,MAAM,CAAC;AAAA,EACP,KAAK,CAAC;AAAA,EACN,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,IAAI,CAAC;AAAA,EACL,IAAI,CAAC;AAAA,EACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,CAAC;AAAA,EACN,SAAS,CAAC;AACX;AASA,IAAM,wBAAwB;AAAA,EAC7B,O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,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAAA,IACH,GAAG;AAAA;AAAA;AAAA,IAGH,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,IACpD,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,EACrD;AAEA,SAAO;AACR;AAWO,SAAS,kBAAmB,MAAO;AACzC,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,yBAAyB,EAAE,eAAgB,GAAI,KAAK,QAAQ;AACpE;AAMO,SAAS,cAAe,MAAO;AACrC,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,kBAAkB,eAAgB,GAAI,KAAK,QAAQ;AAC3D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,11 +33,6 @@ var textContentSchema = {
|
|
|
33
33
|
wbr: {},
|
|
34
34
|
"#text": {}
|
|
35
35
|
};
|
|
36
|
-
var excludedElements = ["#text", "br"];
|
|
37
|
-
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
38
|
-
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
39
|
-
textContentSchema[tag].children = restSchema;
|
|
40
|
-
});
|
|
41
36
|
var embeddedContentSchema = {
|
|
42
37
|
audio: {
|
|
43
38
|
attributes: [
|
|
@@ -93,6 +88,14 @@ var embeddedContentSchema = {
|
|
|
93
88
|
children: "*"
|
|
94
89
|
}
|
|
95
90
|
};
|
|
91
|
+
var excludedElements = ["#text", "br", "wbr"];
|
|
92
|
+
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
93
|
+
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
94
|
+
textContentSchema[tag].children = {
|
|
95
|
+
...restSchema,
|
|
96
|
+
img: embeddedContentSchema.img
|
|
97
|
+
};
|
|
98
|
+
});
|
|
96
99
|
var phrasingContentSchema = {
|
|
97
100
|
...textContentSchema,
|
|
98
101
|
...embeddedContentSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/phrasing-content.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema|'*'} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n
|
|
5
|
-
"mappings": ";AAuBA,IAAM,oBAAoB;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,GAAG,EAAE,YAAY,CAAE,QAAQ,UAAU,OAAO,IAAK,EAAE;AAAA,EACnD,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,IAAI,CAAC;AAAA,EACL,OAAO,CAAC;AAAA;AAAA;AAAA,EAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;AAAA,EAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;AAAA,EACnC,KAAK,CAAC;AAAA,EACN,MAAM,CAAC;AAAA,EACP,KAAK,CAAC;AAAA,EACN,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,IAAI,CAAC;AAAA,EACL,IAAI,CAAC;AAAA,EACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,CAAC;AAAA,EACN,SAAS,CAAC;AACX;
|
|
4
|
+
"sourcesContent": ["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema|'*'} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'playsinline',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tmath: {\n\t\tattributes: [ 'display', 'xmlns' ],\n\t\tchildren: '*',\n\t},\n};\n\nconst excludedElements = [ '#text', 'br', 'wbr' ];\n\n// Wire up children for each text-level wrapper.\n// - Recursion is needed (e.g. strong > em > strong; not strong > strong).\n// - <img> is allowed too: text-level wrappers accept phrasing content, and\n// <a>'s transparent model permits non-interactive embedded content.\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = {\n\t\t\t...restSchema,\n\t\t\timg: embeddedContentSchema.img,\n\t\t};\n\t} );\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\t/**\n\t * @type {Partial<ContentSchema>}\n\t */\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t} = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {Node} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],
|
|
5
|
+
"mappings": ";AAuBA,IAAM,oBAAoB;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,GAAG,EAAE,YAAY,CAAE,QAAQ,UAAU,OAAO,IAAK,EAAE;AAAA,EACnD,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,IAAI,CAAC;AAAA,EACL,OAAO,CAAC;AAAA;AAAA;AAAA,EAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;AAAA,EAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;AAAA,EACnC,KAAK,CAAC;AAAA,EACN,MAAM,CAAC;AAAA,EACP,KAAK,CAAC;AAAA,EACN,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,IAAI,CAAC;AAAA,EACL,IAAI,CAAC;AAAA,EACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,EAAE,YAAY,C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GAAG;AACJ;AAYO,SAAS,yBAA0B,SAAU;AACnD,MAAK,YAAY,SAAU;AAC1B,WAAO;AAAA,EACR;AAKA,QAAM;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAAA,IACH,GAAG;AAAA;AAAA;AAAA,IAGH,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,IACpD,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,EACrD;AAEA,SAAO;AACR;AAWO,SAAS,kBAAmB,MAAO;AACzC,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,yBAAyB,EAAE,eAAgB,GAAI,KAAK,QAAQ;AACpE;AAMO,SAAS,cAAe,MAAO;AACrC,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,kBAAkB,eAAgB,GAAI,KAAK,QAAQ;AAC3D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAGA,YAAoD,aAAa,GAAvD,MAAM,CAAC,MAAM,EAAC,yBAAyB,CAAC,CAAe;AAIjE,YAAS,yBAAyB,GAClC;IAA+B,UAAU,AAAzC,CACA,EADW,MAAM,EAAE,CACnB;IAA+B,QAAQ,AAAvC,CACF,EADa,aAAa,GAAC,GAAG,CAC9B;CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAGA,YAAoD,aAAa,GAAvD,MAAM,CAAC,MAAM,EAAC,yBAAyB,CAAC,CAAe;AAIjE,YAAS,yBAAyB,GAClC;IAA+B,UAAU,AAAzC,CACA,EADW,MAAM,EAAE,CACnB;IAA+B,QAAQ,AAAvC,CACF,EADa,aAAa,GAAC,GAAG,CAC9B;CAAA,CAAA;AAqID;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAE,OAAO,AAL9C,CAGA,EAHQ,MAKsC,GAFrC,OAAO,CAAC,aAAa,CAAC,CA4BjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAJ5B,IAI4B,GAF3B,OAAO,CAKlB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAE,IAAI,EAHxB,IAGwB,GAFvB,OAAO,CAKlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dom",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.47.0",
|
|
4
4
|
"description": "DOM utilities module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"types": "build-types",
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wordpress/deprecated": "^4.
|
|
48
|
+
"@wordpress/deprecated": "^4.47.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "d653c5fd6161571a0c2ebde28553d6e25624eacc"
|
|
54
54
|
}
|
package/src/phrasing-content.js
CHANGED
|
@@ -56,17 +56,6 @@ const textContentSchema = {
|
|
|
56
56
|
'#text': {},
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
// Recursion is needed.
|
|
60
|
-
// Possible: strong > em > strong.
|
|
61
|
-
// Impossible: strong > strong.
|
|
62
|
-
const excludedElements = [ '#text', 'br' ];
|
|
63
|
-
Object.keys( textContentSchema )
|
|
64
|
-
.filter( ( element ) => ! excludedElements.includes( element ) )
|
|
65
|
-
.forEach( ( tag ) => {
|
|
66
|
-
const { [ tag ]: removedTag, ...restSchema } = textContentSchema;
|
|
67
|
-
textContentSchema[ tag ].children = restSchema;
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
59
|
/**
|
|
71
60
|
* Embedded content elements.
|
|
72
61
|
*
|
|
@@ -130,6 +119,22 @@ const embeddedContentSchema = {
|
|
|
130
119
|
},
|
|
131
120
|
};
|
|
132
121
|
|
|
122
|
+
const excludedElements = [ '#text', 'br', 'wbr' ];
|
|
123
|
+
|
|
124
|
+
// Wire up children for each text-level wrapper.
|
|
125
|
+
// - Recursion is needed (e.g. strong > em > strong; not strong > strong).
|
|
126
|
+
// - <img> is allowed too: text-level wrappers accept phrasing content, and
|
|
127
|
+
// <a>'s transparent model permits non-interactive embedded content.
|
|
128
|
+
Object.keys( textContentSchema )
|
|
129
|
+
.filter( ( element ) => ! excludedElements.includes( element ) )
|
|
130
|
+
.forEach( ( tag ) => {
|
|
131
|
+
const { [ tag ]: removedTag, ...restSchema } = textContentSchema;
|
|
132
|
+
textContentSchema[ tag ].children = {
|
|
133
|
+
...restSchema,
|
|
134
|
+
img: embeddedContentSchema.img,
|
|
135
|
+
};
|
|
136
|
+
} );
|
|
137
|
+
|
|
133
138
|
/**
|
|
134
139
|
* Phrasing content elements.
|
|
135
140
|
*
|