@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.
@@ -1 +1 @@
1
- automerge:4EhwfShT9ybL5Tf1rEc7dfNB97Gx
1
+ automerge:39oLVgHTE2neTRTvB1oXhSurUPct
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork-pkg-base",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "type": "module",
5
5
  "description": "Base packages for the Patchwork system",
6
6
  "repository": {
@@ -29,7 +29,7 @@ var MarkdownDatatype = {
29
29
  updateText(
30
30
  doc,
31
31
  ["content"],
32
- doc.content.replace(/^#\s+(.*)/gm, () => `# ${title}`)
32
+ doc.content.replace(/^#\s+(.*)/m, () => `# ${title}`)
33
33
  );
34
34
  } else {
35
35
  if (hasFrontmatter) return;
@@ -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+(.*)/gm, () => `# ${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;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,eAAe,MAAM,KAAK,KAAK,EAAE;AAAA,MACvD;AAAA,IACF,OAAO;AAEL,UAAI,eAAgB;AACpB;AAAA,QACE;AAAA,QACA,CAAC,SAAS;AAAA,QACT,IAAI,UAAU,KAAK,KAAK;AAAA,IAAO,IAAI;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACF;",
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;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,cAAc,MAAM,KAAK,KAAK,EAAE;AAAA,MACtD;AAAA,IACF,OAAO;AAEL,UAAI,eAAgB;AACpB;AAAA,QACE;AAAA,QACA,CAAC,SAAS;AAAA,QACT,IAAI,UAAU,KAAK,KAAK;AAAA,IAAO,IAAI;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- automerge:3wYm7sKeEYA5M1kJ8SiwBEmzUB9a
1
+ automerge:32XipTKTijNpX1EGG7R7wnz3dRDE