WYSIWYG editor for editing XWiki syntax style documents.
Roadmap:
- support markdown syntax
<!-- ... -->
<dr-wedit id="edit1"></dr-wedit>
<!-- ... -->
<script src="wedit.js"></script>
<script>
// init the editor
let editor = wedit.createEditor({
id: "edit1",
toolbarButtons: ["code", "charStyles", "paragraph", "lists", "paragraphStyles"],
utilButtons: ["fullscreen", "sidebar"],
sidebar: {
tags: {
title: "Tags",
content: [
{
headline: "Firma",
tags: [
{tag: "content.name1", description: "Firmenname"},
]
}
]
},
templates: {
title: "Templates",
content: [
{
code: '<#if company.hasEmail()>E: ${company.email} </#if>\n'+
'<#if company.hasPhone()>T: ${company.phone} </#if>\n'+
'<#if company.hasFax()>F: ${company.fax} </#if>',
description: "Alle Ansprechpartner anzeigen"
}
]
}
}
});
// fill initial content (using wiki text format and an optional error object)
editor.setWikiText(wikiText, error);
// get edited text value
console.log(editor.getWikiText());
</script>
<!-- ... -->
let config = {
id: "edit1", // id of the element in html <dr-wedit id="..."></dr-wedit>
toolbarButtons: ["code", "charStyles", "paragraph", "lists", "paragraphStyles"], // options available in the global toolbar
utilButtons: ["fullscreen", "sidebar"], // options available in the utility toolbar
sidebar: { // if there is a sidebar available fill it here
tags: {
title: "Tags", // button title
content: [
{
headline: "Firma", // section headline
tags: [
{tag: "content.name1", description: "Firmenname"}, // list of vailable tags which are inserted using '${tag}'
]
}
]
},
templates: {
title: "Templates", // button title
content: [ // list of code template contents
{
// code template with newlines, etc
code: '<#if company.hasEmail()>E: ${company.email} </#if>\n'+
'<#if company.hasPhone()>T: ${company.phone} </#if>\n'+
'<#if company.hasFax()>F: ${company.fax} </#if>',
description: "Alle <strong>Ansprechpartner</strong> anzeigen" // title for this template
}
]
}
}
}
let error = {
lineFrom: 10, // start line number (starting from 1) of the error message block
lineTo: 14, // end line number of the error message block
message: "What a cool error there is inside" // error message to display on top
}
Set wiki Text content and optional error definition
Get current version of xwiki formatted content
Update sidebar tag list with new json sidebar.tags.content list
Update sidebar template list with new json sidebar.templates.content list
Update content to show proper syntax highlighting
Scrolls the error in view if there is any
Focus the editor
Switch to raw code edit mode
Switch to WYSIWYG editor
Switch editor to fullscreen mode
Switch editor out of fullscreen mode
Show sidebar
Hide sidebar