2013-06-26 21:18:39 +00:00
/ * !
2014-03-03 14:10:06 +00:00
* VisualEditor DataModel MediaWiki - specific example data sets .
2013-06-26 21:18:39 +00:00
*
2020-01-08 17:13:04 +00:00
* @ copyright 2011 - 2020 VisualEditor Team and others ; see AUTHORS . txt
2013-06-26 21:18:39 +00:00
* @ license The MIT License ( MIT ) ; see LICENSE . txt
* /
/ * *
* @ class
* @ singleton
* @ ignore
* /
ve . dm . mwExample = { } ;
2023-01-21 17:00:26 +00:00
ve . dm . mwExample . baseUri = 'http://example.com/wiki/' ;
ve . dm . mwExample . createExampleDocument = ( name , store , base ) =>
ve . dm . example . createExampleDocumentFromObject ( name , store , ve . dm . mwExample , base || ve . dm . mwExample . baseUri ) ;
ve . dm . mwExample . createExampleDocumentFromData = ( data , store , base ) =>
ve . dm . example . createExampleDocumentFromData ( data , store , base || ve . dm . mwExample . baseUri ) ;
2013-07-03 01:30:10 +00:00
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion = {
2023-05-30 15:00:52 +00:00
blockOpen : ve . dm . example . singleLine `
< div about = "#mwt1" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
< / d i v >
` ,
blockOpenModified : ve . dm . example . singleLine `
< div about = "#mwt1" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
< / d i v >
` ,
blockOpenFromData : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
< / s p a n >
` ,
blockOpenClipboard : ve . dm . example . singleLine `
< div about = "#mwt1" typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
2023-05-30 15:00:52 +00:00
& nbsp ;
< / d i v >
` ,
blockOpenFromDataModified : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
< / s p a n >
` ,
blockOpenModifiedClipboard : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}'
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
2023-05-30 15:00:52 +00:00
& nbsp ;
< / s p a n >
` ,
2014-08-22 20:50:48 +00:00
blockContent : '<p about="#mwt1" data-parsoid="{}">Hello, world!</p>' ,
2015-02-23 02:40:58 +00:00
blockContentClipboard : '<p about="#mwt1" data-parsoid="{}" data-ve-ignore="true">Hello, world!</p>' ,
2023-05-30 15:00:52 +00:00
inlineOpen : ve . dm . example . singleLine `
< span about = "#mwt1" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
` ,
inlineOpenModified : ve . dm . example . singleLine `
< span about = "#mwt1" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
` ,
inlineOpenFromData : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
` ,
inlineOpenClipboard : ve . dm . example . singleLine `
< span about = "#mwt1" typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
2023-05-30 15:00:52 +00:00
` ,
inlineOpenFromDataModified : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
` ,
inlineOpenModifiedClipboard : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
2023-05-30 15:00:52 +00:00
& nbsp ;
2023-06-01 13:21:55 +00:00
< / s p a n >
2023-05-30 15:00:52 +00:00
` ,
2014-08-22 20:50:48 +00:00
inlineContent : '$1,234.00' ,
inlineClose : '</span>' ,
2023-05-30 15:00:52 +00:00
mixed : ve . dm . example . singleLine `
< link about = "#mwt1" rel = "mw:PageProp/Category" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}' >
2023-05-30 15:00:52 +00:00
< span about = "#mwt1" > Foo < / s p a n >
` ,
mixedFromData : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}' >
< / s p a n >
2023-05-30 15:00:52 +00:00
` ,
mixedClipboard : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
& nbsp ;
< / s p a n >
2023-05-30 15:00:52 +00:00
< span about = "#mwt1" data - ve - ignore = "true" > Foo < / s p a n >
` ,
pairOne : ve . dm . example . singleLine `
< p about = "#mwt1" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data - parsoid = "1" >
foo
< / p >
2023-05-30 15:00:52 +00:00
` ,
pairTwo : ve . dm . example . singleLine `
< p about = "#mwt2" typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data - parsoid = "2" >
foo
< / p >
2023-05-30 15:00:52 +00:00
` ,
pairFromData : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
2023-06-01 13:21:55 +00:00
data - mw = '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' > < / s p a n >
2023-05-30 15:00:52 +00:00
` ,
pairClipboard : ve . dm . example . singleLine `
< p about = "#mwt1" typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
data - parsoid = "1"
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
foo
< / p >
2023-05-30 15:00:52 +00:00
` ,
meta : ve . dm . example . singleLine `
< link rel = "mw:PageProp/Category" href = "./Category:Page" about = "#mwt1" typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}' >
< span about = "#mwt1" data - parsoid = "{}" > \ n < / s p a n >
< link rel = "mw:PageProp/Category" href = "./Category:Book" about = "#mwt1" >
` ,
metaFromData : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
data - mw = ' { "parts" : [ { "template" : { "target" : { "wt" : "Template:Echo" , "href" : "./Template:Echo" } , "params" : { "1" : { "wt" : "
2023-06-01 13:21:55 +00:00
[ [ Category : Page ] ] \ \ n [ [ Category : Book ] ] "}}," i " : 0 } } ] } ' >
< / s p a n >
2023-05-30 15:00:52 +00:00
` ,
metaClipboard : ve . dm . example . singleLine `
< span typeof = "mw:Transclusion"
data - mw = ' { "parts" : [ { "template" : { "target" : { "wt" : "Template:Echo" , "href" : "./Template:Echo" } , "params" : { "1" : { "wt" : "
[ [ Category : Page ] ] \ \ n [ [ Category : Book ] ] "}}," i " : 0 } } ] } '
2023-06-01 13:21:55 +00:00
data - ve - no - generated - contents = "true" >
& nbsp ;
< / s p a n >
2023-05-30 15:00:52 +00:00
`
2013-06-26 21:18:39 +00:00
} ;
ve . dm . mwExample . MWTransclusion . blockData = {
2014-08-22 20:50:48 +00:00
type : 'mwTransclusionBlock' ,
attributes : {
mw : {
parts : [
2014-08-20 20:36:12 +00:00
{
2014-08-22 20:50:48 +00:00
template : {
target : {
wt : 'Test' ,
href : './Template:Test'
2014-08-20 20:36:12 +00:00
} ,
2014-08-22 20:50:48 +00:00
params : {
1 : {
wt : 'Hello, world!'
2014-08-20 20:36:12 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
i : 0
2014-08-20 20:36:12 +00:00
}
}
]
2013-06-26 21:18:39 +00:00
} ,
2015-10-02 10:39:40 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ;
ve . dm . mwExample . MWTransclusion . inlineData = {
2014-08-22 20:50:48 +00:00
type : 'mwTransclusionInline' ,
attributes : {
mw : {
parts : [
2014-08-20 20:36:12 +00:00
{
2014-08-22 20:50:48 +00:00
template : {
target : {
wt : 'Inline' ,
href : './Template:Inline'
2014-08-20 20:36:12 +00:00
} ,
2014-08-22 20:50:48 +00:00
params : {
1 : {
wt : '1,234'
2014-08-20 20:36:12 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
i : 0
2014-08-20 20:36:12 +00:00
}
}
]
2013-06-26 21:18:39 +00:00
} ,
2015-10-02 10:39:40 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ;
ve . dm . mwExample . MWTransclusion . mixedDataOpen = {
2014-08-22 20:50:48 +00:00
type : 'mwTransclusionInline' ,
attributes : {
mw : {
parts : [
2014-08-20 20:36:12 +00:00
{
2014-08-22 20:50:48 +00:00
template : {
target : {
wt : 'Inline' ,
href : './Template:Inline'
2014-08-20 20:36:12 +00:00
} ,
2014-08-22 20:50:48 +00:00
params : {
1 : {
wt : '5,678'
2014-08-20 20:36:12 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
i : 0
2014-08-20 20:36:12 +00:00
}
}
]
2013-06-26 21:18:39 +00:00
} ,
2015-10-02 10:39:40 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ;
2014-08-22 20:50:48 +00:00
ve . dm . mwExample . MWTransclusion . mixedDataClose = { type : '/mwTransclusionInline' } ;
2013-06-26 21:18:39 +00:00
2013-10-15 19:59:14 +00:00
ve . dm . mwExample . MWTransclusion . blockParamsHash = OO . getHash ( [ ve . dm . MWTransclusionNode . static . getHashObject ( ve . dm . mwExample . MWTransclusion . blockData ) , undefined ] ) ;
2016-08-17 19:50:55 +00:00
ve . dm . mwExample . MWTransclusion . blockStoreItems = { } ;
2018-03-06 12:44:37 +00:00
ve . dm . mwExample . MWTransclusion . blockStoreItems [ ve . dm . HashValueStore . prototype . hashOfValue ( null , ve . dm . mwExample . MWTransclusion . blockParamsHash ) ] =
2022-03-08 23:48:22 +00:00
$ . parseHTML ( ve . dm . mwExample . MWTransclusion . blockOpen + ve . dm . mwExample . MWTransclusion . blockContent ) ;
2013-06-26 21:18:39 +00:00
2013-10-15 19:59:14 +00:00
ve . dm . mwExample . MWTransclusion . inlineParamsHash = OO . getHash ( [ ve . dm . MWTransclusionNode . static . getHashObject ( ve . dm . mwExample . MWTransclusion . inlineData ) , undefined ] ) ;
2016-08-17 19:50:55 +00:00
ve . dm . mwExample . MWTransclusion . inlineStoreItems = { } ;
2018-03-06 12:44:37 +00:00
ve . dm . mwExample . MWTransclusion . inlineStoreItems [ ve . dm . HashValueStore . prototype . hashOfValue ( null , ve . dm . mwExample . MWTransclusion . inlineParamsHash ) ] =
2022-03-08 23:48:22 +00:00
$ . parseHTML ( ve . dm . mwExample . MWTransclusion . inlineOpen + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose ) ;
2013-06-26 21:18:39 +00:00
2013-10-15 19:59:14 +00:00
ve . dm . mwExample . MWTransclusion . mixedParamsHash = OO . getHash ( [ ve . dm . MWTransclusionNode . static . getHashObject ( ve . dm . mwExample . MWTransclusion . mixedDataOpen ) , undefined ] ) ;
2016-08-17 19:50:55 +00:00
ve . dm . mwExample . MWTransclusion . mixedStoreItems = { } ;
2018-03-06 12:44:37 +00:00
ve . dm . mwExample . MWTransclusion . mixedStoreItems [ ve . dm . HashValueStore . prototype . hashOfValue ( null , ve . dm . mwExample . MWTransclusion . mixedParamsHash ) ] =
2022-03-08 23:48:22 +00:00
$ . parseHTML ( ve . dm . mwExample . MWTransclusion . mixed ) ;
2013-06-26 21:18:39 +00:00
2014-01-06 13:56:55 +00:00
ve . dm . mwExample . MWInternalLink = {
2023-01-30 14:57:56 +00:00
absoluteHref : new URL ( './Foo/Bar' , ve . dm . mwExample . baseUri ) . toString ( )
2014-01-06 13:56:55 +00:00
} ;
ve . dm . mwExample . MWInternalLink . absoluteOpen = '<a rel="mw:WikiLink" href="' + ve . dm . mwExample . MWInternalLink . absoluteHref + '">' ;
ve . dm . mwExample . MWInternalLink . absoluteData = {
2014-08-22 20:50:48 +00:00
type : 'link/mwInternal' ,
attributes : {
title : 'Foo/Bar' ,
normalizedTitle : 'Foo/Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Foo/Bar'
2015-02-17 00:36:52 +00:00
}
2014-01-06 13:56:55 +00:00
} ;
2014-03-19 02:08:47 +00:00
ve . dm . mwExample . MWInternalSectionLink = {
2023-01-30 14:57:56 +00:00
absoluteHref : new URL ( './Foo#Bar' , ve . dm . mwExample . baseUri ) . toString ( )
2014-03-19 02:08:47 +00:00
} ;
ve . dm . mwExample . MWInternalSectionLink . absoluteOpen = '<a rel="mw:WikiLink" href="' + ve . dm . mwExample . MWInternalSectionLink . absoluteHref + '">' ;
ve . dm . mwExample . MWInternalSectionLink . absoluteData = {
2014-08-22 20:50:48 +00:00
type : 'link/mwInternal' ,
attributes : {
title : 'Foo#Bar' ,
normalizedTitle : 'Foo#Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Foo'
2015-02-17 00:36:52 +00:00
}
2014-03-19 02:08:47 +00:00
} ;
2019-09-24 16:25:03 +00:00
ve . dm . mwExample . MWMediaLinkExistsData = {
type : 'link/mwInternal' ,
attributes : {
lookupTitle : 'Media:Exists.png' ,
normalizedTitle : 'Media:Exists.png' ,
title : 'Media:Exists.png'
}
} ;
ve . dm . mwExample . MWMediaLinkMissingData = {
type : 'link/mwInternal' ,
attributes : {
lookupTitle : 'Media:Missing.png' ,
normalizedTitle : 'Media:Missing.png' ,
title : 'Media:Missing.png'
}
} ;
2013-10-05 10:27:39 +00:00
ve . dm . mwExample . MWBlockImage = {
2023-05-30 15:00:52 +00:00
html : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" class = "mw-halign-right foobar" >
< a href = "./Foo" class = "mw-file-description" >
< img src = "${ve.ce.minImgDataUri}" class = "mw-file-element" width = "1" height = "2" resource = "./FooBar" alt = "alt text" >
< / a >
< figcaption > abc < / f i g c a p t i o n >
< / f i g u r e >
` ,
2014-08-22 20:50:48 +00:00
data : [
2013-10-05 10:27:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwBlockImage' ,
attributes : {
type : 'thumb' ,
align : 'right' ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2017-04-27 18:08:35 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2016-01-07 01:06:44 +00:00
src : ve . ce . minImgDataUri ,
2014-08-22 20:50:48 +00:00
width : 1 ,
height : 2 ,
2019-03-28 16:23:50 +00:00
alt : 'alt text' ,
2018-06-05 11:41:09 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './FooBar' ,
2018-06-26 12:02:19 +00:00
mw : { } ,
2014-08-22 20:50:48 +00:00
originalClasses : 'mw-halign-right foobar' ,
2015-07-22 22:13:09 +00:00
unrecognizedClasses : [ 'foobar' ]
2013-10-05 10:27:39 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
{ type : 'mwImageCaption' } ,
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-10-05 10:27:39 +00:00
'a' , 'b' , 'c' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' }
2013-10-15 12:18:11 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : {
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
h1d9b405cfd633576 : ve . ce . minImgDataUri
2016-08-17 19:50:55 +00:00
}
2013-10-05 10:27:39 +00:00
} ;
2013-10-15 16:50:01 +00:00
ve . dm . mwExample . MWInlineImage = {
2023-05-30 15:00:52 +00:00
html : ve . dm . example . singleLine `
< span typeof = "mw:Image" class = "foo mw-valign-text-top" >
< a href = "./File:Wiki.png" class = "mw-file-description" >
< img resource = "./File:Wiki.png" src = "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class = "mw-file-element" height = "155" width = "135" alt = "alt text" >
< / a >
< / s p a n >
` ,
2014-08-22 20:50:48 +00:00
data : {
type : 'mwInlineImage' ,
attributes : {
src : 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png' ,
href : './File:Wiki.png' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2017-04-27 18:08:35 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2014-08-22 20:50:48 +00:00
width : 135 ,
height : 155 ,
2019-03-28 16:23:50 +00:00
alt : 'alt text' ,
2018-06-05 11:41:09 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2014-08-22 20:50:48 +00:00
valign : 'text-top' ,
resource : './File:Wiki.png' ,
2018-06-26 12:02:19 +00:00
mw : { } ,
2014-08-22 20:50:48 +00:00
type : 'none' ,
originalClasses : 'foo mw-valign-text-top' ,
2022-05-31 18:35:52 +00:00
unrecognizedClasses : [ 'foo' ]
2014-05-15 16:12:43 +00:00
}
2013-10-15 12:18:11 +00:00
} ,
2016-08-17 19:50:55 +00:00
storeItems : {
2018-02-24 12:15:55 +00:00
hbb0aeb2b8e907b74 : 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png'
2016-08-17 19:50:55 +00:00
}
2013-10-15 16:50:01 +00:00
} ;
2013-10-05 10:27:39 +00:00
2023-05-30 14:07:19 +00:00
ve . dm . mwExample . MWInlineImageWithoutWrapperClass = {
2023-05-30 15:00:52 +00:00
html : ve . dm . example . singleLine `
< span typeof = "mw:Image" class = "foo mw-valign-text-top" >
< a href = "./File:Wiki.png" >
< img resource = "./File:Wiki.png" src = "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class = "mw-file-element" height = "155" width = "135" alt = "alt text" >
< / a >
< / s p a n >
` ,
2022-03-09 19:33:42 +00:00
data : {
type : 'mwInlineImage' ,
attributes : {
src : 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png' ,
href : './File:Wiki.png' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : null ,
2022-03-09 19:33:42 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2022-03-09 19:33:42 +00:00
width : 135 ,
height : 155 ,
alt : 'alt text' ,
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2022-03-09 19:33:42 +00:00
valign : 'text-top' ,
resource : './File:Wiki.png' ,
mw : { } ,
type : 'none' ,
originalClasses : 'foo mw-valign-text-top' ,
2022-05-31 18:35:52 +00:00
unrecognizedClasses : [ 'foo' ]
2022-03-09 19:33:42 +00:00
}
}
} ;
2013-07-17 01:22:22 +00:00
ve . dm . mwExample . mwNowikiAnnotation = {
2015-02-17 00:36:52 +00:00
type : 'mwNowiki'
2013-07-17 01:22:22 +00:00
} ;
ve . dm . mwExample . mwNowiki = [
2014-08-22 20:50:48 +00:00
{ type : 'paragraph' } ,
2013-07-17 01:22:22 +00:00
'F' , 'o' , 'o' ,
[ '[' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ '[' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ 'B' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ 'a' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ 'r' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ ']' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
[ ']' , [ ve . dm . mwExample . mwNowikiAnnotation ] ] ,
'B' , 'a' , 'z' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-07-17 01:22:22 +00:00
] ;
ve . dm . mwExample . mwNowikiHtml = '<body><p>Foo<span typeof="mw:Nowiki">[[Bar]]</span>Baz</p></body>' ;
2015-02-17 00:36:52 +00:00
ve . dm . mwExample . mwNowikiHtmlFromData = '<body><p>Foo[[Bar]]Baz</p></body>' ;
2013-07-03 01:30:10 +00:00
ve . dm . mwExample . withMeta = [
{
2015-02-21 21:18:24 +00:00
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{
type : 'comment' ,
2014-08-22 20:50:48 +00:00
attributes : {
2018-05-31 15:12:28 +00:00
text : ' No conversion '
2013-07-03 01:30:10 +00:00
}
} ,
2015-02-21 21:18:24 +00:00
{ type : '/comment' } ,
{ type : '/paragraph' } ,
2013-07-03 01:30:10 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:ThisIsAnAlien" />' )
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwAlienMeta' } ,
{ type : 'paragraph' } ,
2013-07-03 01:30:10 +00:00
'F' ,
'o' ,
'o' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwCategory' ,
attributes : {
category : 'Category:Bar' ,
2022-12-21 15:49:20 +00:00
sortkey : ''
2015-02-17 00:36:52 +00:00
}
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwCategory' } ,
2013-07-03 01:30:10 +00:00
'B' ,
'a' ,
'r' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:foo" content="bar" />' )
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwAlienMeta' } ,
2013-07-03 01:30:10 +00:00
'B' ,
'a' ,
{
2014-08-22 20:50:48 +00:00
type : 'comment' ,
attributes : {
text : ' inline '
2013-07-03 01:30:10 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
{ type : '/comment' } ,
2013-07-03 01:30:10 +00:00
'z' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
2013-07-03 01:30:10 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:bar" content="baz" />' )
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwAlienMeta' } ,
2013-07-03 01:30:10 +00:00
{
2015-02-21 21:18:24 +00:00
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{
type : 'comment' ,
2014-08-22 20:50:48 +00:00
attributes : {
text : 'barbaz'
2013-07-03 01:30:10 +00:00
}
} ,
2015-02-21 21:18:24 +00:00
{ type : '/comment' } ,
{ type : '/paragraph' } ,
2013-07-03 01:30:10 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwCategory' ,
attributes : {
category : 'Category:Foo foo' ,
2022-12-21 15:49:20 +00:00
sortkey : 'Bar baz#quux'
2015-02-17 00:36:52 +00:00
}
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwCategory' } ,
2013-07-03 01:30:10 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
2013-07-03 01:30:10 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwAlienMeta' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-07-03 01:30:10 +00:00
] ;
2018-03-20 23:22:03 +00:00
ve . dm . mwExample . withMetaRealData = [
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{
type : 'comment' ,
attributes : {
2018-05-31 15:12:28 +00:00
text : ' No conversion '
2018-03-20 23:22:03 +00:00
}
} ,
{ type : '/comment' } ,
{ type : '/paragraph' } ,
{
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:ThisIsAnAlien" />' )
2018-03-20 23:22:03 +00:00
} ,
{ type : '/mwAlienMeta' } ,
2014-08-22 20:50:48 +00:00
{ type : 'paragraph' } ,
2013-07-03 01:30:10 +00:00
'F' ,
'o' ,
'o' ,
'B' ,
'a' ,
'r' ,
'B' ,
'a' ,
2018-03-20 23:22:03 +00:00
{
type : 'comment' ,
attributes : {
text : ' inline '
}
} ,
{ type : '/comment' } ,
2013-07-03 01:30:10 +00:00
'z' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
2018-03-20 23:22:03 +00:00
{
type : 'mwCategory' ,
attributes : {
category : 'Category:Bar' ,
2022-12-21 15:49:20 +00:00
sortkey : ''
2018-03-20 23:22:03 +00:00
}
} ,
{ type : '/mwCategory' } ,
{
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:foo" content="bar" />' )
2018-03-20 23:22:03 +00:00
} ,
{ type : '/mwAlienMeta' } ,
{
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:bar" content="baz" />' )
2018-03-20 23:22:03 +00:00
} ,
{ type : '/mwAlienMeta' } ,
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{
type : 'comment' ,
attributes : {
text : 'barbaz'
}
} ,
{ type : '/comment' } ,
{ type : '/paragraph' } ,
{
type : 'mwCategory' ,
attributes : {
category : 'Category:Foo foo' ,
2022-12-21 15:49:20 +00:00
sortkey : 'Bar baz#quux'
2018-03-20 23:22:03 +00:00
}
} ,
{ type : '/mwCategory' } ,
{
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
2018-03-20 23:22:03 +00:00
} ,
{ type : '/mwAlienMeta' } ,
2014-08-22 20:50:48 +00:00
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-07-03 01:30:10 +00:00
] ;
ve . dm . mwExample . withMetaMetaData = [
[
{
2014-08-22 20:50:48 +00:00
type : 'alienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<!-- No conversion -->' )
2013-07-03 01:30:10 +00:00
} ,
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:ThisIsAnAlien" />' )
2013-07-03 01:30:10 +00:00
}
] ,
undefined ,
undefined ,
undefined ,
[
{
2014-08-22 20:50:48 +00:00
type : 'mwCategory' ,
attributes : {
category : 'Category:Bar' ,
2022-12-21 15:49:20 +00:00
sortkey : ''
2015-02-17 00:36:52 +00:00
}
2013-07-03 01:30:10 +00:00
}
] ,
undefined ,
undefined ,
[
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:foo" content="bar" />' )
2013-07-03 01:30:10 +00:00
}
] ,
undefined ,
[
{
2014-08-22 20:50:48 +00:00
type : 'alienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<!-- inline -->' )
2013-07-03 01:30:10 +00:00
}
] ,
undefined ,
[
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta property="mw:bar" content="baz" />' )
2013-07-03 01:30:10 +00:00
} ,
{
2014-08-22 20:50:48 +00:00
type : 'comment' ,
attributes : {
text : 'barbaz'
2013-07-03 01:30:10 +00:00
}
} ,
{
2014-08-22 20:50:48 +00:00
type : 'mwCategory' ,
attributes : {
category : 'Category:Foo foo' ,
2022-12-21 15:49:20 +00:00
sortkey : 'Bar baz#quux'
2015-02-17 00:36:52 +00:00
}
2013-07-03 01:30:10 +00:00
} ,
{
2014-08-22 20:50:48 +00:00
type : 'mwAlienMeta' ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
2013-07-03 01:30:10 +00:00
}
] ,
undefined ,
undefined
] ;
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . domToDataCases = {
2015-11-20 00:08:32 +00:00
'adjacent annotations (data-parsoid)' : {
preserveAnnotationDomElements : true ,
2023-06-01 13:21:55 +00:00
body : ve . dm . example . singleLine `
< b > a < / b >
< b data - parsoid = "1" > b < / b >
< b data - parsoid = "2" > c < / b >
< b > d < / b >
< b > d < / b >
` ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-07-12 21:21:20 +00:00
[
2015-11-20 00:08:32 +00:00
'a' ,
2013-07-12 21:21:20 +00:00
[ {
2014-08-22 20:50:48 +00:00
type : 'textStyle/bold' ,
2015-11-20 00:08:32 +00:00
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2013-07-12 21:21:20 +00:00
} ]
] ,
[
2015-11-20 00:08:32 +00:00
'b' ,
2013-07-12 21:21:20 +00:00
[ {
2014-08-22 20:50:48 +00:00
type : 'textStyle/bold' ,
2015-11-20 00:08:32 +00:00
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b data-parsoid="1">b</b>' )
2013-07-12 21:21:20 +00:00
} ]
] ,
[
2015-11-20 00:08:32 +00:00
'c' ,
2013-07-12 21:21:20 +00:00
[ {
2014-08-22 20:50:48 +00:00
type : 'textStyle/bold' ,
2015-11-20 00:08:32 +00:00
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b data-parsoid="2">c</b>' )
2013-07-12 21:21:20 +00:00
} ]
] ,
2015-11-20 00:08:32 +00:00
' ' ,
2013-07-12 21:21:20 +00:00
[
2015-11-20 00:08:32 +00:00
'd' ,
2013-07-12 21:21:20 +00:00
[ {
2014-08-22 20:50:48 +00:00
type : 'textStyle/bold' ,
2015-11-20 00:08:32 +00:00
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2013-07-12 21:21:20 +00:00
} ]
] ,
[
2015-11-20 00:08:32 +00:00
'd' ,
2013-07-12 21:21:20 +00:00
[ {
2014-08-22 20:50:48 +00:00
type : 'textStyle/bold' ,
2015-11-20 00:08:32 +00:00
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2013-07-12 21:21:20 +00:00
} ]
] ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-07-12 21:21:20 +00:00
] ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
2021-04-29 14:42:18 +00:00
const data = [ 'x' , [ ve . dm . example . bold ] ] ,
2015-11-20 00:08:32 +00:00
linearData = ve . dm . example . preprocessAnnotations ( [ data ] , model . getStore ( ) ) ;
model . data . data . splice ( 3 , 0 , linearData . data [ 0 ] ) ;
} ,
2023-06-01 13:21:55 +00:00
normalizedBody : ve . dm . example . singleLine `
< b > a < / b >
< b data - parsoid = "1" > bx < / b >
< b data - parsoid = "2" > c < / b >
< b > dd < / b >
` ,
fromDataBody : ve . dm . example . singleLine `
< b > a < / b >
< b data - parsoid = "1" > bx < / b >
< b data - parsoid = "2" > c < / b >
< b > dd < / b
`
2013-07-12 21:21:20 +00:00
} ,
2020-06-10 19:31:16 +00:00
'adjacent annotations (RESTBase IDs)' : {
2015-11-20 00:33:02 +00:00
preserveAnnotationDomElements : true ,
2023-06-01 13:21:55 +00:00
body : ve . dm . example . singleLine `
< b > a < / b >
< b id = "mwAB" > b < / b >
< b id = "mwCD" > c < / b >
< b > d < / b >
< b > d < / b >
` ,
2015-11-20 00:33:02 +00:00
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
[
'a' ,
[ {
type : 'textStyle/bold' ,
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2015-11-20 00:33:02 +00:00
} ]
] ,
[
'b' ,
[ {
type : 'textStyle/bold' ,
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b id="mwAB">b</b>' )
2015-11-20 00:33:02 +00:00
} ]
] ,
[
'c' ,
[ {
type : 'textStyle/bold' ,
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b id="mwCD">c</b>' )
2015-11-20 00:33:02 +00:00
} ]
] ,
' ' ,
[
'd' ,
[ {
type : 'textStyle/bold' ,
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2015-11-20 00:33:02 +00:00
} ]
] ,
[
'd' ,
[ {
type : 'textStyle/bold' ,
attributes : { nodeName : 'b' } ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<b>a</b>' )
2015-11-20 00:33:02 +00:00
} ]
] ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
2021-04-29 14:42:18 +00:00
const data = [ 'x' , [ ve . dm . example . bold ] ] ,
2015-11-20 00:33:02 +00:00
linearData = ve . dm . example . preprocessAnnotations ( [ data ] , model . getStore ( ) ) ;
model . data . data . splice ( 3 , 0 , linearData . data [ 0 ] ) ;
} ,
2023-06-01 13:21:55 +00:00
normalizedBody : ve . dm . example . singleLine `
< b > a < / b >
< b id = "mwAB" > bx < / b >
< b id = "mwCD" > c < / b >
< b > dd < / b >
` ,
fromDataBody : ve . dm . example . singleLine `
< b > a < / b >
< b id = "mwAB" > bx < / b >
< b id = "mwCD" > c < / b >
< b > dd < / b >
`
2015-11-20 00:33:02 +00:00
} ,
2015-02-17 13:03:59 +00:00
mwImage : {
2023-05-30 15:00:52 +00:00
body : ` <p> ${ ve . dm . mwExample . MWInlineImage . html } </p> ` ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' } ,
2013-10-15 16:50:01 +00:00
ve . dm . mwExample . MWInlineImage . data ,
2014-08-22 20:50:48 +00:00
{ type : '/mwInlineImage' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2016-08-17 19:50:55 +00:00
] ,
2023-05-30 15:00:52 +00:00
ceHtml : ve . dm . example . singleLine `
< p class = "ve-ce-branchNode ve-ce-contentBranchNode ve-ce-paragraphNode" >
< span class = "ve-ce-branchNode-slug ve-ce-branchNode-inlineSlug" > < / s p a n >
2023-06-09 15:52:08 +00:00
< a class = "mw-file-description ve-ce-leafNode ve-ce-focusableNode ve-ce-mwInlineImageNode" contenteditable = "false" href = "${new URL( './File:Wiki.png', ve.dm.mwExample.baseUri )}" >
< img src = "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class = "mw-file-element" width = "135" height = "155" style = "vertical-align: text-top;" >
2023-05-30 15:00:52 +00:00
< / a >
$ { ve . dm . example . inlineSlug }
< / p >
` ,
2022-03-09 19:33:42 +00:00
storeItems : ve . dm . mwExample . MWInlineImage . storeItems
} ,
2023-05-30 14:07:19 +00:00
mwImageWithoutWrapperClass : {
body : '<p>' + ve . dm . mwExample . MWInlineImageWithoutWrapperClass . html + '</p>' ,
2022-03-09 19:33:42 +00:00
data : [
{ type : 'paragraph' } ,
2023-05-30 14:07:19 +00:00
ve . dm . mwExample . MWInlineImageWithoutWrapperClass . data ,
2022-03-09 19:33:42 +00:00
{ type : '/mwInlineImage' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
ceHtml : ve . dm . example . singleLine `
< p class = "ve-ce-branchNode ve-ce-contentBranchNode ve-ce-paragraphNode" >
< span class = "ve-ce-branchNode-slug ve-ce-branchNode-inlineSlug" > < / s p a n >
2023-06-09 15:52:08 +00:00
< a class = "mw-file-description ve-ce-leafNode ve-ce-focusableNode ve-ce-mwInlineImageNode" contenteditable = "false" href = "${new URL( './File:Wiki.png', ve.dm.mwExample.baseUri )}" >
< img src = "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class = "mw-file-element" width = "135" height = "155" style = "vertical-align: text-top;" >
2023-05-30 15:00:52 +00:00
< / a >
$ { ve . dm . example . inlineSlug }
< / p >
` ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWInlineImage . storeItems
2013-06-26 21:18:39 +00:00
} ,
2015-02-17 13:03:59 +00:00
'mwHeading and mwPreformatted nodes' : {
body : '<h2>Foo</h2><pre>Bar</pre>' ,
data : [
{
type : 'mwHeading' ,
attributes : {
level : 2
}
} ,
'F' , 'o' , 'o' ,
{ type : '/mwHeading' } ,
{ type : 'mwPreformatted' } ,
'B' , 'a' , 'r' ,
{ type : '/mwPreformatted' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
2015-02-17 13:05:24 +00:00
'mwTable with duplicate class attributes' : {
body : '<table class="wikitable sortable wikitable"><tr><td>Foo</td></tr></table>' ,
2015-02-17 13:03:59 +00:00
data : [
{
type : 'mwTable' ,
attributes : {
2023-02-20 15:00:11 +00:00
hasExpandedAttrs : false ,
2015-02-17 13:03:59 +00:00
wikitable : true ,
sortable : true ,
2015-02-17 13:05:24 +00:00
originalClasses : 'wikitable sortable wikitable' ,
2015-02-17 13:03:59 +00:00
unrecognizedClasses : [ ]
2015-02-17 00:36:52 +00:00
}
2015-02-17 13:03:59 +00:00
} ,
{ type : 'tableSection' , attributes : { style : 'body' } } ,
{ type : 'tableRow' } ,
{ type : 'tableCell' , attributes : { style : 'data' } } ,
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
'F' , 'o' , 'o' ,
{ type : '/paragraph' } ,
{ type : '/tableCell' } ,
{ type : '/tableRow' } ,
{ type : '/tableSection' } ,
{ type : '/mwTable' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2016-06-30 12:31:04 +00:00
] ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 0 , ( item ) => {
2021-01-23 19:47:59 +00:00
item . attributes . wikitable = false ;
item . attributes . sortable = false ;
} ) ;
2016-06-30 12:31:04 +00:00
} ,
normalizedBody : '<table><tr><td>Foo</td></tr></table>'
2015-02-17 13:03:59 +00:00
} ,
2022-05-23 14:18:20 +00:00
'mwGalleryImage (broken image)' : {
2023-06-01 13:21:55 +00:00
body : ve . dm . example . singleLine `
< ul class = "gallery mw-gallery-traditional" typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{},"body":{}}' >
< li class = "gallerybox" style = "width: 155px;" >
< div class = "thumb" style = "width: 150px; height: 150px;" >
< span typeof = "mw:Error mw:File" data - mw = '{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' >
< a href = "./Special:FilePath/!Example.jpg" >
2023-05-30 14:08:20 +00:00
< span class = "mw-file-element mw-broken-media" resource = "./File:!Example.jpg" data - width = "120" data - height = "120" > File : ! Example . jpg < / s p a n >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" >
< / d i v >
< / l i >
< / u l >
` ,
2022-05-23 14:18:20 +00:00
data : [
{
type : 'mwGallery' ,
attributes : {
mw : {
2023-02-15 22:41:04 +00:00
attrs : { } ,
2023-02-22 15:08:46 +00:00
body : { } ,
2022-05-23 14:18:20 +00:00
name : 'gallery'
} ,
2023-02-22 15:08:46 +00:00
originalMw : '{"name":"gallery","attrs":{},"body":{}}'
2022-05-23 14:18:20 +00:00
}
} ,
{
type : 'mwGalleryImage' ,
attributes : {
2023-02-15 22:41:04 +00:00
mediaClass : 'File' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'span' ,
2022-05-23 14:18:20 +00:00
altText : null ,
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
altTextSame : false ,
2022-05-23 14:18:20 +00:00
width : 120 ,
height : 120 ,
2023-02-15 22:41:04 +00:00
resource : './File:!Example.jpg' ,
2023-02-15 01:53:10 +00:00
href : './Special:FilePath/!Example.jpg' ,
2023-05-30 14:08:20 +00:00
imageClassAttr : 'mw-file-element mw-broken-media' ,
2023-05-11 00:19:47 +00:00
imgWrapperClassAttr : null ,
2022-05-23 14:18:20 +00:00
src : null ,
2023-02-16 02:28:35 +00:00
isError : true ,
errorText : 'File:!Example.jpg'
2022-05-23 14:18:20 +00:00
}
} ,
{ type : 'mwGalleryImageCaption' } ,
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{ type : '/paragraph' } ,
{ type : '/mwGalleryImageCaption' } ,
{ type : '/mwGalleryImage' } ,
{ type : '/mwGallery' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-06-01 13:21:55 +00:00
fromDataBody : ve . dm . example . singleLine `
< ul typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{},"body":{}}' >
< li class = "gallerybox" >
< div class = "thumb" >
< span typeof = "mw:Error mw:File" >
< a href = "./Special:FilePath/!Example.jpg" >
2023-05-30 14:08:20 +00:00
< span class = "mw-file-element mw-broken-media" resource = "./File:!Example.jpg" data - width = "120" data - height = "120" > File : ! Example . jpg < / s p a n >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > < / d i v >
< / l i >
< / u l >
`
2022-05-23 14:18:20 +00:00
} ,
2018-08-14 07:42:03 +00:00
'mwGalleryImage (empty caption in DOM)' : {
2023-06-01 13:21:55 +00:00
body : ve . dm . example . singleLine `
< ul class = "gallery mw-gallery-packed" typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}' >
< li class = "gallerybox" style = "width: 182px;" >
< div class = "thumb" style = "width: 180px;" >
< span typeof = "mw:File" >
< a href = "./File:Example.jpg" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./File:Example.jpg" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" decoding = "async" data - file - width = "400"
2023-06-01 13:21:55 +00:00
data - file - height = "267" data - file - type = "bitmap" height = "120" width = "180" srcset = "${ve.ce.minImgDataUri} 2x" / >
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > < / d i v >
< / l i >
< / u l >
` ,
2018-08-14 07:42:03 +00:00
data : [
{
type : 'mwGallery' ,
attributes : {
mw : {
attrs : {
mode : 'packed'
} ,
2023-02-22 15:08:46 +00:00
body : { } ,
2018-08-14 07:42:03 +00:00
name : 'gallery'
} ,
2023-02-22 15:08:46 +00:00
originalMw : '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'
2018-08-14 07:42:03 +00:00
}
} ,
{
type : 'mwGalleryImage' ,
attributes : {
2023-02-15 22:41:04 +00:00
mediaClass : 'File' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
altText : null ,
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
altTextSame : false ,
2023-02-15 22:41:04 +00:00
width : 180 ,
2022-05-21 12:59:31 +00:00
height : 120 ,
2023-02-15 22:41:04 +00:00
resource : './File:Example.jpg' ,
2023-02-15 01:53:10 +00:00
href : null ,
2023-05-30 14:08:20 +00:00
imageClassAttr : 'mw-file-element' ,
2023-05-11 00:19:47 +00:00
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
src : ve . ce . minImgDataUri ,
2023-02-16 02:28:35 +00:00
isError : false ,
errorText : null
2018-08-14 07:42:03 +00:00
}
} ,
{ type : 'mwGalleryImageCaption' } ,
{
type : 'paragraph' ,
internal : {
2021-03-10 22:59:31 +00:00
generated : 'wrapper'
2018-08-14 07:42:03 +00:00
}
} ,
{ type : '/paragraph' } ,
{ type : '/mwGalleryImageCaption' } ,
{ type : '/mwGalleryImage' } ,
{ type : '/mwGallery' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-06-01 13:21:55 +00:00
fromDataBody : ve . dm . example . singleLine `
< ul typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}' >
< li class = "gallerybox" >
< div class = "thumb" >
< span typeof = "mw:File" >
< a href = "./File:Example.jpg" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./File:Example.jpg" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "120" width = "180" / >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > < / d i v >
< / l i >
< / u l >
`
2018-08-14 07:42:03 +00:00
} ,
2023-02-15 22:41:04 +00:00
'mwGalleryImage (caption with content)' : {
2023-06-01 13:21:55 +00:00
body : ve . dm . example . singleLine `
< ul class = "gallery mw-gallery-packed" typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}' >
< li class = "gallerybox" style = "width: 182px;" >
< div class = "thumb" style = "width: 180px;" >
< span typeof = "mw:File" >
< a href = "./File:Example.jpg" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./File:Example.jpg" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" data - file - width = "400" data - file - height = "267" data - file - type = "bitmap" height = "120" width = "180" / >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > Caption < / d i v >
< / l i >
< / u l >
` ,
2018-08-14 07:42:03 +00:00
data : [
{
type : 'mwGallery' ,
attributes : {
mw : {
attrs : {
mode : 'packed'
} ,
2023-02-22 15:08:46 +00:00
body : { } ,
2018-08-14 07:42:03 +00:00
name : 'gallery'
} ,
2023-02-22 15:08:46 +00:00
originalMw : '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'
2018-08-14 07:42:03 +00:00
}
} ,
{
type : 'mwGalleryImage' ,
attributes : {
2023-02-15 22:41:04 +00:00
mediaClass : 'File' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
altText : null ,
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
altTextSame : false ,
2023-02-15 22:41:04 +00:00
width : 180 ,
2022-05-21 12:59:31 +00:00
height : 120 ,
2023-02-15 22:41:04 +00:00
resource : './File:Example.jpg' ,
2023-02-15 01:53:10 +00:00
href : null ,
2023-05-30 14:08:20 +00:00
imageClassAttr : 'mw-file-element' ,
2023-05-11 00:19:47 +00:00
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
src : ve . ce . minImgDataUri ,
2023-02-16 02:28:35 +00:00
isError : false ,
errorText : null
2018-08-14 07:42:03 +00:00
}
} ,
{ type : 'mwGalleryImageCaption' } ,
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
'C' , 'a' , 'p' , 't' , 'i' , 'o' , 'n' ,
{ type : '/paragraph' } ,
{ type : '/mwGalleryImageCaption' } ,
{ type : '/mwGalleryImage' } ,
{ type : '/mwGallery' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-06-01 13:21:55 +00:00
fromDataBody : ve . dm . example . singleLine `
< ul typeof = "mw:Extension/gallery" about = "#mwt2" data - mw = '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}' >
< li class = "gallerybox" >
< div class = "thumb" >
< span typeof = "mw:File" >
< a href = "./File:Example.jpg" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./File:Example.jpg" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "120" width = "180" / >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > Caption < / d i v >
< / l i >
< / u l >
`
2018-08-14 07:42:03 +00:00
} ,
'mwGalleryImage (no caption in model)' : {
data : [
{
type : 'mwGallery' ,
attributes : {
mw : {
attrs : {
mode : 'packed'
} ,
2023-02-22 15:08:46 +00:00
body : { } ,
2018-08-14 07:42:03 +00:00
name : 'gallery'
} ,
2023-02-22 15:08:46 +00:00
originalMw : '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'
2018-08-14 07:42:03 +00:00
}
} ,
{
type : 'mwGalleryImage' ,
attributes : {
2022-05-30 23:17:46 +00:00
mediaClass : 'Image' ,
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
altText : null ,
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
altTextSame : false ,
2022-05-21 12:59:31 +00:00
width : 120 ,
height : 120 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2023-02-15 01:53:10 +00:00
href : null ,
2023-05-30 14:08:20 +00:00
imageClassAttr : 'mw-file-element' ,
2023-05-11 00:19:47 +00:00
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
src : ve . ce . minImgDataUri ,
2023-02-16 02:28:35 +00:00
isError : false ,
errorText : null
2018-08-14 07:42:03 +00:00
}
} ,
{ type : '/mwGalleryImage' } ,
{ type : '/mwGallery' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-06-01 13:21:55 +00:00
fromDataBody : ve . dm . example . singleLine `
< ul typeof = "mw:Extension/gallery" data - mw = '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}' >
< li class = "gallerybox" >
< div class = "thumb" >
< span typeof = "mw:Image" >
< a href = "./Foo" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "120" width = "120" / >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< / l i >
< / u l >
`
2018-08-14 07:42:03 +00:00
} ,
'mwGalleryImage (empty caption in model)' : {
data : [
{
type : 'mwGallery' ,
attributes : {
mw : {
attrs : {
mode : 'packed'
} ,
2023-02-22 15:08:46 +00:00
body : { } ,
2018-08-14 07:42:03 +00:00
name : 'gallery'
} ,
2023-02-22 15:08:46 +00:00
originalMw : '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'
2018-08-14 07:42:03 +00:00
}
} ,
{
type : 'mwGalleryImage' ,
attributes : {
2022-05-30 23:17:46 +00:00
mediaClass : 'Image' ,
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
altText : null ,
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
altTextSame : false ,
2022-05-21 12:59:31 +00:00
width : 120 ,
height : 120 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2023-02-15 01:53:10 +00:00
href : null ,
2023-05-30 14:08:20 +00:00
imageClassAttr : 'mw-file-element' ,
2023-05-11 00:19:47 +00:00
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
src : ve . ce . minImgDataUri ,
2023-02-16 02:28:35 +00:00
isError : false ,
errorText : null
2018-08-14 07:42:03 +00:00
}
} ,
{ type : 'mwGalleryImageCaption' } ,
{ type : '/mwGalleryImageCaption' } ,
{ type : '/mwGalleryImage' } ,
{ type : '/mwGallery' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-06-01 13:21:55 +00:00
fromDataBody : ve . dm . example . singleLine `
< ul typeof = "mw:Extension/gallery" data - mw = '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}' >
< li class = "gallerybox" >
< div class = "thumb" >
< span typeof = "mw:Image" >
< a href = "./Foo" class = "mw-file-description" >
2023-05-30 14:08:20 +00:00
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "120" width = "120" / >
2023-06-01 13:21:55 +00:00
< / a >
< / s p a n >
< / d i v >
< div class = "gallerytext" > < / d i v >
< / l i >
< / u l >
`
2018-08-14 07:42:03 +00:00
} ,
'mwBlockImage (no caption in DOM)' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< / f i g u r e >
` ,
2018-08-14 07:42:03 +00:00
data : [
{
type : 'mwBlockImage' ,
attributes : {
align : 'default' ,
alt : null ,
height : 300 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2018-08-14 07:42:03 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
mw : { } ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2018-08-14 07:42:03 +00:00
src : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' ,
type : 'thumb' ,
width : 300
}
} ,
{ type : 'mwImageCaption' } ,
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
normalizedBody : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< figcaption > < / f i g c a p t i o n >
< / f i g u r e >
`
2018-08-14 07:42:03 +00:00
} ,
'mwBlockImage (empty caption in DOM)' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< figcaption > < / f i g c a p t i o n >
< / f i g u r e >
` ,
2018-08-14 07:42:03 +00:00
data : [
{
type : 'mwBlockImage' ,
attributes : {
align : 'default' ,
alt : null ,
height : 300 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2018-08-14 07:42:03 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
mw : { } ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2018-08-14 07:42:03 +00:00
src : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' ,
type : 'thumb' ,
width : 300
}
} ,
{ type : 'mwImageCaption' } ,
{
type : 'paragraph' ,
internal : {
2021-03-10 22:59:31 +00:00
generated : 'wrapper'
2018-08-14 07:42:03 +00:00
}
} ,
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
'mwBlockImage (caption with content in DOM)' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< figcaption > Caption < / f i g c a p t i o n >
< / f i g u r e >
` ,
2018-08-14 07:42:03 +00:00
data : [
{
type : 'mwBlockImage' ,
attributes : {
align : 'default' ,
alt : null ,
height : 300 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2018-08-14 07:42:03 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
mw : { } ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2018-08-14 07:42:03 +00:00
src : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' ,
type : 'thumb' ,
width : 300
}
} ,
{ type : 'mwImageCaption' } ,
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
'C' , 'a' , 'p' , 't' , 'i' , 'o' , 'n' ,
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
'mwBlockImage (no caption in model)' : {
data : [
{
type : 'mwBlockImage' ,
attributes : {
align : 'default' ,
alt : null ,
height : 300 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2018-08-14 07:42:03 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
mw : { } ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2018-08-14 07:42:03 +00:00
src : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' ,
type : 'thumb' ,
width : 300
}
} ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
fromDataBody : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< / f i g u r e >
`
2018-08-14 07:42:03 +00:00
} ,
'mwBlockImage (empty caption in model)' : {
data : [
{
type : 'mwBlockImage' ,
attributes : {
align : 'default' ,
alt : null ,
height : 300 ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2018-08-14 07:42:03 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
2018-08-14 07:42:03 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2018-08-14 07:42:03 +00:00
mw : { } ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './Foo' ,
2018-08-14 07:42:03 +00:00
src : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' ,
type : 'thumb' ,
width : 300
}
} ,
{ type : 'mwImageCaption' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
fromDataBody : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img resource = "./Foo" src = "${ve.ce.minImgDataUri}" class = "mw-file-element" height = "300" width = "300" / >
< / a >
< / f i g u r e >
`
2018-08-14 07:42:03 +00:00
} ,
2013-06-26 21:18:39 +00:00
'mw:Transclusion (block level)' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . blockOpen + ve . dm . mwExample . MWTransclusion . blockContent ,
data : [
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion . blockData ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionBlock' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWTransclusion . blockStoreItems ,
2015-02-17 00:36:52 +00:00
normalizedBody : ve . dm . mwExample . MWTransclusion . blockOpen + ve . dm . mwExample . MWTransclusion . blockContent ,
2015-02-23 02:40:58 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . blockOpenFromData ,
2018-05-31 15:12:28 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . blockOpenClipboard + ve . dm . mwExample . MWTransclusion . blockContentClipboard ,
previewBody : ve . dm . mwExample . MWTransclusion . blockOpen + ve . dm . mwExample . MWTransclusion . blockContent
2013-06-26 21:18:39 +00:00
} ,
'mw:Transclusion (block level - modified)' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . blockOpen + ve . dm . mwExample . MWTransclusion . blockContent ,
data : [
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion . blockData ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionBlock' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWTransclusion . blockStoreItems ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 0 , ( item ) => {
2021-01-23 19:47:59 +00:00
item . attributes . mw . parts [ 0 ] . template . params [ '1' ] . wt = 'Hello, globe!' ;
} ) ;
2013-06-26 21:18:39 +00:00
} ,
2019-01-17 12:58:29 +00:00
normalizedBody : ve . dm . mwExample . MWTransclusion . blockOpenModified . replace ( /about="#mwt1"/ , '' ) ,
2015-02-23 02:40:58 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . blockOpenFromDataModified ,
2018-05-31 15:12:28 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . blockOpenModifiedClipboard ,
previewBody : false
2013-06-26 21:18:39 +00:00
} ,
'mw:Transclusion (inline)' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . inlineOpen + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose ,
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion . inlineData ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionInline' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWTransclusion . inlineStoreItems ,
2015-02-17 00:36:52 +00:00
normalizedBody : ve . dm . mwExample . MWTransclusion . inlineOpen + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose ,
2015-02-23 02:40:58 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . inlineOpenFromData + ve . dm . mwExample . MWTransclusion . inlineClose ,
2018-05-31 15:12:28 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . inlineOpenClipboard + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose ,
previewBody : ve . dm . mwExample . MWTransclusion . inlineOpen + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose
2013-06-26 21:18:39 +00:00
} ,
'mw:Transclusion (inline - modified)' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . inlineOpen + ve . dm . mwExample . MWTransclusion . inlineContent + ve . dm . mwExample . MWTransclusion . inlineClose ,
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion . inlineData ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionInline' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWTransclusion . inlineStoreItems ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 1 , ( item ) => {
2021-01-23 19:47:59 +00:00
item . attributes . mw . parts [ 0 ] . template . params [ '1' ] . wt = '5,678' ;
} ) ;
2013-06-26 21:18:39 +00:00
} ,
2019-01-17 12:58:29 +00:00
normalizedBody : ve . dm . mwExample . MWTransclusion . inlineOpenModified . replace ( /about="#mwt1"/ , '' ) + ve . dm . mwExample . MWTransclusion . inlineClose ,
2015-02-23 02:40:58 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . inlineOpenFromDataModified + ve . dm . mwExample . MWTransclusion . inlineClose ,
2018-05-31 15:12:28 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . inlineOpenModifiedClipboard + ve . dm . mwExample . MWTransclusion . inlineClose ,
previewBody : false
2013-06-26 21:18:39 +00:00
} ,
'two mw:Transclusion nodes with identical params but different htmlAttributes' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . pairOne + ve . dm . mwExample . MWTransclusion . pairTwo ,
2015-02-17 00:36:52 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . pairFromData + ve . dm . mwExample . MWTransclusion . pairFromData ,
2015-02-23 02:40:58 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . pairClipboard + ve . dm . mwExample . MWTransclusion . pairClipboard ,
2018-05-31 15:12:28 +00:00
previewBody : ve . dm . mwExample . MWTransclusion . pairOne + ve . dm . mwExample . MWTransclusion . pairOne ,
2014-08-22 20:50:48 +00:00
data : [
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwTransclusionBlock' ,
attributes : {
mw : {
parts : [
2014-08-20 20:36:12 +00:00
{
2014-08-22 20:50:48 +00:00
template : {
target : {
wt : 'echo' ,
href : './Template:Echo'
2014-08-20 20:36:12 +00:00
} ,
2014-08-22 20:50:48 +00:00
params : {
1 : {
wt : 'foo'
2014-08-20 20:36:12 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
i : 0
2014-08-20 20:36:12 +00:00
}
}
]
2013-06-26 21:18:39 +00:00
} ,
2015-10-02 10:39:40 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionBlock' } ,
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwTransclusionBlock' ,
attributes : {
mw : {
parts : [
2014-08-20 20:36:12 +00:00
{
2014-08-22 20:50:48 +00:00
template : {
target : {
wt : 'echo' ,
href : './Template:Echo'
2014-08-20 20:36:12 +00:00
} ,
2014-08-22 20:50:48 +00:00
params : {
1 : {
wt : 'foo'
2014-08-20 20:36:12 +00:00
}
} ,
2014-08-22 20:50:48 +00:00
i : 0
2014-08-20 20:36:12 +00:00
}
}
]
2013-06-26 21:18:39 +00:00
} ,
2015-10-02 10:39:40 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwTransclusionBlock' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : {
2023-05-30 15:00:52 +00:00
hd2ff771ac84b229d : $ . parseHTML ( ve . dm . example . singleLine `
< p about = "#mwt1" typeof = "mw:Transclusion"
data - mw = '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data - parsoid = "1" >
foo
< / p >
` )
2016-08-17 19:50:55 +00:00
}
2013-06-26 21:18:39 +00:00
} ,
2013-07-23 13:35:26 +00:00
'mw:Transclusion containing only meta data' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . meta ,
2015-03-12 17:30:28 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . metaFromData ,
clipboardBody : ve . dm . mwExample . MWTransclusion . metaClipboard ,
2018-05-31 15:12:28 +00:00
previewBody : false ,
2014-08-22 20:50:48 +00:00
data : [
2013-07-23 13:35:26 +00:00
{
2015-03-12 17:30:28 +00:00
internal : { generated : 'wrapper' } ,
type : 'paragraph'
} ,
{
type : 'mwTransclusionInline' ,
2014-08-22 20:50:48 +00:00
attributes : {
2015-03-12 17:30:28 +00:00
mw : {
parts : [ {
template : {
target : {
wt : 'Template:Echo' ,
href : './Template:Echo'
} ,
params : {
1 : { wt : '[[Category:Page]]\n[[Category:Book]]' }
} ,
i : 0
}
} ]
} ,
2017-07-18 11:55:33 +00:00
originalMw : '{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}'
2013-07-23 13:35:26 +00:00
}
} ,
2015-03-12 17:30:28 +00:00
{ type : '/mwTransclusionInline' } ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-07-23 13:35:26 +00:00
]
} ,
2015-06-16 12:51:35 +00:00
'mw:Transclusion which is also a language annotation' : {
body : '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}">content</span>' ,
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
{
type : 'mwTransclusionInline' ,
attributes : {
mw : { } ,
originalMw : '{}'
} ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}">content</span>' )
2015-06-16 12:51:35 +00:00
} ,
{ type : '/mwTransclusionInline' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2018-05-31 15:12:28 +00:00
clipboardBody : '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}" data-ve-no-generated-contents="true">content</span>' ,
previewBody : false
2015-06-16 12:51:35 +00:00
} ,
2015-03-23 15:49:38 +00:00
'mw:AlienBlockExtension' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< div about = "#mwt1" typeof = "mw:Extension/syntaxhighlight"
data - mw = '{"name":"syntaxhighlight","attrs":{"lang":"php"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
2023-06-01 13:21:55 +00:00
data - parsoid = "1" >
2023-05-30 15:00:52 +00:00
< div > < span > Rendering < / s p a n > < / d i v >
< / d i v >
` ,
normalizedBody : ve . dm . example . singleLine `
< div typeof = "mw:Extension/syntaxhighlight"
data - mw = '{"name":"syntaxhighlight","attrs":{"lang":"php5"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
2023-06-01 13:21:55 +00:00
about = "#mwt1" data - parsoid = "1" >
2023-05-30 15:00:52 +00:00
< / d i v >
` ,
2015-03-23 12:49:37 +00:00
data : [
{
2015-03-23 15:49:38 +00:00
type : 'mwAlienBlockExtension' ,
2015-03-23 12:49:37 +00:00
attributes : {
mw : {
name : 'syntaxhighlight' ,
attrs : {
lang : 'php'
} ,
body : {
extsrc : '\n$foo = bar;\n'
}
} ,
originalMw : '{"name":"syntaxhighlight","attrs":{"lang":"php"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
} ,
2022-03-08 23:48:22 +00:00
originalDomElements : $ . parseHTML ( '<div about="#mwt1" data-parsoid="1"></div>' )
2015-03-23 12:49:37 +00:00
} ,
2015-03-23 15:49:38 +00:00
{ type : '/mwAlienBlockExtension' } ,
2015-03-23 12:49:37 +00:00
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 0 , ( item ) => {
2021-01-23 19:47:59 +00:00
item . attributes . mw . attrs . lang = 'php5' ;
} ) ;
2015-03-23 12:49:37 +00:00
}
} ,
2015-03-23 15:49:38 +00:00
'mw:AlienInlineExtension' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< p >
< img src = "${ve.ce.minImgDataUri}" width = "100" height = "20" alt = "Bar" typeof = "mw:Extension/score"
data - mw = '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c' { e d c d e e e }"}}'
data - parsoid = "1" about = "#mwt1" / >
< / p >
` ,
normalizedBody : ve . dm . example . singleLine `
< p >
< span typeof = "mw:Extension/score"
data - mw = '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c' { d d d e e e }"}}'
src = "${ve.ce.minImgDataUri}" width = "100" height = "20" alt = "Bar" data - parsoid = "1" about = "#mwt1" / >
< / p >
` ,
2015-03-23 15:49:38 +00:00
data : [
{ type : 'paragraph' } ,
{
type : 'mwAlienInlineExtension' ,
attributes : {
mw : {
name : 'score' ,
attrs : { } ,
body : {
extsrc : '\\relative c\' { e d c d e e e }'
}
} ,
originalMw : '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c\' { e d c d e e e }"}}'
} ,
2023-05-30 15:00:52 +00:00
originalDomElements : $ . parseHTML ( ` <img src=" ${ ve . ce . minImgDataUri } " width="100" height="20" alt="Bar" about="#mwt1" data-parsoid="1"></img> ` )
2015-03-23 15:49:38 +00:00
} ,
{ type : '/mwAlienInlineExtension' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 1 , ( item ) => {
2021-01-23 19:47:59 +00:00
item . attributes . mw . body . extsrc = '\\relative c\' { d d d e e e }' ;
} ) ;
2015-03-23 15:49:38 +00:00
}
} ,
2014-01-06 13:56:55 +00:00
'internal link with absolute path' : {
2014-08-22 20:50:48 +00:00
body : '<p>' + ve . dm . mwExample . MWInternalLink . absoluteOpen + 'Foo</a></p>' ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' } ,
2014-01-06 13:56:55 +00:00
[
'F' ,
[ ve . dm . mwExample . MWInternalLink . absoluteData ]
] ,
[
'o' ,
[ ve . dm . mwExample . MWInternalLink . absoluteData ]
] ,
[
'o' ,
[ ve . dm . mwExample . MWInternalLink . absoluteData ]
] ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2014-01-06 13:56:55 +00:00
] ,
2018-10-05 19:24:27 +00:00
normalizedBody : '<p><a rel="mw:WikiLink" href="./Foo/Bar">Foo</a></p>' ,
2014-08-22 20:50:48 +00:00
mwConfig : {
wgArticlePath : '/wiki/$1'
2014-01-06 13:56:55 +00:00
}
} ,
2014-03-19 02:08:47 +00:00
'internal link with absolute path and section' : {
2014-08-22 20:50:48 +00:00
body : '<p>' + ve . dm . mwExample . MWInternalSectionLink . absoluteOpen + 'Foo</a></p>' ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' } ,
2014-03-19 02:08:47 +00:00
[
'F' ,
[ ve . dm . mwExample . MWInternalSectionLink . absoluteData ]
] ,
[
'o' ,
[ ve . dm . mwExample . MWInternalSectionLink . absoluteData ]
] ,
[
'o' ,
[ ve . dm . mwExample . MWInternalSectionLink . absoluteData ]
] ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2014-03-19 02:08:47 +00:00
] ,
2018-10-05 19:24:27 +00:00
normalizedBody : '<p><a rel="mw:WikiLink" href="./Foo#Bar">Foo</a></p>' ,
2014-08-22 20:50:48 +00:00
mwConfig : {
wgArticlePath : '/wiki/$1'
2014-03-19 02:08:47 +00:00
}
} ,
2015-01-31 02:43:09 +00:00
'internal link with href set to ./' : {
2015-04-16 20:46:49 +00:00
body : '<p><a rel="mw:WikiLink" href="./">x</a></p>' ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2015-01-31 02:43:09 +00:00
data : [
{ type : 'paragraph' } ,
[
2015-04-16 20:46:49 +00:00
'x' ,
2015-01-31 02:43:09 +00:00
[ {
type : 'link/mwInternal' ,
attributes : {
title : '' ,
normalizedTitle : '' ,
2019-04-03 19:17:19 +00:00
lookupTitle : ''
2015-02-17 00:36:52 +00:00
}
2015-01-31 02:43:09 +00:00
} ]
] ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
2016-09-18 22:22:09 +00:00
'internal link with special characters' : {
body : '<p><a rel="mw:WikiLink" href="./Foo%3F+%25&Bar">x</a></p>' ,
2022-01-04 02:01:38 +00:00
ignoreXmlWarnings : true ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2016-09-18 22:22:09 +00:00
data : [
{ type : 'paragraph' } ,
[
'x' ,
[ {
type : 'link/mwInternal' ,
attributes : {
title : 'Foo?+%&Bar' ,
normalizedTitle : 'Foo?+%&Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Foo?+%&Bar'
2016-09-18 22:22:09 +00:00
}
} ]
] ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
2019-09-24 16:25:03 +00:00
'mw:MediaLink (exists)' : {
body : '<p><a rel="mw:MediaLink" href="//localhost/w/images/x/xx/Exists.png" resource="./Media:Exists.png" title="Exists.png">Media:Exists.png</a></p>' ,
data : [
{ type : 'paragraph' } ,
[ 'M' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'e' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'd' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'i' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'a' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ ':' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'E' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'x' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'i' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 's' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 't' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 's' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ '.' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'p' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'n' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
[ 'g' , [ ve . dm . mwExample . MWMediaLinkExistsData ] ] ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
normalizedBody : '<p><a href="./Media:Exists.png" rel="mw:WikiLink" resource="./Media:Exists.png" title="Exists.png">Media:Exists.png</a></p>' ,
fromDataBody : '<p><a href="./Media:Exists.png" rel="mw:WikiLink">Media:Exists.png</a></p>'
} ,
'mw:MediaLink (missing)' : {
body : '<p><a rel="mw:MediaLink" href="./Special:FilePath/Missing.png" resource="./Media:Missing.png" title="Missing.png" typeof="mw:Error" data-mw=\'{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}\'>Media:Missing.png</a></p>' ,
data : [
{ type : 'paragraph' } ,
[ 'M' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'e' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'd' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'i' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'a' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ ':' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'M' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'i' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 's' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 's' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'i' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'n' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'g' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ '.' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'p' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'n' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
[ 'g' , [ ve . dm . mwExample . MWMediaLinkMissingData ] ] ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
normalizedBody : '<p><a href="./Media:Missing.png" rel="mw:WikiLink" resource="./Media:Missing.png" title="Missing.png" typeof="mw:Error" data-mw=\'{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}\'>Media:Missing.png</a></p>' ,
fromDataBody : '<p><a href="./Media:Missing.png" rel="mw:WikiLink">Media:Missing.png</a></p>'
} ,
2013-10-17 20:15:36 +00:00
'numbered external link (empty mw:Extlink)' : {
2018-05-31 14:06:57 +00:00
body : '<p>Foo<a rel="mw:ExtLink" href="http://www.example.com"></a>Bar</p>' ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' } ,
2013-10-17 20:15:36 +00:00
'F' , 'o' , 'o' ,
{
2014-08-22 20:50:48 +00:00
type : 'link/mwNumberedExternal' ,
attributes : {
href : 'http://www.example.com'
2015-02-17 00:36:52 +00:00
}
2013-10-17 20:15:36 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/link/mwNumberedExternal' } ,
2013-10-17 20:15:36 +00:00
'B' , 'a' , 'r' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2016-06-27 14:19:53 +00:00
] ,
2018-05-31 14:06:57 +00:00
clipboardBody : '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>'
2013-06-26 21:18:39 +00:00
} ,
2018-03-05 19:35:25 +00:00
'numbered external link (non-empty mw:Extlink as cross-document paste)' : {
2018-05-31 14:06:57 +00:00
body : '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>' ,
2018-03-05 19:35:25 +00:00
data : [
{ type : 'paragraph' } ,
'F' , 'o' , 'o' ,
{
type : 'link/mwNumberedExternal' ,
attributes : {
href : 'http://www.example.com'
}
} ,
{ type : '/link/mwNumberedExternal' } ,
'B' , 'a' , 'r' ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2018-05-31 14:06:57 +00:00
clipboardBody : '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>' ,
normalizedBody : '<p>Foo<a rel="mw:ExtLink" href="http://www.example.com"></a>Bar</p>'
2018-03-05 19:35:25 +00:00
} ,
2013-06-26 21:18:39 +00:00
'URL link' : {
2018-04-23 15:03:32 +00:00
body : '<p><a rel="mw:ExtLink" href="https://www.mediawiki.org/">mw</a></p>' ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' } ,
2013-06-26 21:18:39 +00:00
[
'm' ,
[ {
2014-08-22 20:50:48 +00:00
type : 'link/mwExternal' ,
attributes : {
2018-04-23 15:03:32 +00:00
href : 'https://www.mediawiki.org/' ,
2014-08-22 20:50:48 +00:00
rel : 'mw:ExtLink'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ]
] ,
[
'w' ,
[ {
2014-08-22 20:50:48 +00:00
type : 'link/mwExternal' ,
attributes : {
2018-04-23 15:03:32 +00:00
href : 'https://www.mediawiki.org/' ,
2014-08-22 20:50:48 +00:00
rel : 'mw:ExtLink'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ]
] ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2018-05-31 15:12:28 +00:00
] ,
previewBody : '<p><a rel="mw:ExtLink" class="external" href="https://www.mediawiki.org/">mw</a></p>'
2018-01-22 18:59:45 +00:00
} , / * F I X M E T 1 8 5 9 0 2 : T e m p o r a r i l y c o m m e n t e d o u t f a i l i n g t e s t c a s e
2013-06-26 21:18:39 +00:00
'whitespace preservation with wrapped comments and language links' : {
2014-08-22 20:50:48 +00:00
body : 'Foo\n' +
2023-05-30 15:00:52 +00:00
< link rel = "mw:PageProp/Language" href = "http://de.wikipedia.org/wiki/Foo" > \ n
2013-10-18 21:27:25 +00:00
'<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Foo">' ,
2014-08-22 20:50:48 +00:00
data : [
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'paragraph' ,
internal : {
generated : 'wrapper' ,
2018-01-22 18:59:45 +00:00
metaItems : [
{
2018-03-06 12:44:37 +00:00
originalDomElementsHash : 'h188ab6af88887790' ,
2018-01-22 18:59:45 +00:00
type : 'mwLanguage' ,
attributes : {
href : 'http://de.wikipedia.org/wiki/Foo'
} ,
internal : {
2018-03-06 12:44:37 +00:00
loadMetaParentHash : 'hbc66e1df10d058e6' ,
2018-01-22 18:59:45 +00:00
loadMetaParentOffset : 3
}
} ,
{
2018-03-06 12:44:37 +00:00
originalDomElementsHash : 'h188ab6ff88887790' ,
2018-01-22 18:59:45 +00:00
type : 'mwLanguage' ,
attributes : {
href : 'http://fr.wikipedia.org/wiki/Foo'
} ,
internal : {
2018-03-06 12:44:37 +00:00
loadMetaParentHash : 'h4e7ce2a82b7ce627' ,
2018-01-22 18:59:45 +00:00
loadMetaParentOffset : 6
}
}
] ,
2014-08-22 20:50:48 +00:00
whitespace : [ undefined , undefined , undefined , '\n' ]
2013-06-26 21:18:39 +00:00
}
} ,
'F' ,
'o' ,
'o' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwLanguage' ,
attributes : {
href : 'http://de.wikipedia.org/wiki/Foo'
2013-06-26 21:18:39 +00:00
} ,
2018-01-22 18:59:45 +00:00
internal : {
whitespace : [ '\n' , undefined , undefined , '\n' ]
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwLanguage' } ,
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwLanguage' ,
attributes : {
href : 'http://fr.wikipedia.org/wiki/Foo'
2014-05-15 16:12:43 +00:00
} ,
2018-01-22 18:59:45 +00:00
internal : {
whitespace : [ '\n' ]
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwLanguage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
2020-06-02 20:30:00 +00:00
} , * /
2013-06-26 21:18:39 +00:00
'document with meta elements' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
<!-- No conversion -- >
< meta property = "mw:ThisIsAnAlien" / >
< p >
Foo
< link rel = "mw:PageProp/Category" href = "./Category:Bar" / >
Bar
< meta property = "mw:foo" content = "bar" / >
Ba <!-- inline -- > z <
/ p >
< meta property = "mw:bar" content = "baz" / >
<!-- barbaz -- >
< link rel = "mw:PageProp/Category" href = "./Category:Foo_foo#Bar%20baz%23quux" / >
< meta typeof = "mw:Placeholder" data - parsoid = "foobar" / >
` ,
clipboardBody : ve . dm . example . singleLine `
< span rel = "ve:Comment" data - ve - comment = " No conversion " >
& nbsp ;
< / s p a n >
< meta property = "mw:ThisIsAnAlien" / >
< p >
Foo
< link rel = "mw:PageProp/Category" href = "./Category:Bar" / >
Bar
< meta property = "mw:foo" content = "bar" / >
Ba < span rel = "ve:Comment" data - ve - comment = " inline " > & nbsp ; < / s p a n > z
< / p >
< meta property = "mw:bar" content = "baz" / >
< span rel = "ve:Comment" data - ve - comment = "barbaz" > & nbsp ; < / s p a n >
< link rel = "mw:PageProp/Category" href = "./Category:Foo_foo#Bar%20baz%23quux" / >
< meta typeof = "mw:Placeholder" data - parsoid = "foobar" / >
` ,
previewBody : ve . dm . example . singleLine `
$ { ve . dm . example . commentNodePreview ( ' No conversion ' ) }
< meta property = "mw:ThisIsAnAlien" / >
< p >
Foo
< a href = "/wiki/Category:Bar" > Bar < / a >
Bar
< meta property = "mw:foo" content = "bar" / >
Ba$ { ve . dm . example . commentNodePreview ( ' inline ' ) } z
< / p >
< meta property = "mw:bar" content = "baz" / >
$ { ve . dm . example . commentNodePreview ( 'barbaz' ) }
< a href = "/wiki/Category:Foo_foo" > Foo foo < / a >
< meta typeof = "mw:Placeholder" data - parsoid = "foobar" / >
` ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2018-03-20 23:22:03 +00:00
data : ve . dm . mwExample . withMeta ,
realData : ve . dm . mwExample . withMetaRealData
2013-06-26 21:18:39 +00:00
} ,
'RDFa types spread across two attributes, about grouping is forced' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWTransclusion . mixed ,
2015-02-17 00:36:52 +00:00
fromDataBody : ve . dm . mwExample . MWTransclusion . mixedFromData ,
2015-02-23 02:40:58 +00:00
clipboardBody : ve . dm . mwExample . MWTransclusion . mixedClipboard ,
2018-05-31 15:12:28 +00:00
previewBody : ve . dm . mwExample . MWTransclusion . mixed ,
2014-08-22 20:50:48 +00:00
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-06-26 21:18:39 +00:00
ve . dm . mwExample . MWTransclusion . mixedDataOpen ,
ve . dm . mwExample . MWTransclusion . mixedDataClose ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
] ,
2016-08-17 19:50:55 +00:00
storeItems : ve . dm . mwExample . MWTransclusion . mixedStoreItems
2013-06-26 21:18:39 +00:00
} ,
'mw:Entity' : {
2014-08-22 20:50:48 +00:00
body : '<p>a<span typeof="mw:Entity">¢</span>b<span typeof="mw:Entity">¥</span><span typeof="mw:Entity">™</span></p>' ,
data : [
{ type : 'paragraph' } ,
2013-06-26 21:18:39 +00:00
'a' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '¢' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
'b' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '¥' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '™' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
} ,
2020-01-08 00:38:19 +00:00
'mw:DisplaySpace' : {
2020-06-04 17:48:49 +00:00
body : '<p>a<span typeof="mw:DisplaySpace"> </span>: b</p>' ,
2020-01-08 00:38:19 +00:00
data : [
{ type : 'paragraph' } ,
'a' ,
{
type : 'mwEntity' ,
attributes : {
character : '\u00a0' ,
displaySpace : true
}
} ,
{ type : '/mwEntity' } ,
':' ,
' ' ,
'b' ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
]
} ,
2013-06-26 21:18:39 +00:00
'wrapping with mw:Entity' : {
2014-08-22 20:50:48 +00:00
body : 'a<span typeof="mw:Entity">¢</span>b<span typeof="mw:Entity">¥</span><span typeof="mw:Entity">™</span>' ,
data : [
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
2013-06-26 21:18:39 +00:00
'a' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '¢' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
'b' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '¥' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '™' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
} ,
'whitespace preservation with mw:Entity' : {
2014-08-22 20:50:48 +00:00
body : '<p> a <span typeof="mw:Entity"> </span> b <span typeof="mw:Entity">¥</span>\t<span typeof="mw:Entity">™</span></p>' ,
data : [
{ type : 'paragraph' , internal : { whitespace : [ undefined , ' ' ] } } ,
2013-06-26 21:18:39 +00:00
'a' ,
' ' ,
' ' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : ' ' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
' ' ,
' ' ,
' ' ,
'b' ,
' ' ,
' ' ,
' ' ,
' ' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '¥' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
2013-06-26 21:18:39 +00:00
'\t' ,
{
2014-08-22 20:50:48 +00:00
type : 'mwEntity' ,
2015-02-17 00:36:52 +00:00
attributes : { character : '™' }
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwEntity' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
} ,
'category default sort key' : {
2014-08-22 20:50:48 +00:00
body : '<meta property="mw:PageProp/categorydefaultsort" content="foo">' ,
data : [
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwDefaultSort' ,
attributes : {
content : 'foo'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : '/mwDefaultSort' } ,
{ type : 'paragraph' , internal : { generated : 'empty' } } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
} ,
'thumb image' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . MWBlockImage . html ,
data : ve . dm . mwExample . MWBlockImage . data . concat ( [
{ type : 'internalList' } ,
{ type : '/internalList' }
2016-08-17 19:50:55 +00:00
] ) ,
storeItems : ve . dm . mwExample . MWBlockImage . storeItems
2013-06-26 21:18:39 +00:00
} ,
2022-01-19 00:39:56 +00:00
'broken block image' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< figure class = "mw-default-size" typeof = "mw:Error mw:Image/Thumb" data - mw = '{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' >
< a href = "./Special:FilePath/Missing_image.jpg" >
< span resource = "./File:Missing_image.jpg" class = "mw-file-element mw-broken-media" data - width = "220" > File : Missing image . jpg < / s p a n >
< / a >
< figcaption > abc < / f i g c a p t i o n >
< / f i g u r e >
` ,
2022-01-19 00:39:56 +00:00
data : [
{
type : 'mwBlockImage' ,
attributes : {
type : 'thumb' ,
align : 'default' ,
href : './Special:FilePath/Missing_image.jpg' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element mw-broken-media' ,
2022-03-09 19:33:42 +00:00
imgWrapperClassAttr : null ,
2022-01-19 00:39:56 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'span' ,
2022-01-19 00:39:56 +00:00
src : null ,
defaultSize : true ,
width : 220 ,
height : null ,
originalWidth : 220 ,
originalHeight : null ,
alt : null ,
isError : true ,
2023-02-16 02:28:35 +00:00
errorText : 'File:Missing image.jpg' ,
2022-01-19 00:39:56 +00:00
resource : './File:Missing_image.jpg' ,
mw : {
errors : [ {
key : 'apierror-filedoesnotexist' ,
message : 'This image does not exist.'
} ]
} ,
originalClasses : 'mw-default-size' ,
unrecognizedClasses : [ ]
}
} ,
{ type : 'mwImageCaption' } ,
{ type : 'paragraph' , internal : { generated : 'wrapper' } } ,
'a' , 'b' , 'c' ,
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
previewBody : ve . dm . example . singleLine `
< figure class = "mw-default-size" typeof = "mw:Error mw:Image/Thumb" data - mw = '{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' >
< a href = "./Special:FilePath/Missing_image.jpg" class = "new" >
< span resource = "./File:Missing_image.jpg" class = "mw-file-element mw-broken-media" data - width = "220" > File : Missing image . jpg < / s p a n >
< / a >
< figcaption > abc < / f i g c a p t i o n >
< / f i g u r e >
`
2022-01-19 00:39:56 +00:00
} ,
'broken inline image' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< p >
< span typeof = "mw:Error mw:Image" data - mw = '{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' >
< a href = "./Special:FilePath/Missing_image.jpg" >
< span resource = "./File:Missing_image.jpg" class = "mw-file-element mw-broken-media" data - width = "200" > File : Missing image . jpg < / s p a n >
< / a >
< / s p a n >
< / p >
` ,
2022-01-19 00:39:56 +00:00
data : [
{ type : 'paragraph' } ,
{
type : 'mwInlineImage' ,
attributes : {
type : 'none' ,
href : './Special:FilePath/Missing_image.jpg' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element mw-broken-media' ,
2022-03-09 19:33:42 +00:00
imgWrapperClassAttr : null ,
2022-01-19 00:39:56 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'span' ,
2022-01-19 00:39:56 +00:00
src : null ,
width : 200 ,
height : null ,
valign : 'default' ,
alt : null ,
isError : true ,
2023-02-16 02:28:35 +00:00
errorText : 'File:Missing image.jpg' ,
2022-01-19 00:39:56 +00:00
resource : './File:Missing_image.jpg' ,
mw : {
errors : [ {
key : 'apierror-filedoesnotexist' ,
message : 'This image does not exist.'
} ]
} ,
originalClasses : null ,
unrecognizedClasses : [ ]
}
} ,
{ type : '/mwInlineImage' } ,
{ type : '/paragraph' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
] ,
2023-05-30 15:00:52 +00:00
previewBody : ve . dm . example . singleLine `
< p >
< span typeof = "mw:Error mw:Image" data - mw = '{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' >
< a href = "./Special:FilePath/Missing_image.jpg" class = "new" >
< span resource = "./File:Missing_image.jpg" class = "mw-file-element mw-broken-media" data - width = "200" > File : Missing image . jpg < / s p a n >
< / a >
< / s p a n >
< / p >
`
2022-01-19 00:39:56 +00:00
} ,
2013-06-26 21:18:39 +00:00
'attribute preservation does not crash due to text node split' : {
2023-05-30 15:00:52 +00:00
body : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" data - parsoid = "{}" >
< a href = "./Foo" data - parsoid = "{}" class = "mw-file-description" >
< img src = "${ve.ce.minImgDataUri}" class = "mw-file-element" width = "1" height = "2" resource = "./FooBar" data - parsoid = "{}" >
< / a >
< figcaption data - parsoid = "{}" >
foo < a rel = "mw:WikiLink" href = "./Bar" data - parsoid = "{}" > bar < / a > b a z
< / f i g c a p t i o n >
< / f i g u r e >
` ,
fromDataBody : ve . dm . example . singleLine `
< figure typeof = "mw:Image/Thumb" >
< a href = "./Foo" class = "mw-file-description" >
< img src = "${ve.ce.minImgDataUri}" class = "mw-file-element" width = "1" height = "2" resource = "./FooBar" >
< / a >
< figcaption >
foo < a rel = "mw:WikiLink" href = "./Bar" > bar < / a > b a z
< / f i g c a p t i o n >
< / f i g u r e >
` ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2014-08-22 20:50:48 +00:00
data : [
2013-06-26 21:18:39 +00:00
{
2014-08-22 20:50:48 +00:00
type : 'mwBlockImage' ,
attributes : {
type : 'thumb' ,
align : 'default' ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
href : './Foo' ,
2023-05-30 14:07:19 +00:00
imageClassAttr : 'mw-file-element' ,
imgWrapperClassAttr : 'mw-file-description' ,
2017-04-27 18:08:35 +00:00
mediaClass : 'Image' ,
2022-05-30 23:17:46 +00:00
mediaTag : 'img' ,
2016-01-07 01:06:44 +00:00
src : ve . ce . minImgDataUri ,
2014-08-22 20:50:48 +00:00
width : 1 ,
height : 2 ,
2018-06-05 11:41:09 +00:00
alt : null ,
2018-06-26 12:02:19 +00:00
mw : { } ,
2018-06-05 11:41:09 +00:00
isError : false ,
2023-02-16 02:28:35 +00:00
errorText : null ,
Parse relative hrefs on image nodes like on regular links (try 2)
Previous, reverted attempt: da9b6fffbdba9007cfe893b1eafd1ccb42dbb537.
This attempt also includes 6037fefbe044fbf61e7734923f3b625f10e910a1,
and fixes minor conflicts with other changes.
* In normal images, parse relative 'href' attributes instead of
expanding them to absolute. This resolves Parsoid generating
|link= options for copy-pasted images (T193253).
Keep them in the underscore-form to avoid causing dirty diffs like
T237040 again. Unlike in the previous attempt, we don't need to be
super-careful about the 'resource' attribute, thanks to the Parsoid
changes in T108504.
* In gallery images stuff, prefix the 'resource' attribute with './',
same as normal images do. This causes no functional changes, but it
makes updating tests easier, and the consistency is probably good.
* Update test examples to also prefix 'resource' and relative 'href'
attributes with './', like the real Parsoid does.
Bug: T193253
Change-Id: I91131728a87c9406bf069d46d3c94c9a8905a003
2019-09-10 18:57:05 +00:00
resource : './FooBar'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ,
2014-08-22 20:50:48 +00:00
{ type : 'mwImageCaption' , internal : { whitespace : [ undefined , ' ' ] } } ,
{ type : 'paragraph' , internal : { generated : 'wrapper' , whitespace : [ ' ' ] } } ,
2013-06-26 21:18:39 +00:00
'f' , 'o' , 'o' , ' ' ,
[
'b' ,
[ {
2014-08-22 20:50:48 +00:00
type : 'link/mwInternal' ,
attributes : {
title : 'Bar' ,
normalizedTitle : 'Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Bar'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ]
] ,
[
'a' ,
[ {
2014-08-22 20:50:48 +00:00
type : 'link/mwInternal' ,
attributes : {
title : 'Bar' ,
normalizedTitle : 'Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Bar'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ]
] ,
[
'r' ,
[ {
2014-08-22 20:50:48 +00:00
type : 'link/mwInternal' ,
attributes : {
title : 'Bar' ,
normalizedTitle : 'Bar' ,
2019-04-03 19:17:19 +00:00
lookupTitle : 'Bar'
2015-02-17 00:36:52 +00:00
}
2013-06-26 21:18:39 +00:00
} ]
] ,
' ' , 'b' , 'a' , 'z' ,
2014-08-22 20:50:48 +00:00
{ type : '/paragraph' } ,
{ type : '/mwImageCaption' } ,
{ type : '/mwBlockImage' } ,
{ type : 'internalList' } ,
{ type : '/internalList' }
2013-06-26 21:18:39 +00:00
]
2013-07-17 01:22:22 +00:00
} ,
'mw:Nowiki' : {
2014-08-22 20:50:48 +00:00
body : ve . dm . mwExample . mwNowikiHtml ,
2015-02-17 00:36:52 +00:00
data : ve . dm . mwExample . mwNowiki ,
fromDataBody : ve . dm . mwExample . mwNowikiHtmlFromData
2013-07-17 01:22:22 +00:00
} ,
'mw:Nowiki unwraps when text modified' : {
2014-08-22 20:50:48 +00:00
data : ve . dm . mwExample . mwNowiki ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 7 , ( item ) => {
2021-01-23 19:47:59 +00:00
item [ 0 ] = 'z' ;
} ) ;
2013-07-17 01:22:22 +00:00
} ,
2014-08-22 20:50:48 +00:00
normalizedBody : '<p>Foo[[Bzr]]Baz</p>'
2013-07-17 01:22:22 +00:00
} ,
'mw:Nowiki unwraps when annotations modified' : {
2014-08-22 20:50:48 +00:00
data : ve . dm . mwExample . mwNowiki ,
2021-04-30 09:33:22 +00:00
modify : ( model ) => {
model . data . modifyData ( 7 , ( item ) => {
2021-01-23 19:47:59 +00:00
item [ 1 ] . push ( model . getStore ( ) . hash ( ve . dm . example . createAnnotation ( ve . dm . example . bold ) ) ) ;
} ) ;
2013-07-17 01:22:22 +00:00
} ,
2014-08-22 20:50:48 +00:00
normalizedBody : '<p>Foo[[B<b>a</b>r]]Baz</p>'
2015-08-03 22:48:42 +00:00
} ,
2020-11-05 21:24:43 +00:00
'plain external links when pasted are converted to link/mwExternal' : {
fromClipboard : true ,
2018-04-23 15:03:32 +00:00
body : '<a href="https://www.mediawiki.org/">ab</a>' ,
2016-03-17 15:30:59 +00:00
data : [
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
2016-03-17 18:35:22 +00:00
[
'a' ,
[ {
type : 'link/mwExternal' ,
attributes : {
2018-04-23 15:03:32 +00:00
href : 'https://www.mediawiki.org/'
2016-03-17 18:35:22 +00:00
}
} ]
] ,
2016-03-17 15:30:59 +00:00
[
'b' ,
[ {
type : 'link/mwExternal' ,
attributes : {
2018-04-23 15:03:32 +00:00
href : 'https://www.mediawiki.org/'
2016-03-17 15:30:59 +00:00
}
} ]
] ,
2016-03-17 18:35:22 +00:00
{
type : '/paragraph'
} ,
{
type : 'internalList'
} ,
{
type : '/internalList'
}
] ,
2018-05-31 15:12:28 +00:00
normalizedBody : '<a href="https://www.mediawiki.org/" rel="mw:ExtLink">ab</a>' ,
previewBody : '<a href="https://www.mediawiki.org/" class="external" rel="mw:ExtLink">ab</a>'
2016-03-17 18:35:22 +00:00
} ,
2020-11-05 21:24:43 +00:00
'plain internal links when pasted are converted to link/mwInternal' : {
fromClipboard : true ,
2016-03-17 18:35:22 +00:00
body : '<a href="' + ve . dm . mwExample . MWInternalLink . absoluteHref + '">ab</a>' ,
2023-01-30 14:57:56 +00:00
base : ve . dm . mwExample . baseUri ,
2016-03-17 18:35:22 +00:00
data : [
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
2016-03-17 15:30:59 +00:00
[
'a' ,
[ {
2016-03-17 18:35:22 +00:00
type : 'link/mwInternal' ,
2016-03-17 15:30:59 +00:00
attributes : {
2016-03-17 18:35:22 +00:00
title : 'Foo/Bar' ,
normalizedTitle : 'Foo/Bar' ,
lookupTitle : 'Foo/Bar'
2016-03-17 15:30:59 +00:00
}
} ]
] ,
[
2016-03-17 18:35:22 +00:00
'b' ,
2016-03-17 15:30:59 +00:00
[ {
2016-03-17 18:35:22 +00:00
type : 'link/mwInternal' ,
2016-03-17 15:30:59 +00:00
attributes : {
2016-03-17 18:35:22 +00:00
title : 'Foo/Bar' ,
normalizedTitle : 'Foo/Bar' ,
lookupTitle : 'Foo/Bar'
2016-03-17 15:30:59 +00:00
}
} ]
] ,
{
type : '/paragraph'
} ,
{
type : 'internalList'
} ,
{
type : '/internalList'
}
] ,
2018-10-05 19:24:27 +00:00
normalizedBody : '<a href="./Foo/Bar" rel="mw:WikiLink">ab</a>' ,
2016-03-17 18:35:22 +00:00
mwConfig : {
wgArticlePath : '/wiki/$1'
}
2018-04-06 10:52:02 +00:00
} ,
2020-11-05 21:24:43 +00:00
'plain href-less anchors when pasted are converted to spans' : {
fromClipboard : true ,
2018-04-06 10:52:02 +00:00
body : '<a name="foo">ab</a>' ,
data : [
{
type : 'paragraph' ,
internal : {
generated : 'wrapper'
}
} ,
[
'a' ,
[ {
type : 'textStyle/span' ,
2020-11-05 21:24:43 +00:00
attributes : { nodeName : 'span' }
2018-04-06 10:52:02 +00:00
} ]
] ,
[
'b' ,
[ {
type : 'textStyle/span' ,
2020-11-05 21:24:43 +00:00
attributes : { nodeName : 'span' }
2018-04-06 10:52:02 +00:00
} ]
] ,
{
type : '/paragraph'
} ,
{
type : 'internalList'
} ,
{
type : '/internalList'
}
] ,
2020-11-05 21:24:43 +00:00
normalizedBody : '<span name="foo">ab</span>' ,
fromDataBody : '<span>ab</span>'
2013-06-26 21:18:39 +00:00
}
} ;