@inkandswitch/patchwork-pkg-base 0.0.97 → 0.0.98
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.
package/module-settings-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:39oLVgHTE2neTRTvB1oXhSurUPct
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/datatype.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DatatypeImplementation } from \"@inkandswitch/patchwork-plugins\";\nimport { updateText } from \"@automerge/automerge/slim\";\n\nexport type MarkdownDoc = {\n content: string;\n};\n\nconst frontmatterRegex = /---\\n([\\s\\S]+?)\\n---/;\n\nexport const MarkdownDatatype: DatatypeImplementation<MarkdownDoc> = {\n init(doc: MarkdownDoc) {\n doc.content = \"# Untitled\";\n },\n getTitle(doc: MarkdownDoc) {\n const content = doc.content;\n\n const frontmatterMatch = content.match(frontmatterRegex);\n const frontmatter = frontmatterMatch ? frontmatterMatch[1] : \"\";\n\n const titleRegex = /title:\\s\"(.+?)\"/;\n const subtitleRegex = /subtitle:\\s\"(.+?)\"/;\n\n const titleMatch = frontmatter.match(titleRegex);\n const subtitleMatch = frontmatter.match(subtitleRegex);\n\n let title = titleMatch ? titleMatch[1] : null;\n const subtitle = subtitleMatch ? subtitleMatch[1] : \"\";\n\n // If title not found in frontmatter, find first markdown heading\n if (!title) {\n const titleFallbackRegex = /(^|\\n)#\\s(.+)/;\n const titleFallbackMatch = content.match(titleFallbackRegex);\n title = titleFallbackMatch ? titleFallbackMatch[2] : \"Untitled\";\n }\n\n return `${title}${subtitle && `: ${subtitle}`}`;\n },\n setTitle(doc: MarkdownDoc, title: string) {\n const hasTitle = doc.content.match(/^#\\s/gm);\n const hasFrontmatter = frontmatterRegex.exec(doc.content);\n\n if (hasTitle) {\n updateText(\n doc,\n [\"content\"],\n doc.content.replace(/^#\\s+(.*)/
|
|
5
|
-
"mappings": ";AACA,SAAS,kBAAkB;AAM3B,IAAM,mBAAmB;AAElB,IAAM,mBAAwD;AAAA,EACnE,KAAK,KAAkB;AACrB,QAAI,UAAU;AAAA,EAChB;AAAA,EACA,SAAS,KAAkB;AACzB,UAAM,UAAU,IAAI;AAEpB,UAAM,mBAAmB,QAAQ,MAAM,gBAAgB;AACvD,UAAM,cAAc,mBAAmB,iBAAiB,CAAC,IAAI;AAE7D,UAAM,aAAa;AACnB,UAAM,gBAAgB;AAEtB,UAAM,aAAa,YAAY,MAAM,UAAU;AAC/C,UAAM,gBAAgB,YAAY,MAAM,aAAa;AAErD,QAAI,QAAQ,aAAa,WAAW,CAAC,IAAI;AACzC,UAAM,WAAW,gBAAgB,cAAc,CAAC,IAAI;AAGpD,QAAI,CAAC,OAAO;AACV,YAAM,qBAAqB;AAC3B,YAAM,qBAAqB,QAAQ,MAAM,kBAAkB;AAC3D,cAAQ,qBAAqB,mBAAmB,CAAC,IAAI;AAAA,IACvD;AAEA,WAAO,GAAG,KAAK,GAAG,YAAY,KAAK,QAAQ,EAAE;AAAA,EAC/C;AAAA,EACA,SAAS,KAAkB,OAAe;AACxC,UAAM,WAAW,IAAI,QAAQ,MAAM,QAAQ;AAC3C,UAAM,iBAAiB,iBAAiB,KAAK,IAAI,OAAO;AAExD,QAAI,UAAU;AACZ;AAAA,QACE;AAAA,QACA,CAAC,SAAS;AAAA,QACV,IAAI,QAAQ,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { type DatatypeImplementation } from \"@inkandswitch/patchwork-plugins\";\nimport { updateText } from \"@automerge/automerge/slim\";\n\nexport type MarkdownDoc = {\n content: string;\n};\n\nconst frontmatterRegex = /---\\n([\\s\\S]+?)\\n---/;\n\nexport const MarkdownDatatype: DatatypeImplementation<MarkdownDoc> = {\n init(doc: MarkdownDoc) {\n doc.content = \"# Untitled\";\n },\n getTitle(doc: MarkdownDoc) {\n const content = doc.content;\n\n const frontmatterMatch = content.match(frontmatterRegex);\n const frontmatter = frontmatterMatch ? frontmatterMatch[1] : \"\";\n\n const titleRegex = /title:\\s\"(.+?)\"/;\n const subtitleRegex = /subtitle:\\s\"(.+?)\"/;\n\n const titleMatch = frontmatter.match(titleRegex);\n const subtitleMatch = frontmatter.match(subtitleRegex);\n\n let title = titleMatch ? titleMatch[1] : null;\n const subtitle = subtitleMatch ? subtitleMatch[1] : \"\";\n\n // If title not found in frontmatter, find first markdown heading\n if (!title) {\n const titleFallbackRegex = /(^|\\n)#\\s(.+)/;\n const titleFallbackMatch = content.match(titleFallbackRegex);\n title = titleFallbackMatch ? titleFallbackMatch[2] : \"Untitled\";\n }\n\n return `${title}${subtitle && `: ${subtitle}`}`;\n },\n setTitle(doc: MarkdownDoc, title: string) {\n const hasTitle = doc.content.match(/^#\\s/gm);\n const hasFrontmatter = frontmatterRegex.exec(doc.content);\n\n if (hasTitle) {\n updateText(\n doc,\n [\"content\"],\n doc.content.replace(/^#\\s+(.*)/m, () => `# ${title}`)\n );\n } else {\n // todo\n if (hasFrontmatter) return;\n updateText(\n doc,\n [\"content\"],\n (doc.content = `# ${title}\\n` + doc.content)\n );\n }\n },\n};\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,kBAAkB;AAM3B,IAAM,mBAAmB;AAElB,IAAM,mBAAwD;AAAA,EACnE,KAAK,KAAkB;AACrB,QAAI,UAAU;AAAA,EAChB;AAAA,EACA,SAAS,KAAkB;AACzB,UAAM,UAAU,IAAI;AAEpB,UAAM,mBAAmB,QAAQ,MAAM,gBAAgB;AACvD,UAAM,cAAc,mBAAmB,iBAAiB,CAAC,IAAI;AAE7D,UAAM,aAAa;AACnB,UAAM,gBAAgB;AAEtB,UAAM,aAAa,YAAY,MAAM,UAAU;AAC/C,UAAM,gBAAgB,YAAY,MAAM,aAAa;AAErD,QAAI,QAAQ,aAAa,WAAW,CAAC,IAAI;AACzC,UAAM,WAAW,gBAAgB,cAAc,CAAC,IAAI;AAG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