Skip to content

Commit 9939c75

Browse files
committed
fmt
1 parent a07ddc1 commit 9939c75

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

examples/rich-text-editor/rich_text_editor.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ function traverseMdastNode(node, delta, attributes = {}) {
229229
for (const child of node.children || []) {
230230
traverseMdastNode(child, delta, listItemChildrenAttributes);
231231
}
232-
232+
233233
// Attributes for the listItem's newline (e.g., { list: 'bullet', blockquote: true })
234234
// are in `attributes` passed to this `listItem` case.
235235
{
236236
const lastOp = delta.ops[delta.ops.length - 1];
237237
if (lastOp && lastOp.insert === "\n") {
238-
lastOp.attributes = { ...lastOp.attributes, ...attributes };
238+
lastOp.attributes = { ...lastOp.attributes, ...attributes };
239239
} else {
240240
delta.ops.push({ insert: "\n", attributes });
241241
}
@@ -249,18 +249,20 @@ function traverseMdastNode(node, delta, attributes = {}) {
249249
}
250250
break;
251251

252-
case "code": { // mdast 'code' is a block
252+
case "code": {
253+
// mdast 'code' is a block
253254
const codeBlockLineFormat = { "code-block": node.lang || true };
254255
if (attributes.blockquote) {
255256
codeBlockLineFormat.blockquote = true;
256257
}
257258

258259
const textInCodeAttributes = {};
259-
if (attributes.blockquote) { // Text lines also get blockquote if active
260+
if (attributes.blockquote) {
261+
// Text lines also get blockquote if active
260262
textInCodeAttributes.blockquote = true;
261263
}
262264

263-
const lines = (node.value || "").split('\n');
265+
const lines = (node.value || "").split("\n");
264266
for (const lineText of lines) {
265267
delta.ops.push({ insert: lineText, attributes: textInCodeAttributes });
266268
delta.ops.push({ insert: "\n", attributes: codeBlockLineFormat });
@@ -269,7 +271,10 @@ function traverseMdastNode(node, delta, attributes = {}) {
269271
}
270272

271273
case "inlineCode":
272-
delta.ops.push({ insert: node.value || "", attributes: { ...attributes, code: true } });
274+
delta.ops.push({
275+
insert: node.value || "",
276+
attributes: { ...attributes, code: true },
277+
});
273278
break;
274279

275280
default:
@@ -302,7 +307,9 @@ function updateTextareaOnSubmit(form, textarea, quill) {
302307
const delta = quill.getContents();
303308
const markdownContent = deltaToMarkdown(delta);
304309
textarea.value = markdownContent;
305-
console.log(`${textarea.name}:\n${markdownContent}\ntransformed from delta:\n${JSON.stringify(delta, null, 2)}`);
310+
console.log(
311+
`${textarea.name}:\n${markdownContent}\ntransformed from delta:\n${JSON.stringify(delta, null, 2)}`,
312+
);
306313
if (textarea.required && !markdownContent) {
307314
textarea.setCustomValidity(`${textarea.name} cannot be empty`);
308315
quill.once("text-change", (delta) => {
@@ -456,7 +463,13 @@ function deltaToMdast(delta) {
456463
}
457464

458465
// Process line break
459-
currentList = processLineBreak(mdast, currentParagraph, attributes, textBuffer, currentList);
466+
currentList = processLineBreak(
467+
mdast,
468+
currentParagraph,
469+
attributes,
470+
textBuffer,
471+
currentList,
472+
);
460473

461474
currentParagraph = null;
462475
textBuffer = "";

0 commit comments

Comments
 (0)