Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit a163bb5

Browse files
Goamandmo-odoo
authored andcommitted
[FIX] demo: make odoo field work again
1 parent c4fa964 commit a163bb5

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1+
import { Parser } from './../../packages/plugin-parser/src/Parser';
12
import { BasicEditor } from '../../packages/bundle-basic-editor/BasicEditor';
23
import { FontAwesome } from '../../packages/plugin-fontawesome/src/FontAwesome';
34
import { DevTools } from '../../packages/plugin-devtools/src/DevTools';
45
import template from './demo-odoo-fields.xml';
56
import './demo-odoo-fields.css';
6-
import { Toolbar } from '../../packages/plugin-toolbar/src/Toolbar';
77
import { DomLayout } from '../../packages/plugin-dom-layout/src/DomLayout';
8+
import { JWEditorConfig, Loadables } from '../../packages/core/src/JWEditor';
9+
import { Layout } from '../../packages/plugin-layout/src/Layout';
10+
import { VNode } from '../../packages/core/src/VNodes/VNode';
11+
import JWEditor from '../../packages/core/src/JWEditor';
812

13+
import layout from './layout.xml';
914
import '../utils/fontawesomeAssets';
1015

1116
const target = document.getElementById('contentToEdit');
1217
target.style.paddingTop = '40px';
1318
target.style.paddingLeft = '8px';
1419
target.innerHTML = template;
1520

16-
const editor = new BasicEditor();
21+
const editor = new BasicEditor({ editable: target });
1722
editor.load(FontAwesome);
1823
editor.load(DevTools);
1924
editor.configure(DomLayout, {
2025
location: [target, 'replace'],
2126
});
22-
editor.configure(Toolbar, {
23-
layout: [
24-
[
25-
[
26-
'ParagraphButton',
27-
'Heading1Button',
28-
'Heading2Button',
29-
'Heading3Button',
30-
'Heading4Button',
31-
'Heading5Button',
32-
'Heading6Button',
33-
'PreButton',
34-
],
27+
const config: JWEditorConfig & { loadables: Loadables<Layout> } = {
28+
loadables: {
29+
components: [
30+
{
31+
id: 'editor',
32+
render(editor: JWEditor): Promise<VNode[]> {
33+
return editor.plugins.get(Parser).parse('text/html', layout);
34+
},
35+
},
3536
],
36-
['BoldButton', 'ItalicButton', 'UnderlineButton'],
37-
['AlignLeftButton', 'AlignCenterButton', 'AlignRightButton', 'AlignJustifyButton'],
38-
['OrderedListButton', 'UnorderedListButton'],
39-
['IndentButton', 'OutdentButton'],
40-
],
41-
});
37+
componentZones: [['editor', ['root']]],
38+
},
39+
};
40+
editor.configure(config);
4241

4342
editor.start();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<jw-editor>
2+
<t-range><t t-zone="tools"/></t-range>
3+
<jw-header><t t-zone="tools"/></jw-header>
4+
<jw-body><t t-zone="main"/></jw-body>
5+
<jw-footer>
6+
<t t-zone="status"/>
7+
</jw-footer>
8+
<t-dialog>
9+
<t t-zone="dialog"/>
10+
<t t-zone="default"/>
11+
</t-dialog>
12+
<t t-zone="debug"/>
13+
</jw-editor>

0 commit comments

Comments
 (0)