Talk:VisualEditor/API/Data Model/Surface
Add topicAppearance
< Talk:VisualEditor | API
Latest comment: 6 years ago by Adamw in topic Request for clarification
| This page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
Request for clarification
[edit]Beginner feedback: I would love to see a paragraph added, explaining how to get a surfaceModel. Adamw (talk) 11:49, 7 October 2019 (UTC)
I would love to see a paragraph added, explaining all methods of fragments like insertContent etc.
Structures here - is objects or variable in JSON format, that need to insert content in fragment, which is not wrapped in
<nowiki>
tags, allowing you to add content with wiki markup.
Examples of permitted structures
[edit]Adding redirect to Page
[edit]var redirectContent = [{
type: 'mwRedirect',
attributes: {title: 'Page'}
}];
fragment.collapseToStart().insertContent(redirectContent);
Template with values
[edit][{
type: 'mwTransclusionBlock',
attributes: {
mw: {
parts: [
{
template: {
target: { href: 'Template:MyTemplate', wt: 'MyTemplate' },
params: { 1: { wt: 'my parameter' } }
}
}
]
}
}
},
{ type: '/mwTransclusionBlock' } /*???*/]
Links
[edit][{
type: 'link',
attributes: {
href: 'https://example.com',
title: 'Пример ссылки'
},
content: 'Пример ссылки'
}]
Images
[edit][{
type: 'image',
attributes: {
src: 'File:Example.jpg',
alt: 'Пример изображения'
}
}]