@inshapardaz/likhari-converters 0.1.13-dev.112 → 0.1.14-dev.115

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
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/html/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiCjD,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlD;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvD;AAiRD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,qBAAqB,CAMvF"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/html/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiCjD,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlD;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvD;AA6RD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,qBAAqB,CAMvF"}
@@ -237,6 +237,16 @@ function convertTable(el) {
237
237
  });
238
238
  return elementBase('table', rows);
239
239
  }
240
+ function convertLayout(container) {
241
+ const items = Array.from(container.children)
242
+ .filter((child) => child.hasAttribute('data-likhari-layout-item'))
243
+ .map((item) => {
244
+ const children = flowBlocks(item);
245
+ return elementBase('layout-item', children.length > 0 ? children : [paragraph()]);
246
+ });
247
+ const templateColumns = container.style.gridTemplateColumns || `repeat(${Math.max(items.length, 2)}, 1fr)`;
248
+ return elementBase('layout-container', items.length > 0 ? items : [elementBase('layout-item', [paragraph()])], { templateColumns });
249
+ }
240
250
  function convertImage(img, caption) {
241
251
  const src = safeImageSrc(img.getAttribute('src') ?? '');
242
252
  if (!src)
@@ -305,6 +315,8 @@ function convertBlock(el) {
305
315
  case 'div':
306
316
  if (el.hasAttribute('data-likhari-page-break'))
307
317
  return [{ type: 'page-break', version: 1 }];
318
+ if (el.hasAttribute('data-likhari-layout-container'))
319
+ return [convertLayout(el)];
308
320
  return flowBlocks(el);
309
321
  case 'figcaption':
310
322
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/html/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAE4E,KAAK,KAAK,EAC5F,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAgGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAuCtE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAE1F"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/html/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAE4E,KAAK,KAAK,EAC5F,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAyGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAyCtE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAE1F"}
@@ -87,6 +87,14 @@ function tableToHtml(node, ctx) {
87
87
  .join('');
88
88
  return `<table><tbody>${rows}</tbody></table>`;
89
89
  }
90
+ function layoutToHtml(node, ctx) {
91
+ const items = node.children ?? [];
92
+ const templateColumns = typeof node.templateColumns === 'string' ? node.templateColumns : `repeat(${items.length}, 1fr)`;
93
+ const columns = items
94
+ .map((item) => `<div data-likhari-layout-item>${(item.children ?? []).map((child) => nodeToHtml(child, ctx)).join('')}</div>`)
95
+ .join('');
96
+ return `<div data-likhari-layout-container style="display: grid; grid-template-columns: ${escapeAttr(templateColumns)}">${columns}</div>`;
97
+ }
90
98
  function imageToHtml(node, ctx) {
91
99
  const rawSrc = String(node.src ?? '');
92
100
  const src = ctx?.resolveImageUrl ? ctx.resolveImageUrl(rawSrc) : rawSrc;
@@ -133,6 +141,8 @@ export function nodeToHtml(node, ctx) {
133
141
  return imageToHtml(node, ctx);
134
142
  case 'table':
135
143
  return tableToHtml(node, ctx);
144
+ case 'layout-container':
145
+ return layoutToHtml(node, ctx);
136
146
  default:
137
147
  // Unknown node (e.g. a future feature): keep its content, drop the wrapper.
138
148
  return inlineChildren(node, ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/markdown/parse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoRjD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,qBAAqB,CAI3F"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/markdown/parse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiSjD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,qBAAqB,CAI3F"}
@@ -223,8 +223,22 @@ function blocks(nodes, extra = {}) {
223
223
  out.push(tableBlock(node));
224
224
  break;
225
225
  case 'containerDirective':
226
- // Unknown containers are transparent: their content is kept.
227
- out.push(...blocks(node.children ?? [], node.name === 'para' ? blockExtras(node.attributes ?? {}) : extra));
226
+ if (node.name === 'columns') {
227
+ const columns = (node.children ?? [])
228
+ .filter((c) => c.type === 'containerDirective' && c.name === 'column')
229
+ .map((c) => {
230
+ const children = blocks(c.children ?? []);
231
+ return elementBase('layout-item', children.length > 0 ? children : [paragraph()]);
232
+ });
233
+ if (columns.length > 0) {
234
+ out.push(elementBase('layout-container', columns, { templateColumns: `repeat(${columns.length}, 1fr)` }));
235
+ }
236
+ }
237
+ else {
238
+ // Unknown containers (including a stray "column" outside "columns")
239
+ // are transparent: their content is kept.
240
+ out.push(...blocks(node.children ?? [], node.name === 'para' ? blockExtras(node.attributes ?? {}) : extra));
241
+ }
228
242
  break;
229
243
  case 'leafDirective': {
230
244
  if (node.name === 'pagebreak')
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/markdown/serialize.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAKjD,OAAO,EAAa,KAAK,KAAK,EAAe,MAAM,SAAS,CAAC;AAyC7D,2GAA2G;AAC3G,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAUjD;AAiHD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAMhE;AA4GD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAI9F"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/markdown/serialize.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAKjD,OAAO,EAAa,KAAK,KAAK,EAAe,MAAM,SAAS,CAAC;AAyC7D,2GAA2G;AAC3G,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAUjD;AAiHD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAMhE;AAoHD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAI9F"}
@@ -236,6 +236,11 @@ function imageToMd(node, ctx) {
236
236
  attrs.height = String(node.height);
237
237
  return directive('leafDirective', 'figure', attrs, caption ? [{ type: 'text', value: caption }] : []);
238
238
  }
239
+ function layoutToMd(node, ctx) {
240
+ const items = node.children ?? [];
241
+ const columns = items.map((item) => directive('containerDirective', 'column', {}, (item.children ?? []).flatMap((child) => blockToMd(child, ctx))));
242
+ return directive('containerDirective', 'columns', { count: String(items.length) }, columns);
243
+ }
239
244
  function tableToMd(node, ctx) {
240
245
  const rows = (node.children ?? []).map((row) => ({
241
246
  type: 'tableRow',
@@ -277,6 +282,8 @@ function blockToMd(node, ctx) {
277
282
  return [imageToMd(node, ctx)];
278
283
  case 'table':
279
284
  return [tableToMd(node, ctx)];
285
+ case 'layout-container':
286
+ return [layoutToMd(node, ctx)];
280
287
  default:
281
288
  // Fallback rule (dialect spec §6): unknown blocks keep their text as paragraphs.
282
289
  return (node.children ?? []).flatMap((child) => blockToMd(child, ctx));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inshapardaz/likhari-converters",
3
- "version": "0.1.13-dev.112",
3
+ "version": "0.1.14-dev.115",
4
4
  "description": "Format transformers (Markdown/HTML/plain-text/Lexical JSON) against the canonical Lexical EditorState, isolated from UI.",
5
5
  "license": "MIT",
6
6
  "repository": {