Skip to content

Commit e978936

Browse files
author
Sorita Heng
committed
Update interactive demo
1 parent c93b4a3 commit e978936

File tree

3 files changed

+430
-20
lines changed

3 files changed

+430
-20
lines changed
Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
1+
/** Fake user database */
2+
const userDb = {
3+
adamhenderson: {
4+
id: 'adamhenderson',
5+
name: 'Adam Henderson',
6+
avatar: `https://randomuser.me/api/portraits/men/1.jpg`,
7+
},
8+
michaelcook: {
9+
id: 'michaelcook',
10+
name: 'Michael Cook',
11+
avatar: `https://randomuser.me/api/portraits/men/2.jpg`,
12+
},
13+
kalebwilson: {
14+
id: 'kalebwilson',
15+
name: 'Kaleb Wilson',
16+
avatar: `https://randomuser.me/api/portraits/men/3.jpg`,
17+
},
18+
kyleeinstein: {
19+
id: 'kyleeinstein',
20+
name: 'Kyle Einstein',
21+
avatar: `https://randomuser.me/api/portraits/men/4.jpg`,
22+
},
23+
};
24+
25+
const suggestededits_model = null; //Replace with the object returned by the plugin's getModel API, or null if there is no model.
26+
27+
const fetch_users = (ids) => {
28+
return new Promise((resolve, reject) => {
29+
const users = ids.map(id => userDb[id]);
30+
if (users.length > 0) {
31+
resolve(users);
32+
} else {
33+
reject(new Error('No users found'));
34+
}
35+
});
36+
}
137

238
tinymce.init({
3-
selector: 'textarea#trackchanges',
4-
height: 500,
5-
plugins: 'trackchanges',
6-
toolbar: 'trackchanges',
7-
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
8-
trackchanges_uid: 'adamhenderson',
9-
});
39+
selector: 'textarea#suggested-edits',
40+
height: 500,
41+
plugins: 'suggestededits',
42+
toolbar: 'suggestededits',
43+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
44+
suggestededits_model, // If there is no model, the plugin will generate a default model based on the editor content.
45+
user_id: 'michaelcook',
46+
fetch_users,
47+
});
48+

modules/ROOT/examples/live-demos/suggestededits/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<textarea id="trackchanges">
1+
<textarea id="suggested-edits">
22
{{logofordemoshtml}}
33

44
<h2 style="text-align: center;">Welcome to the TinyMCE Suggested Edits demo!</h2>

0 commit comments

Comments
 (0)