alinea 0.8.1 → 0.8.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.
@@ -30,7 +30,7 @@ import { slugify } from "alinea/core/util/Slugs";
30
30
  import { unreachable } from "alinea/core/util/Types";
31
31
  import { EntryPhase, EntryRow } from "../core/EntryRow.js";
32
32
  import { Media } from "./Media.js";
33
- import { ChangeSetCreator } from "./data/ChangeSet.js";
33
+ import { ChangeType } from "./data/ChangeSet.js";
34
34
  import { AlineaMeta } from "./db/AlineaMeta.js";
35
35
  import { createEntrySearch } from "./db/CreateEntrySearch.js";
36
36
  import { JsonLoader } from "./loader/JsonLoader.js";
@@ -360,7 +360,11 @@ ${JSON.stringify(mutation)}`
360
360
  const { Parent } = alias(EntryRow);
361
361
  const res = await tx(
362
362
  EntryRow().set({
363
- parent: Parent({ childrenDir: EntryRow.parentDir }).select(Parent.entryId).maybeFirst(),
363
+ parent: Parent({
364
+ childrenDir: EntryRow.parentDir,
365
+ workspace: EntryRow.workspace,
366
+ root: EntryRow.root
367
+ }).select(Parent.entryId).maybeFirst(),
364
368
  active: EntryRealm.isActive,
365
369
  main: EntryRealm.isMain
366
370
  })
@@ -635,24 +639,21 @@ ${JSON.stringify(mutation)}`
635
639
  await this.writeMeta(query, commitHash);
636
640
  });
