Skip to content

Commit f6365f1

Browse files
committed
DOC-3174: Update interactive demos and examples for revisionhistory
1 parent b05d7dd commit f6365f1

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

modules/ROOT/examples/live-demos/revisionhistory/index.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ const getRandomDelay = () => {
44
return Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
55
};
66

7+
const userDirectory = {
8+
'john.doe': {
9+
id: 'john.doe',
10+
name: 'John Doe',
11+
avatar: 'https://example.com/avatar/john.png'
12+
}
13+
};
14+
715
const lightRevisions = [
816
{
917
revisionId: '3',
@@ -202,9 +210,17 @@ tinymce.init({
202210
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
203211
revisionhistory_fetch,
204212
revisionhistory_fetch_revision,
205-
revisionhistory_author: {
206-
id: 'john.doe',
207-
name: 'John Doe'
213+
user_id: 'john.doe',
214+
fetch_users: (userIds) => {
215+
const results = userIds.map((id) => {
216+
const user = Object.values(userDirectory).find((user) => user.id === id);
217+
if (user) {
218+
return user;
219+
} else {
220+
throw new Error(`User ${id} not found`);
221+
}
222+
});
223+
return Promise.resolve(results);
208224
},
209225
revisionhistory_display_author: true
210226
});

modules/ROOT/partials/configuration/revisionhistory_fetch_revision.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ tinymce.init({
6565
toolbar: 'revisionhistory',
6666
revisionhistory_fetch: () => Promise.resolve(lightRevisions),
6767
revisionhistory_fetch_revision: (_editor, revision) => new Promise((resolve) => {
68-
let newRevision = null;
69-
for (let i = 0; i < revisions.length; i++) {
70-
const temp = revisions[i];
71-
if (temp.revisionId === revision.revisionId) {
72-
newRevision = temp;
73-
break;
68+
let newRevision = null;
69+
for (let i = 0; i < revisions.length; i++) {
70+
const temp = revisions[i];
71+
if (temp.revisionId === revision.revisionId) {
72+
newRevision = temp;
73+
break;
74+
}
7475
}
75-
}
76-
resolve(newRevision);
76+
resolve(newRevision);
7777
})
7878
});
7979
----

0 commit comments

Comments
 (0)