@threadlabs/looma 0.53.15 → 0.53.16
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/components/ui-button/ui-button.html +3 -2
- package/components/ui-editor/ui-editor.html +2 -1
- package/dist/index.js +1 -1
- package/docs/catalog.json +1 -1
- package/editor/components.css +3 -2
- package/editor/file-deletions.d.ts +2 -0
- package/editor/index.js +27 -5
- package/editor/node-views/file-attachment.d.ts +1 -1
- package/package.json +1 -1
- package/styles/ui-button.css +3 -2
package/docs/catalog.json
CHANGED
package/editor/components.css
CHANGED
|
@@ -211,11 +211,12 @@
|
|
|
211
211
|
box-shadow: none;
|
|
212
212
|
background-image: none;
|
|
213
213
|
}
|
|
214
|
-
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-
|
|
214
|
+
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=lg"][data-appearance="card"] {
|
|
215
215
|
min-block-size: max(var(--ui-control-min-block-size), var(--ui-control-size-lg));
|
|
216
216
|
}
|
|
217
|
-
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-
|
|
217
|
+
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=sm"][data-appearance="card"] {
|
|
218
218
|
min-block-size: var(--ui-control-size-sm);
|
|
219
|
+
align-items: center !important;
|
|
219
220
|
gap: var(--ui-space-2) !important;
|
|
220
221
|
}
|
|
221
222
|
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="fit"][data-appearance="card"] {
|
|
@@ -7,5 +7,7 @@ export interface FileDeletionServices {
|
|
|
7
7
|
remove: (file: LoomaFileDescriptor, signal: AbortSignal) => Promise<boolean>;
|
|
8
8
|
onError: (error: unknown, file: LoomaFileDescriptor) => void;
|
|
9
9
|
}
|
|
10
|
+
/** Remove an authored reference without changing the original file's availability. */
|
|
11
|
+
export declare function removeFileBlock(editor: Editor, position: () => number | undefined): void;
|
|
10
12
|
/** Remove one block optimistically; retain a mapped rollback anchor while transport runs. */
|
|
11
13
|
export declare function deleteFileBlock(editor: Editor, position: () => number | undefined, file: LoomaFileDescriptor, services: FileDeletionServices): Promise<void>;
|
package/editor/index.js
CHANGED
|
@@ -14144,6 +14144,16 @@ var dividerNodeView = ({ editor, getPos }) => {
|
|
|
14144
14144
|
};
|
|
14145
14145
|
//#endregion
|
|
14146
14146
|
//#region src/editor/file-deletions.ts
|
|
14147
|
+
/** Remove an authored reference without changing the original file's availability. */
|
|
14148
|
+
function removeFileBlock(editor, position) {
|
|
14149
|
+
if (editor.isDestroyed || !editor.isEditable) return;
|
|
14150
|
+
const at = position();
|
|
14151
|
+
if (at === void 0) return;
|
|
14152
|
+
const original = editor.state.doc.nodeAt(at);
|
|
14153
|
+
if (original?.type.name !== "loomaFileAttachment") return;
|
|
14154
|
+
editor.view.dispatch(closeHistory(editor.state.tr).delete(at, at + original.nodeSize));
|
|
14155
|
+
editor.view.focus();
|
|
14156
|
+
}
|
|
14147
14157
|
/** Remove one block optimistically; retain a mapped rollback anchor while transport runs. */
|
|
14148
14158
|
async function deleteFileBlock(editor, position, file, services) {
|
|
14149
14159
|
if (!services.enabled() || editor.isDestroyed || !editor.isEditable) return;
|
|
@@ -14196,7 +14206,7 @@ async function deleteFileBlock(editor, position, file, services) {
|
|
|
14196
14206
|
//#endregion
|
|
14197
14207
|
//#region src/editor/node-views/file-attachment.ts
|
|
14198
14208
|
var sequence = 0;
|
|
14199
|
-
/** A compact
|
|
14209
|
+
/** A compact file link with an editable reference action and optional original deletion. */
|
|
14200
14210
|
var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
14201
14211
|
let current = node, pending = false;
|
|
14202
14212
|
const metadata = () => {
|
|
@@ -14206,6 +14216,10 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
|
14206
14216
|
return null;
|
|
14207
14217
|
}
|
|
14208
14218
|
};
|
|
14219
|
+
const deletesOriginal = () => {
|
|
14220
|
+
const a = metadata(), display = a ? getReferenceDisplay(editor)[`attachment:${a.href}`] : void 0;
|
|
14221
|
+
return Boolean(a && services.enabled() && display?.status !== "deleted" && display?.status !== "pending" && display?.deletable !== false);
|
|
14222
|
+
};
|
|
14209
14223
|
const name = document.createTextNode(""), size = document.createTextNode("");
|
|
14210
14224
|
const download = createUiIcon({
|
|
14211
14225
|
name: "download",
|
|
@@ -14251,17 +14265,22 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
|
14251
14265
|
label: "Delete file",
|
|
14252
14266
|
variant: "ghost",
|
|
14253
14267
|
tone: "neutral",
|
|
14254
|
-
size: "
|
|
14268
|
+
size: "xs",
|
|
14255
14269
|
attributes: {
|
|
14256
14270
|
id,
|
|
14257
14271
|
"data-looma-file-delete": ""
|
|
14258
14272
|
},
|
|
14259
14273
|
children: [createUiIcon({
|
|
14260
14274
|
name: "trash",
|
|
14275
|
+
tone: "muted",
|
|
14261
14276
|
attributes: { "aria-hidden": "true" }
|
|
14262
14277
|
})]
|
|
14263
14278
|
});
|
|
14264
14279
|
trash.addEventListener("click", async () => {
|
|
14280
|
+
if (!deletesOriginal()) {
|
|
14281
|
+
removeFileBlock(editor, getPos);
|
|
14282
|
+
return;
|
|
14283
|
+
}
|
|
14265
14284
|
const a = metadata();
|
|
14266
14285
|
if (!a || pending) return;
|
|
14267
14286
|
pending = true;
|
|
@@ -14273,6 +14292,7 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
|
14273
14292
|
render();
|
|
14274
14293
|
}
|
|
14275
14294
|
});
|
|
14295
|
+
const tooltip = document.createTextNode("");
|
|
14276
14296
|
const dom = createUiCluster({
|
|
14277
14297
|
padding: "s",
|
|
14278
14298
|
gap: "xs",
|
|
@@ -14286,7 +14306,7 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
|
14286
14306
|
trash,
|
|
14287
14307
|
createUiTooltip({
|
|
14288
14308
|
for: id,
|
|
14289
|
-
children: [
|
|
14309
|
+
children: [tooltip]
|
|
14290
14310
|
})
|
|
14291
14311
|
]
|
|
14292
14312
|
});
|
|
@@ -14300,10 +14320,12 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
|
|
|
14300
14320
|
disabled: !a || deleted || display?.status === "pending"
|
|
14301
14321
|
});
|
|
14302
14322
|
download.hidden = deleted;
|
|
14303
|
-
trash.hidden = !
|
|
14323
|
+
trash.hidden = !editor.isEditable;
|
|
14324
|
+
const deleteOriginal = deletesOriginal(), verb = deleteOriginal ? "Delete" : "Remove";
|
|
14325
|
+
tooltip.data = deleteOriginal ? "Delete file and remove reference" : "Remove attachment reference";
|
|
14304
14326
|
componentRegistry.update(trash, {
|
|
14305
14327
|
loading: pending,
|
|
14306
|
-
label:
|
|
14328
|
+
label: `${verb} ${a?.name ?? "unavailable attachment"}`
|
|
14307
14329
|
});
|
|
14308
14330
|
};
|
|
14309
14331
|
const stop = observeReferenceDisplay(editor, render);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { NodeViewRenderer } from '@tiptap/core';
|
|
2
2
|
import { type FileDeletionServices } from '../file-deletions';
|
|
3
|
-
/** A compact
|
|
3
|
+
/** A compact file link with an editable reference action and optional original deletion. */
|
|
4
4
|
export declare const createFileAttachmentNodeView: (services: FileDeletionServices) => NodeViewRenderer;
|
package/package.json
CHANGED
package/styles/ui-button.css
CHANGED
|
@@ -211,11 +211,12 @@
|
|
|
211
211
|
box-shadow: none;
|
|
212
212
|
background-image: none;
|
|
213
213
|
}
|
|
214
|
-
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-
|
|
214
|
+
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=lg"][data-appearance="card"] {
|
|
215
215
|
min-block-size: max(var(--ui-control-min-block-size), var(--ui-control-size-lg));
|
|
216
216
|
}
|
|
217
|
-
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-
|
|
217
|
+
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=sm"][data-appearance="card"] {
|
|
218
218
|
min-block-size: var(--ui-control-size-sm);
|
|
219
|
+
align-items: center !important;
|
|
219
220
|
gap: var(--ui-space-2) !important;
|
|
220
221
|
}
|
|
221
222
|
:scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="fit"][data-appearance="card"] {
|