637
641
  if (target && publishSeed.length > 0) {
638
- const changeSetCreator = new ChangeSetCreator(this.config);
639
- const mutations = publishSeed.map((seed) => {
642
+ const changes = publishSeed.map((seed) => {
640
643
  const workspace = this.config.workspaces[seed.workspace];
641
644
  const file = paths.join(
642
645
  Workspace.data(workspace).source,
643
646
  seed.root,
644
647
  seed.filePath
645
648
  );
646
- return {
647
- type: MutationType.Create,
648
- entryId: seed.entryId,
649
- file,
650
- entry: seed
651
- };
649
+ const record = createRecord(seed);
650
+ const contents = new TextDecoder().decode(
651
+ JsonLoader.format(this.config.schema, record)
652
+ );
653
+ return { type: ChangeType.Write, file, contents };
652
654
  });
653
- const changes = changeSetCreator.create(mutations);
654
655
  await target.mutate(
655
- { commitHash: "", mutations: changes },
656
+ { commitHash: "", mutations: [{ changes, meta: void 0 }] },
656
657
  { logger: new Logger("seed") }
657
658
  );
658
659
  }
@@ -21,6 +21,7 @@ import { Connection } from "alinea/core/Connection";
21
21
  import { parseYDoc } from "alinea/core/Doc";
22
22
  import { Entry } from "alinea/core/Entry";
23
23
  import { EntryPhase } from "alinea/core/EntryRow";
24
+ import { Graph } from "alinea/core/Graph";
24
25
  import { MutationType } from "alinea/core/Mutation";
25
26
  import { createSelection } from "alinea/core/pages/CreateSelection";
26
27
  import { Realm } from "alinea/core/pages/Realm";
@@ -40,7 +41,10 @@ var Handler = class {
40
41
  options.config.schema,
41
42
  this.parsePreview.bind(this)
42
43
  );
43
- this.changes = new ChangeSetCreator(options.config);
44
+ this.changes = new ChangeSetCreator(
45
+ options.config,
46
+ new Graph(options.config, this)
47
+ );
44
48
  const auth = options.auth ?? Auth.anonymous();
45
49
  this.connect = (ctx) => new HandlerConnection(this, ctx);
46
50
  this.router = createRouter(auth, this.connect);
@@ -134,7 +138,7 @@ var HandlerConnection = class {
134
138
  const { target, db } = this.handler.options;
135
139
  if (!target)
136
140
  throw new Error("Target not available");
137
- const changeSet = this.handler.changes.create(mutations);
141
+ const changeSet = await this.handler.changes.create(mutations);
138
142
  const { commitHash: fromCommitHash } = await this.handler.syncPending();
139
143
  let toCommitHash;
140
144
  try {
@@ -1,6 +1,6 @@
1
1
  import { Config } from 'alinea/core/Config';
2
+ import { Graph } from 'alinea/core/Graph';
2
3
  import { ArchiveMutation, CreateMutation, DiscardDraftMutation, EditMutation, FileRemoveMutation, MoveMutation, Mutation, OrderMutation, PatchMutation, PublishMutation, RemoveEntryMutation, UploadMutation } from 'alinea/core/Mutation';
3
- import { EntryUrlMeta } from 'alinea/core/Type';
4
4
  export declare enum ChangeType {
5
5
  Write = "write",
6
6
  Rename = "rename",
@@ -39,20 +39,20 @@ export type ChangeWithMeta = {
39
39
  };
40
40
  export type ChangeSet = Array<ChangeWithMeta>;
41
41
  export declare class ChangeSetCreator {
42
- config: Config;
43
- constructor(config: Config);
44
- entryLocation({ locale, parentPaths, path, phase }: EntryUrlMeta, extension: string): string;
42
+ protected config: Config;
43
+ protected graph: Graph;
44
+ constructor(config: Config, graph: Graph);
45
45
  editChanges({ previousFile, file, entry }: EditMutation): Array<Change>;
46
46
  patchChanges({ file, patch }: PatchMutation): Array<Change>;
47
47
  createChanges({ file, entry }: CreateMutation): Array<Change>;
48
48
  publishChanges({ file }: PublishMutation): Array<Change>;
49
49
  archiveChanges({ file }: ArchiveMutation): Array<Change>;
50
- removeChanges({ file }: RemoveEntryMutation): Array<Change>;
50
+ removeChanges({ entryId, file }: RemoveEntryMutation): Promise<Array<Change>>;
51
51
  discardChanges({ file }: DiscardDraftMutation): Array<Change>;
52
52
  orderChanges({ file, index }: OrderMutation): Array<Change>;
53
53
  moveChanges({ entryId, entryType, fromFile, toFile, index }: MoveMutation): Array<Change>;
54
54
  fileUploadChanges(mutation: UploadMutation): Array<Change>;
55
55
  fileRemoveChanges(mutation: FileRemoveMutation): Array<Change>;
56
- mutationChanges(mutation: Mutation): Array<Change>;
57
- create(mutations: Array<Mutation>): ChangeSet;
56
+ mutationChanges(mutation: Mutation): Promise<Array<Change>>;
57
+ create(mutations: Array<Mutation>): Promise<ChangeSet>;
58
58
  }
@@ -6,6 +6,7 @@ import { EntryPhase } from "alinea/core/EntryRow";
6
6
  import {
7
7
  MutationType
8
8
  } from "alinea/core/Mutation";
9
+ import { Query } from "alinea/core/Query";
9
10
  import { Type } from "alinea/core/Type";
10
11
  import { Workspace } from "alinea/core/Workspace";
11
12
  import { join } from "alinea/core/util/Paths";
@@ -21,15 +22,9 @@ var ChangeType = /* @__PURE__ */ ((ChangeType2) => {
21
22
  var decoder = new TextDecoder();
22
23
  var loader = JsonLoader;
23
24
  var ChangeSetCreator = class {
24
- constructor(config) {
25
+ constructor(config, graph) {
25
26
  this.config = config;
26
- }
27
- entryLocation({ locale, parentPaths, path, phase }, extension) {
28
- const segments = (locale ? [locale] : []).concat(
29
- parentPaths.concat(path).map((segment) => segment === "" ? "index" : segment)
30
- ).join("/");
31
- const phaseSegment = phase === EntryPhase.Published ? "" : `.${phase}`;
32
- return (segments + phaseSegment + extension).toLowerCase();
27
+ this.graph = graph;
33
28
  }
34
29
  editChanges({ previousFile, file, entry }) {
35
30
  const type = this.config.schema[entry.type];
@@ -101,11 +96,34 @@ var ChangeSetCreator = class {
101
96
  }
102
97
  ];
103
98
  }
104
- removeChanges({ file }) {
99
+ async removeChanges({
100
+ entryId,
101
+ file
102
+ }) {
105
103
  if (!file.endsWith(`.${EntryPhase.Archived}.json`))
106
104
  return [];
105
+ const { workspace, files } = await this.graph.preferPublished.get(
106
+ Query.whereId(entryId).select({
107
+ workspace: Query.workspace,
108
+ files: Query.children(void 0, 999).where(
109
+ Query.type.is("MediaFile")
110
+ )
111
+ })
112
+ );
113
+ const mediaDir = Workspace.data(this.config.workspaces[workspace])?.mediaDir ?? "";
114
+ const removeFiles = files.map((file2) => {
115
+ const binaryLocation = join(mediaDir, file2.location);
116
+ return {
117
+ type: "delete" /* Delete */,
118
+ file: binaryLocation
119
+ };
120
+ });
107
121
  return [
122
+ // Remove any media files in this location
123
+ ...removeFiles,
124
+ // Remove entry
108
125
  { type: "delete" /* Delete */, file },
126
+ // Remove children
109
127
  {
110
128
  type: "delete" /* Delete */,
111
129
  file: file.slice(0, -`.${EntryPhase.Archived}.json`.length)
@@ -161,7 +179,7 @@ var ChangeSetCreator = class {
161
179
  return [removeBinary];
162
180
  return [{ type: "delete" /* Delete */, file: mutation.file }, removeBinary];
163
181
  }
164
- mutationChanges(mutation) {
182
+ async mutationChanges(mutation) {
165
183
  switch (mutation.type) {
166
184
  case MutationType.Edit:
167
185
  return this.editChanges(mutation);
@@ -187,10 +205,11 @@ var ChangeSetCreator = class {
187
205
  return this.fileRemoveChanges(mutation);
188
206
  }
189
207
  }
190
- create(mutations) {
191
- return mutations.map((meta) => {
192
- return { changes: this.mutationChanges(meta), meta };
193
- });
208
+ async create(mutations) {
209
+ const res = [];
210
+ for (const meta of mutations)
211
+ res.push({ changes: await this.mutationChanges(meta), meta });
212
+ return res;
194
213
  }
195
214
  };
196
215
  export {
@@ -511,22 +511,24 @@ var EntryResolver = class {
511
511
  await tx(current.delete());
512
512
  await tx(EntryRow().insert(updated));
513
513
  await Database.index(tx);
514
- const result2 = await tx(query);
515
- const linkResolver2 = new LinkResolver(this, tx, ctx.realm);
516
- if (result2)
517
- await this.post({ linkResolver: linkResolver2 }, result2, selection);
518
- throw { result: result2 };
514
+ const result = await tx(query);
515
+ const linkResolver = new LinkResolver(this, tx, ctx.realm);
516
+ if (result)
517
+ await this.post({ linkResolver }, result, selection);
518
+ throw { result };
519
519
  });
520
520
  } catch (err) {
521
521
  if (err.result)
522
522
  return err.result;
523
523
  }
524
524
  }
525
- const result = await this.db.store(query);
526
- const linkResolver = new LinkResolver(this, this.db.store, ctx.realm);
527
- if (result)
528
- await this.post({ linkResolver }, result, selection);
529
- return result;
525
+ return this.db.store.transaction(async (tx) => {
526
+ const result = await tx(query);
527
+ const linkResolver = new LinkResolver(this, tx, ctx.realm);
528
+ if (result)
529
+ await this.post({ linkResolver }, result, selection);
530
+ return result;
531
+ });
530
532
  };
531
533
  };
532
534
  export {
@@ -35,11 +35,15 @@ function createExample() {
35
35
  path: path("Path"),
36
36
  ...tabs(
37
37
  tab("Tab 1", {
38
- name: path("Name")
38
+ fields: {
39
+ name: path("Name")
40
+ }
39
41
  }),
40
42
  tab("Tab 2", {
41
- name: text("Name"),
42
- name2: text("Name")
43
+ fields: {
44
+ name: text("Name"),
45
+ name2: text("Name")
46
+ }
43
47
  })
44
48
  ),
45
49
  [type.meta]: {
@@ -66,8 +70,10 @@ function createExample() {
66
70
  }),
67
71
  richText: richText("Rich text field"),
68
72
  select: select("Select field", {
69
- a: "Option a",
70
- b: "Option b"
73
+ options: {
74
+ a: "Option a",
75
+ b: "Option b"
76
+ }
71
77
  }),
72
78
  number: number("Number field", {
73
79
  minValue: 0,
@@ -94,8 +100,10 @@ function createExample() {
94
100
  }),
95
101
  multipleWithFields: link.multiple("Multiple With extra fields", {
96
102
  fields: type({
97
- fieldA: text("Field A", { width: 0.5 }),
98
- fieldB: text("Field B", { width: 0.5, required: true })
103
+ fields: {
104
+ fieldA: text("Field A", { width: 0.5 }),
105
+ fieldB: text("Field B", { width: 0.5, required: true })
106
+ }
99
107
  })
100
108
  }),
101
109
  list: list("My list field", {
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.8.1",
5
+ version: "0.8.2",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -80,7 +80,7 @@ var package_default = {
80
80
  "typescript-plugin-css-modules": "^5.0.2",
81
81
  uvu: "^0.5.1"
82
82
  },
83
- packageManager: "yarn@3.2.0",
83
+ packageManager: "yarn@4.1.0",
84
84
  resolutions: {
85
85
  esbuild: "0.19.12",
86
86
  yjs: "13.6.11",
package/dist/cli/Serve.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunks/chunk-UJJSVROY.js";
4
4
  import {
5
5
  package_default
6
- } from "../chunks/chunk-YXMLKKUG.js";
6
+ } from "../chunks/chunk-QI4HAQM4.js";
7
7
  import "../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // 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-YXMLKKUG.js";
3
+ } from "../chunks/chunk-QI4HAQM4.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-YXMLKKUG.js";
3
+ } from "../../chunks/chunk-QI4HAQM4.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-YXMLKKUG.js";
6
+ } from "../../chunks/chunk-QI4HAQM4.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -61,9 +61,9 @@ var GraphRealm = class _GraphRealm {
61
61
  });
62
62
  }
63
63
  async get(select) {
64
- const result = this.maybeGet(select);
64
+ const result = await this.maybeGet(select);
65
65
  if (result === null)
66
- throw new Error("Not found");
66
+ throw new Error("Entry not found");
67
67
  return result;
68
68
  }
69
69
  async find(select) {
@@ -52,6 +52,7 @@ export declare class EditOperation<Definition> extends Operation {
52
52
  export declare class CreateOperation<Definition> extends Operation {
53
53
  private type?;
54
54
  private parentRow?;
55
+ /** @internal */
55
56
  entry: Partial<Entry>;
56
57
  private entryRow;
57
58
  constructor(entry: Partial<Entry>, type?: Type<Definition> | undefined, parentRow?: ((cms: CMS) => Promise<EntryRow>) | undefined);
@@ -256,6 +256,7 @@ var CreateOperation = class _CreateOperation extends Operation {
256
256
  this.parentRow = parentRow;
257
257
  this.entry = { entryId: createId(), ...entry };
258
258
  }
259
+ /** @internal */
259
260
  entry;
260
261
  entryRow = async (cms) => {
261
262
  const partial = this.entry;
@@ -52,6 +52,9 @@ export declare const entryRoute: Route<{
52
52
  deleteFile: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
53
53
  init: null;
54
54
  };
55
+ deleteMediaLibrary: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
56
+ init: null;
57
+ };
55
58
  deleteArchived: import("jotai").WritableAtom<null, [], Promise<void>> & {
56
59
  init: null;
57
60
  };
@@ -148,6 +151,9 @@ export declare const draftRoute: Route<{
148
151
  deleteFile: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
149
152
  init: null;
150
153
  };
154
+ deleteMediaLibrary: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
155
+ init: null;
156
+ };
151
157
  deleteArchived: import("jotai").WritableAtom<null, [], Promise<void>> & {
152
158
  init: null;
153
159
  };
@@ -79,6 +79,9 @@ export declare const entryEditorAtoms: import("jotai/vanilla/utils/atomFamily.js
79
79
  deleteFile: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
80
80
  init: null;
81
81
  };
82
+ deleteMediaLibrary: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
83
+ init: null;
84
+ };
82
85
  deleteArchived: import("jotai").WritableAtom<null, [], Promise<void>> & {
83
86
  init: null;
84
87
  };
@@ -193,6 +196,9 @@ export declare function createEntryEditor(entryData: EntryData): {
193
196
  deleteFile: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
194
197
  init: null;
195
198
  };
199
+ deleteMediaLibrary: import("jotai").WritableAtom<null, [], Promise<void> | undefined> & {
200
+ init: null;
201
+ };
196
202
  deleteArchived: import("jotai").WritableAtom<null, [], Promise<void>> & {
197
203
  init: null;
198
204
  };
@@ -439,6 +439,31 @@ function createEntryEditor(entryData) {
439
439
  errorMessage: "Could not complete publish action, please try again later"
440
440
  });
441
441
  });
442
+ const deleteMediaLibrary = atom(null, (get, set) => {
443
+ const result = confirm(
444
+ "Are you sure you want to delete this folder and all its files?"
445
+ );
446
+ if (!result)
447
+ return;
448
+ const published = entryData.phases[EntryPhase.Published];
449
+ const mutations = [
450
+ {
451
+ type: MutationType.Archive,
452
+ entryId: published.entryId,
453
+ file: entryFile(published)
454
+ },
455
+ {
456
+ type: MutationType.Remove,
457
+ entryId: published.entryId,
458
+ file: entryFile({ ...published, phase: EntryPhase.Archived })
459
+ }
460
+ ];
461
+ return set(transact, {
462
+ transition: 9 /* DeleteArchived */,
463
+ action: () => set(mutateAtom, mutations),
464
+ errorMessage: "Could not complete delete action, please try again later"
465
+ });
466
+ });
442
467
  const deleteFile = atom(null, (get, set) => {
443
468
  const result = confirm("Are you sure you want to delete this file?");
444
469
  if (!result)
@@ -584,6 +609,7 @@ function createEntryEditor(entryData) {
584
609
  archivePublished,
585
610
  publishArchived,
586
611
  deleteFile,
612
+ deleteMediaLibrary,
587
613
  deleteArchived,
588
614
  saveTranslation,
589
615
  discardEdits,
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-7YXWNKGS.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-YXMLKKUG.js";
6
+ } from "../../chunks/chunk-QI4HAQM4.js";
7
7
  import {
8
8
  connect
9
9
  } from "../../chunks/chunk-LMUDRU2U.js";
@@ -13,6 +13,7 @@ import { Main } from "alinea/ui/Main";
13
13
  import { useMemo } from "react";
14
14
  import { Entry } from "alinea/core/Entry";
15
15
  import { workspaceMediaDir } from "alinea/core/util/EntryFilenames";
16
+ import { EntryHeader } from "alinea/dashboard/view/entry/EntryHeader";
16
17
  import { IcRoundArrowBack } from "alinea/ui/icons/IcRoundArrowBack";
17
18
  import { graphAtom } from "../atoms/DbAtoms.js";
18
19
  import { useNavigate } from "../atoms/LocationAtoms.js";
@@ -56,7 +57,7 @@ function MediaExplorer({ editor }) {
56
57
  ["explorer", "media", "total", condition],
57
58
  async () => {
58
59
  const cursor2 = Entry().where(condition).orderBy(Entry.type.desc(), Entry.entryId.desc());
59
- const info = await graph.preferDraft.get(
60
+ const info = await graph.preferDraft.maybeGet(
60
61
  Entry({ entryId: parentId }).select({
61
62
  title: Entry.title,
62
63
  parent: Entry.parent
@@ -71,37 +72,40 @@ function MediaExplorer({ editor }) {
71
72
  const nav = useNav();
72
73
  const navigate = useNavigate();
73
74
  const backLink = data?.parent ? nav.entry({ entryId: data.parent }) : editor ? nav.root({ root: root.name }) : void 0;
74
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Main, { className: styles.root(), scrollable: false, children: /* @__PURE__ */ jsxs("div", { className: styles.root.inner(), children: [
75
- /* @__PURE__ */ jsx(HStack, { style: { flexGrow: 1, minHeight: 0 }, children: /* @__PURE__ */ jsxs(VStack, { style: { height: "100%", width: "100%" }, children: [
76
- /* @__PURE__ */ jsxs("header", { className: styles.root.inner.header(), children: [
77
- /* @__PURE__ */ jsx(Head, { children: /* @__PURE__ */ jsx("title", { children: String(title) }) }),
78
- /* @__PURE__ */ jsxs(HStack, { center: true, gap: 18, children: [
79
- backLink && /* @__PURE__ */ jsx(IconLink, { icon: IcRoundArrowBack, href: backLink }),
80
- /* @__PURE__ */ jsx("h1", { className: styles.root.title(), children: /* @__PURE__ */ jsx(TextLabel, { label: title }) })
81
- ] })
82
- ] }),
75
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Main, { className: styles.root(), scrollable: false, children: [
76
+ editor && /* @__PURE__ */ jsx(EntryHeader, { editable: false, editor }),
77
+ /* @__PURE__ */ jsxs("div", { className: styles.root.inner(), children: [
78
+ /* @__PURE__ */ jsx(HStack, { style: { flexGrow: 1, minHeight: 0 }, children: /* @__PURE__ */ jsxs(VStack, { style: { height: "100%", width: "100%" }, children: [
79
+ /* @__PURE__ */ jsxs("header", { className: styles.root.inner.header(), children: [
80
+ /* @__PURE__ */ jsx(Head, { children: /* @__PURE__ */ jsx("title", { children: String(title) }) }),
81
+ /* @__PURE__ */ jsxs(HStack, { center: true, gap: 18, children: [
82
+ backLink && /* @__PURE__ */ jsx(IconLink, { icon: IcRoundArrowBack, href: backLink }),
83
+ /* @__PURE__ */ jsx("h1", { className: styles.root.title(), children: /* @__PURE__ */ jsx(TextLabel, { label: title }) })
84
+ ] })
85
+ ] }),
86
+ /* @__PURE__ */ jsx(
87
+ Explorer,
88
+ {
89
+ cursor,
90
+ type: "thumb",
91
+ virtualized: true,
92
+ onNavigate: (entryId) => navigate(nav.entry({ entryId }))
93
+ }
94
+ )
95
+ ] }) }),
83
96
  /* @__PURE__ */ jsx(
84
- Explorer,
97
+ FileUploader,
85
98
  {
86
- cursor,
87
- type: "thumb",
88
- virtualized: true,
89
- onNavigate: (entryId) => navigate(nav.entry({ entryId }))
99
+ destination: {
100
+ parentId,
101
+ workspace: workspace.name,
102
+ root: root.name,
103
+ directory: workspaceMediaDir(config, workspace.name)
104
+ }
90
105
  }
91
106
  )
92
- ] }) }),
93
- /* @__PURE__ */ jsx(
94
- FileUploader,
95
- {
96
- destination: {
97
- parentId,
98
- workspace: workspace.name,
99
- root: root.name,
100
- directory: workspaceMediaDir(config, workspace.name)
101
- }
102
- }
103
- )
104
- ] }) }) });
107
+ ] })
108
+ ] }) });
105
109
  }
106
110
  export {
107
111
  MediaExplorer
@@ -122,6 +122,7 @@ function EntryHeader({ editor, editable = true }) {
122
122
  const previewRevision = useAtomValue(editor.previewRevision);
123
123
  const isActivePhase = editor.activePhase === selectedPhase;
124
124
  const isMediaFile = editor.activeVersion.type === "MediaFile";
125
+ const isMediaLibrary = editor.activeVersion.type === "MediaLibrary";
125
126
  const hasChanges = useAtomValue(editor.hasChanges);
126
127
  const currentTransition = useAtomValue(editor.transition)?.transition;
127
128
  const untranslated = locale && locale !== editor.activeVersion.locale;
@@ -135,6 +136,7 @@ function EntryHeader({ editor, editable = true }) {
135
136
  const publishArchived = useSetAtom(editor.publishArchived);
136
137
  const deleteArchived = useSetAtom(editor.deleteArchived);
137
138
  const deleteFile = useSetAtom(editor.deleteFile);
139
+ const deleteMediaLibrary = useSetAtom(editor.deleteMediaLibrary);
138
140
  const queryClient = useQueryClient();
139
141
  function deleteFileAndNavigate() {
140
142
  return deleteFile()?.then(() => {
@@ -142,6 +144,12 @@ function EntryHeader({ editor, editable = true }) {
142
144
  navigate(nav.root(entryLocation));
143
145
  });
144
146
  }
147
+ function deleteMediaLibraryAndNavigate() {
148
+ return deleteMediaLibrary()?.then(() => {
149
+ queryClient.invalidateQueries("explorer");
150
+ navigate(nav.root(entryLocation));
151
+ });
152
+ }
145
153
  const saveTranslation = useSetAtom(editor.saveTranslation);
146
154
  const discardEdits = useSetAtom(editor.discardEdits);
147
155
  const translate = () => saveTranslation(locale);
@@ -198,7 +206,14 @@ function EntryHeader({ editor, editable = true }) {
198
206
  children: "Delete"
199
207
  }
200
208
  )
201
- ] }) : /* @__PURE__ */ jsx(
209
+ ] }) : isMediaLibrary ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
210
+ DropdownMenu.Item,
211
+ {
212
+ className: styles.root.action(),
213
+ onClick: deleteMediaLibraryAndNavigate,
214
+ children: "Delete"
215
+ }
216
+ ) }) : /* @__PURE__ */ jsx(
202
217
  DropdownMenu.Item,
203
218
  {
204
219
  className: styles.root.action(),
@@ -317,7 +332,7 @@ function EntryHeader({ editor, editable = true }) {
317
332
  /* @__PURE__ */ jsxs(DropdownMenu.Root, { bottom: true, left: true, children: [
318
333
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { className: styles.root.more(variant), children: /* @__PURE__ */ jsx(Icon, { icon: IcRoundMoreVert }) }),
319
334
  /* @__PURE__ */ jsxs(DropdownMenu.Items, { children: [
320
- !isMediaFile && /* @__PURE__ */ jsxs(
335
+ !isMediaFile && !isMediaLibrary && /* @__PURE__ */ jsxs(
321
336
  DropdownMenu.Item,
322
337
  {
323
338
  onClick: () => setShowHistory(!showHistory),
@@ -83,7 +83,7 @@ function NewEntryForm({ parentId }) {
83
83
  const { data: requestedParent } = useQuery(
84
84
  ["parent-req", parentId],
85
85
  async () => {
86
- return graph.preferDraft.get(
86
+ return graph.preferDraft.maybeGet(
87
87
  Entry({ entryId: parentId }).select(parentData)
88
88
  );
89
89
  },
@@ -202,7 +202,7 @@ function NewEntryForm({ parentId }) {
202
202
  phase: config.enableDrafts ? EntryPhase.Draft : EntryPhase.Published
203
203
  };
204
204
  const parentId2 = form.data().parent?.entry;
205
- const parent = await graph.preferPublished.get(
205
+ const parent = await graph.preferPublished.maybeGet(
206
206
  Entry({ entryId: parentId2 }).select(parentData)
207
207
  );
208
208
  const parentPaths = parent ? parent.parentPaths.concat(parent.path) : [];
@@ -212,7 +212,7 @@ function NewEntryForm({ parentId }) {
212
212
  const entryType = config.schema[selected];
213
213
  const url = entryUrl(entryType, { ...data, parentPaths });
214
214
  const copyFrom = form.data().copyFrom?.entry;
215
- const entryData = copyFrom ? await graph.preferPublished.get(
215
+ const entryData = copyFrom ? await graph.preferPublished.maybeGet(
216
216
  Entry({ entryId: copyFrom }).select(Entry.data)
217
217
  ) : {};
218
218
  const entry = await createEntryRow(config, {
package/dist/index.css CHANGED
@@ -1767,22 +1767,6 @@ button {
1767
1767
  overflow: auto;
1768
1768
  height: 100%;
1769
1769
  }
1770
- .alinea-Preview::-webkit-scrollbar {
1771
- width: 0.375rem;
1772
- height: 0.375rem;
1773
- }
1774
- .alinea-Preview::-webkit-scrollbar-track {
1775
- background: transparent;
1776
- }
1777
- .alinea-Preview::-webkit-scrollbar-thumb {
1778
- background: hsla(var(--alinea-negative), 0.2);
1779
- }
1780
- .alinea-Preview::-webkit-scrollbar-thumb:hover {
1781
- background: hsla(var(--alinea-negative), 0.4);
1782
- }
1783
- .alinea-Preview::-webkit-scrollbar-thumb:active {
1784
- background: hsla(var(--alinea-negative), 0.9);
1785
- }
1786
1770
 
1787
1771
  /* src/dashboard/view/preview/BrowserPreview.module.scss */
1788
1772
  .alinea-BrowserPreview {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "0.8.1",
4
+ "version": "0.8.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -79,7 +79,7 @@
79
79
  "typescript-plugin-css-modules": "^5.0.2",
80
80
  "uvu": "^0.5.1"
81
81
  },
82
- "packageManager": "yarn@3.2.0",
82
+ "packageManager": "yarn@4.1.0",
83
83
  "resolutions": {
84
84
  "esbuild": "0.19.12",
85
85
  "yjs": "13.6.11",