alinea 0.11.0 → 0.11.1

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.
@@ -106,6 +106,11 @@ export declare function createExample(): import("alinea/core/CMS").CMS<{
106
106
  path: import("alinea/field/path").PathField;
107
107
  name: import("alinea/field/text").TextField;
108
108
  }, Record<string, any>>;
109
+ container1: import("alinea/core/Page").PageSeed<{
110
+ title: import("alinea/field/text").TextField;
111
+ path: import("alinea/field/path").PathField;
112
+ name: import("alinea/field/text").TextField;
113
+ }, Record<string, any>>;
109
114
  }>;
110
115
  multiLanguage: import("alinea/core/Root").Root<{
111
116
  localised1: import("alinea/core/Page").PageSeed<{
@@ -175,7 +175,8 @@ function createExample() {
175
175
  entry1: page(Page({ title: "Test title" })),
176
176
  entry2: page(Container({ title: "Entry 2" }), {
177
177
  entry3: page(Page({ title: "Entry 3" }))
178
- })
178
+ }),
179
+ container1: page(Container({ title: "Container 1" }))
179
180
  }
180
181
  }),
181
182
  multiLanguage: root("Multi language", {
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.11.0",
5
+ version: "0.11.1",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VGTUJMNI.js";
3
+ } from "../chunks/chunk-Y4XBLUGH.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VGTUJMNI.js";
3
+ } from "../chunks/chunk-Y4XBLUGH.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VGTUJMNI.js";
3
+ } from "../chunks/chunk-Y4XBLUGH.js";
4
4
  import {
5
5
  PLazy
6
6
  } from "../chunks/chunk-IKINPSS5.js";
@@ -55,10 +55,10 @@ var GraphRealm = class _GraphRealm {
55
55
  select = select().first();
56
56
  const selection = createSelection(select);
57
57
  serializeSelection(this.#targets, selection);
58
- return this.#resolver.resolve({
58
+ return await this.#resolver.resolve({
59
59
  ...this.#params,
60
60
  selection
61
- });
61
+ }) ?? null;
62
62
  }
63
63
  async get(select) {
64
64
  const result = await this.maybeGet(select);
@@ -21,6 +21,7 @@ import {
21
21
  workspaceMediaDir
22
22
  } from "./util/EntryFilenames.js";
23
23
  import { createEntryRow, entryParentPaths } from "./util/EntryRows.js";
24
+ import { generateKeyBetween } from "./util/FractionalIndexing.js";
24
25
  import { basename, extname, join, normalize } from "./util/Paths.js";
25
26
  import { slugify } from "./util/Slugs.js";
26
27
  var Operation = class _Operation {
@@ -254,7 +255,11 @@ var CreateOperation = class _CreateOperation extends Operation {
254
255
  if (!type)
255
256
  throw new TypeError(`Type is missing`);
256
257
  const parent = await (this.parentRow ? this.parentRow(cms) : partial.parent ? cms.graph.preferPublished.get(Entry({ entryId: partial.parent })) : void 0);
257
- return createEntry(cms.config, type, partial, parent);
258
+ const previousIndex = await cms.graph.preferPublished.maybeGet(
259
+ Entry({ parent: parent?.entryId ?? null }).select(Entry.index).orderBy(Entry.index.desc())
260
+ );
261
+ const index = generateKeyBetween(previousIndex, null);
262
+ return createEntry(cms.config, type, { ...partial, index }, parent);
258
263
  };
259
264
  setParent(parentId) {
260
265
  this.entry.parent = parentId;
@@ -1809,12 +1809,6 @@ function mapNode(name, attributes) {
1809
1809
  return { _type: type, level, content: [] };
1810
1810
  case "p":
1811
1811
  return { _type: "paragraph", content: [] };
1812
- case "b":
1813
- case "strong":
1814
- return { _type: "bold", content: [] };
1815
- case "i":
1816
- case "em":
1817
- return { _type: "italic", content: [] };
1818
1812
  case "ul":
1819
1813
  return { _type: "bulletList", content: [] };
1820
1814
  case "ol":
@@ -1827,10 +1821,6 @@ function mapNode(name, attributes) {
1827
1821
  return { _type: "horizontalRule" };
1828
1822
  case "br":
1829
1823
  return { _type: "hardBreak" };
1830
- case "small":
1831
- return { _type: "small", content: [] };
1832
- case "a":
1833
- return { _type: "link", ...attributes, content: [] };
1834
1824
  case "table":
1835
1825
  return { _type: "table", content: [] };
1836
1826
  case "tbody":
@@ -1843,25 +1833,57 @@ function mapNode(name, attributes) {
1843
1833
  return { _type: "tableRow", content: [] };
1844
1834
  }
1845
1835
  }
1836
+ function mapMark(name, attributes) {
1837
+ switch (name) {
1838
+ case "b":
1839
+ case "strong":
1840
+ return { _type: "bold" };
1841
+ case "i":
1842
+ case "em":
1843
+ return { _type: "italic" };
1844
+ case "u":
1845
+ return { _type: "underline" };
1846
+ case "s":
1847
+ case "strike":
1848
+ return { _type: "strike" };
1849
+ case "a":
1850
+ return { _type: "link", ...attributes };
1851
+ }
1852
+ }
1846
1853
  function parseHTML(html) {
1847
1854
  const doc = [];
1848
1855
  if (typeof html !== "string")
1849
1856
  return doc;
1850
- let parents = [doc];
1857
+ let parents = [
1858
+ { tag: void 0, doc }
1859
+ ];
1860
+ let marks = [];
1851
1861
  const parser = new Parser({
1852
1862
  onopentag(name, attributes) {
1853
1863
  const node = mapNode(name, attributes);
1854
- const parent = parents[parents.length - 1];
1855
- if (node)
1856
- parent?.push(node);
1857
- parents.push(node?.content);
1864
+ const mark = mapMark(name, attributes);
1865
+ const parent = parents.at(-1);
1866
+ if (node) {
1867
+ parent?.doc?.push(node);
1868
+ parents.push({ tag: name, doc: node?.content });
1869
+ } else if (mark) {
1870
+ marks.push(mark);
1871
+ }
1858
1872
  },
1859
1873
  ontext(text) {
1860
- const parent = parents[parents.length - 1];
1861
- parent?.push({ _type: "text", text });
1874
+ const parent = parents.at(-1);
1875
+ const node = { _type: "text", text };
1876
+ if (marks.length)
1877
+ node.marks = marks;
1878
+ parent?.doc?.push(node);
1879
+ marks = [];
1862
1880
  },
1863
- onclosetag() {
1864
- parents.pop();
1881
+ onclosetag(name) {
1882
+ const parent = parents.at(-1);
1883
+ if (parent?.tag === name)
1884
+ parents.pop();
1885
+ else
1886
+ marks.pop();
1865
1887
  }
1866
1888
  });
1867
1889
  parser.write(html);
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-VGTUJMNI.js";
3
+ } from "../../chunks/chunk-Y4XBLUGH.js";
4
4
  import {
5
5
  create as create2
6
6
  } from "../../chunks/chunk-IOTY7UTU.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "0.11.0",
4
+ "version": "0.11.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {