Skip to content

Commit 5cc57fc

Browse files
committed
fix(editor): spelling and organization changes
1 parent e5a84ac commit 5cc57fc

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

docs-site/src/pages/pattern-lab/_patterns/06-experiments/editor/00-editor-docs.twig

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,3 @@
1818
<ul>
1919
<li><a href="{{ link['experiments-drupal-integration'] }}">Docs on Drupal Integration</a></li>
2020
</ul>
21-
22-
<h3>Handlling editor save</h3>
23-
<p>Assign a function to <code>window.__handleEditorSave</code> that will run the Drupal Save process
24-
and resolve with an object of <code>{ok: true/false, message: "Error: could not...." }</code>.</p>
25-
<p>Note that we are not returning an error/reject, merely a <code>{ok: false}</code> if the Drupal axios
26-
request fails. The included message will be displayed as an alert.
27-
28-
<p>Here is the example handler, which should be overwritten on the window. The <code>shouldThisFailDemo</code> var is togglable
29-
to simulate both events. The <code>setTimeout()</code> is only necessary for simulating async, the production functionshould not include this.
30-
</p>
31-
32-
<p>
33-
<code>
34-
function exampleHandleEditorSave({ html, id }) {
35-
const shouldThisFailToDemo = false;
36-
37-
//TODO: Drupal Axios code likely here
38-
return new Promise((resolve, reject) => {
39-
// faking async delay
40-
setTimeout(() => {
41-
if (shouldThisFailToDemo) {
42-
console.log('exampleHandleEditorSave failed');
43-
resolve({
44-
ok: false,
45-
message: 'This is a demonstration of how to fail the save'
46-
});
47-
} else {
48-
console.log('exampleHandleEditorSave ok!');
49-
resolve({
50-
ok: true,
51-
message: 'Saved ok!',
52-
});
53-
}
54-
}, 2000);
55-
})
56-
}
57-
</code>

docs-site/src/pages/pattern-lab/_patterns/06-experiments/editor/misc/-05-drupal-integration.twig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,39 @@ document.querySelectorAll('.js-pega-editor').forEach((pegaEditor) => {
5656
});
5757
});
5858
</bolt-code-snippet>
59+
60+
61+
<h3>Handling editor save</h3>
62+
<p>Assign a function to <code>window.__handleEditorSave</code> that will run the Drupal Save process
63+
and resolve with an object of <code>{ok: true/false, message: "Error: could not...." }</code>.</p>
64+
<p>Note that we are not returning an error/reject, merely a <code>{ok: false}</code> if the Drupal http
65+
request fails. The included message will be displayed as an alert.
66+
67+
<p>Below is the example handler, which should be over-written on the window. The <code>shouldThisFailDemo</code> var is toggleable
68+
to simulate both events. The <code>setTimeout()</code> is only necessary for simulating async, the production function should not include this.
69+
</p>
70+
71+
<p>
72+
<bolt-code-snippet lang="js" syntax="dark">
73+
//@TODO: actual Drupal http request code
74+
window.__handleEditorSave = () => {
75+
return new Promise((resolve, reject) => {
76+
// faking async delay
77+
setTimeout(() => {
78+
if (shouldThisFailToDemo) {
79+
console.log('exampleHandleEditorSave failed');
80+
resolve({
81+
ok: false,
82+
message: 'This is a demonstration of how to fail the save'
83+
});
84+
} else {
85+
console.log('exampleHandleEditorSave ok!');
86+
resolve({
87+
ok: true,
88+
message: 'Saved ok!',
89+
});
90+
}
91+
}, 2000);
92+
})
93+
}
94+
</bolt-code-snippet>

0 commit comments

Comments
 (0)