inkpen 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/inkpen/controllers/editor_controller.js +1 -0
- data/app/assets/javascripts/inkpen/export/markdown.js +42 -6
- data/app/assets/javascripts/inkpen.bundle.js +106 -103
- data/app/assets/javascripts/inkpen.bundle.js.map +3 -3
- data/docs/CHANGELOG.md +8 -0
- data/lib/inkpen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92089e260ac3068e3e269e864d4ec9f0294447bbb4e28764f02f5c722debc155
|
|
4
|
+
data.tar.gz: 1b824dd56c5ccd3f1c448cf841ea53db2660617f14a6b4fe5a41ee9b20f15f7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d6ceb94d0867ab0b0a5194f6a1468454c1ef8b6782b94cd62ce469a15667ca04ad3c764681130c1e148cc823ef0b8cdd770a0822a01ffb402be632300869ce0
|
|
7
|
+
data.tar.gz: 9420e9694ce248bec30176e60e26a3521749a1e7b5463ba14423a58b87df6b18b40a82b82ff5ab9aa1f9146637f8330e32f1abb309744ca89d09346deaa28e89
|
|
@@ -200,6 +200,7 @@ const EXTENSION_LOADERS = {
|
|
|
200
200
|
// surface. Not part of the public gem API; the controller is the only
|
|
201
201
|
// production consumer.
|
|
202
202
|
export const __EXTENSION_LOADER_NAMES__ = Object.keys(EXTENSION_LOADERS)
|
|
203
|
+
export const __loadEditorModulesForTest = loadEditorModules
|
|
203
204
|
|
|
204
205
|
async function loadEditorModules(enabledExtensions = []) {
|
|
205
206
|
const enabledSet = new Set(enabledExtensions)
|
|
@@ -291,11 +291,11 @@ function serializeInlineContent(node) {
|
|
|
291
291
|
const iterate = (items) => {
|
|
292
292
|
if (Array.isArray(items)) {
|
|
293
293
|
for (const item of items) {
|
|
294
|
-
result +=
|
|
294
|
+
result += serializeInlineNode(item)
|
|
295
295
|
}
|
|
296
296
|
} else if (typeof items.forEach === "function") {
|
|
297
297
|
items.forEach(item => {
|
|
298
|
-
result +=
|
|
298
|
+
result += serializeInlineNode(item)
|
|
299
299
|
})
|
|
300
300
|
}
|
|
301
301
|
}
|
|
@@ -304,6 +304,16 @@ function serializeInlineContent(node) {
|
|
|
304
304
|
return result
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
function serializeInlineNode(node) {
|
|
308
|
+
if (!node) return ""
|
|
309
|
+
|
|
310
|
+
const type = node.type?.name || node.type
|
|
311
|
+
if (type === "text") return serializeTextWithMarks(node)
|
|
312
|
+
if (type === "hardBreak") return "\n"
|
|
313
|
+
|
|
314
|
+
return serializeNode(node).trim()
|
|
315
|
+
}
|
|
316
|
+
|
|
307
317
|
/**
|
|
308
318
|
* Serialize text node with marks
|
|
309
319
|
*/
|
|
@@ -316,8 +326,24 @@ function serializeTextWithMarks(node) {
|
|
|
316
326
|
return text
|
|
317
327
|
}
|
|
318
328
|
|
|
319
|
-
|
|
320
|
-
|
|
329
|
+
const markName = mark => mark.type?.name || mark.type
|
|
330
|
+
const hasBold = node.marks.some(mark => ["bold", "strong"].includes(markName(mark)))
|
|
331
|
+
const hasItalic = node.marks.some(mark => ["italic", "em"].includes(markName(mark)))
|
|
332
|
+
|
|
333
|
+
if (hasBold && hasItalic) {
|
|
334
|
+
text = `***${text}***`
|
|
335
|
+
} else if (hasBold) {
|
|
336
|
+
text = MARK_SERIALIZERS.bold(text)
|
|
337
|
+
} else if (hasItalic) {
|
|
338
|
+
text = MARK_SERIALIZERS.italic(text)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const remainingMarks = node.marks.filter(mark => {
|
|
342
|
+
const name = markName(mark)
|
|
343
|
+
return !["bold", "strong", "italic", "em"].includes(name)
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
for (const mark of remainingMarks) {
|
|
321
347
|
const serializer = MARK_SERIALIZERS[mark.type?.name || mark.type]
|
|
322
348
|
if (serializer) {
|
|
323
349
|
text = serializer(text, mark)
|
|
@@ -425,7 +451,8 @@ function serializeBlockquote(node, options) {
|
|
|
425
451
|
*/
|
|
426
452
|
function serializeCodeBlock(node) {
|
|
427
453
|
const language = node.attrs?.language || ""
|
|
428
|
-
|
|
454
|
+
const content = (node.textContent || "").replace(/\n$/, "")
|
|
455
|
+
return "```" + language + "\n" + content + "\n```"
|
|
429
456
|
}
|
|
430
457
|
|
|
431
458
|
/**
|
|
@@ -470,7 +497,7 @@ function serializeTable(node, options) {
|
|
|
470
497
|
const rowChildren = row.content?.content || row.content || []
|
|
471
498
|
|
|
472
499
|
iterate(rowChildren, (cell, cellIndex) => {
|
|
473
|
-
const content =
|
|
500
|
+
const content = serializeTableCell(cell, options)
|
|
474
501
|
cells.push(content)
|
|
475
502
|
|
|
476
503
|
// Track alignment from first row cells
|
|
@@ -500,6 +527,15 @@ function serializeTable(node, options) {
|
|
|
500
527
|
return rows.join("\n") + "\n"
|
|
501
528
|
}
|
|
502
529
|
|
|
530
|
+
function serializeTableCell(cell, options) {
|
|
531
|
+
const content = serializeChildren(cell, options)
|
|
532
|
+
.trim()
|
|
533
|
+
.replace(/\n+/g, "<br>")
|
|
534
|
+
.replace(/\s*\|\s*/g, "\\|")
|
|
535
|
+
|
|
536
|
+
return content || " "
|
|
537
|
+
}
|
|
538
|
+
|
|
503
539
|
/**
|
|
504
540
|
* Serialize callout to GFM-style alert
|
|
505
541
|
*/
|