@aicayzer/inkkit 0.4.1 → 0.6.0

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.
@@ -28436,6 +28436,24 @@ var formatLossCodes = [
28436
28436
  "mark-spaces",
28437
28437
  "empty-line"
28438
28438
  ];
28439
+ /** The closed list of failure codes. The API reference describes each one. */
28440
+ var editorErrorCodes = [
28441
+ "not-ready",
28442
+ "destroyed",
28443
+ "stale-document",
28444
+ "composition",
28445
+ "operation-pending",
28446
+ "read-only",
28447
+ "invalid-argument",
28448
+ "invalid-range",
28449
+ "preservation",
28450
+ "image-unavailable",
28451
+ "diagram-unavailable",
28452
+ "file-unavailable",
28453
+ "clipboard-unavailable",
28454
+ "slash-command-failed",
28455
+ "internal"
28456
+ ];
28439
28457
  /** Every failure InkKit reports. Hosts branch on `code`; `message` is for logs. When the failure
28440
28458
  * started elsewhere, such as in an adapter, the host clipboard or the renderer, `cause` holds the
28441
28459
  * original error. */
@@ -28793,6 +28811,208 @@ function mermaidPreview(store, onError) {
28793
28811
  });
28794
28812
  }
28795
28813
  //#endregion
28814
+ //#region src/preserve-error.ts
28815
+ var PreservationError = class extends Error {
28816
+ constructor(message, options) {
28817
+ super(message, options);
28818
+ this.name = "PreservationError";
28819
+ }
28820
+ };
28821
+ var PreservationRefusal = class extends PreservationError {
28822
+ reason;
28823
+ constructor(reason, message) {
28824
+ super(message);
28825
+ this.reason = reason;
28826
+ }
28827
+ };
28828
+ var MarkdownParseRefusal = class extends InkKitError {
28829
+ constructor() {
28830
+ super("preservation", "The Markdown cannot be shown without losing part of it");
28831
+ }
28832
+ };
28833
+ function isPreservationRefusal(error) {
28834
+ return error instanceof PreservationRefusal || error instanceof MarkdownParseRefusal;
28835
+ }
28836
+ //#endregion
28837
+ //#region src/diagnostics.ts
28838
+ var observers = /* @__PURE__ */ new WeakMap();
28839
+ function observePreservation(ctx, observer) {
28840
+ if (observer) observers.set(ctx, observer);
28841
+ else observers.delete(ctx);
28842
+ }
28843
+ function tracePreservation(ctx, detail) {
28844
+ observers.get(ctx)?.(detail);
28845
+ }
28846
+ var Diagnostics = class {
28847
+ state;
28848
+ enabled = false;
28849
+ sessionId = randomSession();
28850
+ started = performance.now();
28851
+ sequence = 0;
28852
+ events = [];
28853
+ incident;
28854
+ dispose;
28855
+ latestState = {
28856
+ ready: false,
28857
+ revision: 0,
28858
+ format: "md",
28859
+ mode: "formatted",
28860
+ editable: false,
28861
+ composing: false,
28862
+ pending: false
28863
+ };
28864
+ currentState() {
28865
+ try {
28866
+ return this.latestState = this.state();
28867
+ } catch {
28868
+ return this.latestState;
28869
+ }
28870
+ }
28871
+ capture(detail) {
28872
+ try {
28873
+ this.record(detail);
28874
+ } catch {}
28875
+ }
28876
+ constructor(state) {
28877
+ this.state = state;
28878
+ }
28879
+ setEnabled(enabled, root, ctx) {
28880
+ if (enabled === this.enabled) return;
28881
+ this.dispose?.();
28882
+ this.dispose = void 0;
28883
+ observePreservation(ctx);
28884
+ this.enabled = enabled;
28885
+ this.events = [];
28886
+ this.incident = void 0;
28887
+ this.sequence = 0;
28888
+ if (!enabled) return;
28889
+ this.sessionId = randomSession();
28890
+ this.started = performance.now();
28891
+ const listeners = [];
28892
+ const listen = (target, name, run) => {
28893
+ target.addEventListener(name, run, true);
28894
+ listeners.push(() => target.removeEventListener(name, run, true));
28895
+ };
28896
+ for (const name of ["beforeinput", "input"]) listen(root, name, (event) => {
28897
+ const inputType = event.inputType ?? "";
28898
+ const input = inputType.includes("Composition") ? "composition" : inputType.startsWith("delete") ? "delete" : inputType.includes("Paste") ? "paste" : inputType.includes("Drop") ? "drop" : inputType.startsWith("history") ? "history" : inputType.startsWith("format") ? "format" : inputType === "insertText" ? "text" : "other";
28899
+ this.capture({
28900
+ kind: "input",
28901
+ phase: name === "beforeinput" ? "before" : "after",
28902
+ input
28903
+ });
28904
+ });
28905
+ for (const name of ["compositionstart", "compositionend"]) listen(root, name, () => this.capture({
28906
+ kind: "composition",
28907
+ phase: name === "compositionstart" ? "start" : "end"
28908
+ }));
28909
+ for (const name of ["focusin", "focusout"]) listen(root, name, () => this.capture({
28910
+ kind: "focus",
28911
+ phase: name === "focusin" ? "in" : "out"
28912
+ }));
28913
+ listen(root.ownerDocument, "selectionchange", () => {
28914
+ const document = root.ownerDocument;
28915
+ if (root.contains(document.activeElement) || root.contains(document.getSelection()?.anchorNode ?? null)) this.capture({ kind: "selection" });
28916
+ });
28917
+ this.dispose = () => listeners.forEach((remove) => remove());
28918
+ observePreservation(ctx, (detail) => this.capture(detail));
28919
+ this.capture({ kind: "enabled" });
28920
+ }
28921
+ record(detail) {
28922
+ if (!this.enabled) return;
28923
+ const safe = { ...detail };
28924
+ if (safe.code && !editorErrorCodes.includes(safe.code)) safe.code = "internal";
28925
+ if (safe.reason && ![
28926
+ "matching-budget",
28927
+ "source-location",
28928
+ "reopen-mismatch",
28929
+ "parse-refusal",
28930
+ "unexpected"
28931
+ ].includes(safe.reason)) safe.reason = "unexpected";
28932
+ const event = {
28933
+ ...safe,
28934
+ sequence: ++this.sequence,
28935
+ elapsedMs: Math.round(performance.now() - this.started),
28936
+ state: this.currentState()
28937
+ };
28938
+ this.events.push(event);
28939
+ if (this.events.length > 200) this.events.shift();
28940
+ if (this.incident) {
28941
+ if (this.incident.tail.length < 40) this.incident.tail.push(event);
28942
+ } else if (safe.code === "preservation" || safe.code === "internal" || safe.kind === "preservation" && safe.phase === "refused") this.incident = {
28943
+ triggerSequence: event.sequence,
28944
+ events: this.events.slice(),
28945
+ tail: []
28946
+ };
28947
+ }
28948
+ report(presentation) {
28949
+ return structuredClone({
28950
+ schemaVersion: 1,
28951
+ enabled: this.enabled,
28952
+ sessionId: this.sessionId,
28953
+ state: this.currentState(),
28954
+ events: this.events,
28955
+ ...this.incident ? { incident: this.incident } : {},
28956
+ ...presentation ? { presentation } : {}
28957
+ });
28958
+ }
28959
+ destroy(ctx) {
28960
+ this.dispose?.();
28961
+ observePreservation(ctx);
28962
+ this.dispose = void 0;
28963
+ this.enabled = false;
28964
+ this.events = [];
28965
+ this.incident = void 0;
28966
+ }
28967
+ };
28968
+ function diagnosticOperation(name) {
28969
+ if (name === "snapshot") return "snapshot";
28970
+ if (name === "undo" || name === "redo") return "history";
28971
+ if (name === "loadDocument" || name === "reloadDocument") return "load";
28972
+ if (name.startsWith("set")) return "configuration";
28973
+ if (name.includes("Snapshot") || name === "convertDocument") return "output";
28974
+ if (name.includes("TextRange") || name === "focus" || name === "blur") return "selection";
28975
+ if (name === "destroy") return "lifecycle";
28976
+ if ([
28977
+ "insertText",
28978
+ "replaceSource",
28979
+ "paste",
28980
+ "pasteAsPlainText",
28981
+ "format",
28982
+ "table",
28983
+ "moveBlock",
28984
+ "replace",
28985
+ "replaceAll",
28986
+ "insertImages",
28987
+ "appendImages",
28988
+ "insertFootnote",
28989
+ "insertPaths",
28990
+ "editReferenceDefinition"
28991
+ ].includes(name)) return "edit";
28992
+ return "other";
28993
+ }
28994
+ var diagnosticNumber = (value) => Number.isFinite(value) ? Math.round(Math.max(-1e7, Math.min(1e7, value)) * 100) / 100 : 0;
28995
+ function diagnosticReason(error) {
28996
+ try {
28997
+ for (let depth = 0; depth < 8 && error instanceof Error; depth++) {
28998
+ if (error instanceof MarkdownParseRefusal) return "parse-refusal";
28999
+ if (error instanceof PreservationRefusal) {
29000
+ const reason = error.reason;
29001
+ return reason === "matching-budget" || reason === "source-location" || reason === "reopen-mismatch" ? reason : "unexpected";
29002
+ }
29003
+ error = Object.getOwnPropertyDescriptor(error, "cause")?.value;
29004
+ }
29005
+ } catch {}
29006
+ return "unexpected";
29007
+ }
29008
+ function randomSession() {
29009
+ const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
29010
+ bytes[6] = bytes[6] & 15 | 64;
29011
+ bytes[8] = bytes[8] & 63 | 128;
29012
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
29013
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
29014
+ }
29015
+ //#endregion
28796
29016
  //#region src/bom.ts
28797
29017
  function leadingBOMLength(text) {
28798
29018
  return text.startsWith("") ? 1 : 0;
@@ -44160,29 +44380,6 @@ function languageFence(value, language) {
44160
44380
  };
44161
44381
  }
44162
44382
  //#endregion
44163
- //#region src/preserve-error.ts
44164
- var PreservationError = class extends Error {
44165
- constructor(message, options) {
44166
- super(message, options);
44167
- this.name = "PreservationError";
44168
- }
44169
- };
44170
- var PreservationRefusal = class extends PreservationError {
44171
- reason;
44172
- constructor(reason, message) {
44173
- super(message);
44174
- this.reason = reason;
44175
- }
44176
- };
44177
- var MarkdownParseRefusal = class extends InkKitError {
44178
- constructor() {
44179
- super("preservation", "The Markdown cannot be shown without losing part of it");
44180
- }
44181
- };
44182
- function isPreservationRefusal(error) {
44183
- return error instanceof PreservationRefusal || error instanceof MarkdownParseRefusal;
44184
- }
44185
- //#endregion
44186
44383
  //#region src/parser.ts
44187
44384
  /**
44188
44385
  * Milkdown's parser state, except that it throws where Milkdown would drop content. Milkdown
@@ -44309,6 +44506,10 @@ async function resolveFile(adapter, reference, context) {
44309
44506
  "error"
44310
44507
  ].includes(presentation.kind)) throw new TypeError("File adapter returned an unsupported presentation");
44311
44508
  if (presentation.label !== void 0 && typeof presentation.label !== "string") throw new TypeError("File presentation label must be text");
44509
+ if (presentation.kind === "file") {
44510
+ if (presentation.layout !== void 0 && presentation.layout !== "fill") throw new TypeError("File presentation layout must be fill");
44511
+ if (presentation.activation !== void 0 && presentation.activation !== "card") throw new TypeError("File presentation activation must be card");
44512
+ }
44312
44513
  if (presentation.kind === "error" && typeof presentation.message !== "string") throw new TypeError("File presentation error must include a message");
44313
44514
  if ("url" in presentation) {
44314
44515
  if (typeof presentation.url !== "string" || !presentation.url.trim()) throw new TypeError("File presentation needs a resource URL");
@@ -51050,6 +51251,12 @@ var Preservation = class Preservation {
51050
51251
  try {
51051
51252
  return this.serializeWith(doc);
51052
51253
  } catch (cause) {
51254
+ tracePreservation(this.ctx, {
51255
+ kind: "preservation",
51256
+ phase: "refused",
51257
+ code: "preservation",
51258
+ reason: cause instanceof PreservationRefusal ? cause.reason : "unexpected"
51259
+ });
51053
51260
  if (cause instanceof PreservationError || isPreservationRefusal(cause)) throw cause;
51054
51261
  throw new PreservationError("Cannot preserve the edited Markdown", { cause });
51055
51262
  } finally {
@@ -51057,14 +51264,26 @@ var Preservation = class Preservation {
51057
51264
  }
51058
51265
  }
51059
51266
  serializeWith(doc) {
51060
- if (this.unchanged(doc)) return this.source;
51267
+ if (this.unchanged(doc)) {
51268
+ tracePreservation(this.ctx, {
51269
+ kind: "preservation",
51270
+ path: "unchanged"
51271
+ });
51272
+ return this.source;
51273
+ }
51061
51274
  let local = this.localEdits(doc);
51275
+ let path = "local";
51062
51276
  if (local === void 0) try {
51277
+ path = "regions";
51063
51278
  local = this.regions(doc);
51064
51279
  } catch (error) {
51065
51280
  if (!isPreservationRefusal(error)) throw error;
51066
51281
  local = void 0;
51067
51282
  }
51283
+ tracePreservation(this.ctx, {
51284
+ kind: "preservation",
51285
+ path: local === void 0 ? "whole" : path
51286
+ });
51068
51287
  return local === void 0 ? this.wholeDocument(doc) : this.checked(doc, local);
51069
51288
  }
51070
51289
  unchanged(doc) {
@@ -54740,6 +54959,14 @@ function codeControlsPlugin(visibleRect) {
54740
54959
  button.setAttribute("aria-label", labels.codeLanguage);
54741
54960
  button.setAttribute("aria-haspopup", "dialog");
54742
54961
  button.setAttribute("aria-expanded", "false");
54962
+ const chevron = document.createElementNS("http://www.w3.org/2000/svg", "svg");
54963
+ chevron.setAttribute("viewBox", "0 0 12 12");
54964
+ chevron.setAttribute("aria-hidden", "true");
54965
+ chevron.setAttribute("focusable", "false");
54966
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
54967
+ path.setAttribute("d", "m3 4.5 3 3 3-3");
54968
+ chevron.append(path);
54969
+ button.append(chevron);
54743
54970
  wrapper.append(button);
54744
54971
  let popup;
54745
54972
  let restore;
@@ -54752,7 +54979,7 @@ function codeControlsPlugin(visibleRect) {
54752
54979
  if (focus) button.focus();
54753
54980
  };
54754
54981
  button.addEventListener("mousedown", (event) => event.preventDefault());
54755
- button.addEventListener("click", () => {
54982
+ button.addEventListener("click", (event) => {
54756
54983
  if (popup) {
54757
54984
  close();
54758
54985
  return;
@@ -54760,6 +54987,7 @@ function codeControlsPlugin(visibleRect) {
54760
54987
  const captured = view.state.doc;
54761
54988
  popup = document.createElement("span");
54762
54989
  popup.className = "inkkit-code-language-menu";
54990
+ popup.dataset.inkkitInputModality = event.detail === 0 ? "keyboard" : "pointer";
54763
54991
  popup.setAttribute("role", "dialog");
54764
54992
  popup.setAttribute("aria-label", labels.codeLanguage);
54765
54993
  popup.contentEditable = "false";
@@ -54812,7 +55040,11 @@ function codeControlsPlugin(visibleRect) {
54812
55040
  }
54813
55041
  };
54814
55042
  search.addEventListener("input", render);
55043
+ popup.addEventListener("pointerdown", () => {
55044
+ if (popup) popup.dataset.inkkitInputModality = "pointer";
55045
+ });
54815
55046
  popup.addEventListener("keydown", (event) => {
55047
+ if (popup && (event.key === "Tab" || event.key.startsWith("Arrow") || event.key === "Home" || event.key === "End" || event.key === "Enter")) popup.dataset.inkkitInputModality = "keyboard";
54816
55048
  if (event.key === "Escape") {
54817
55049
  event.preventDefault();
54818
55050
  event.stopPropagation();
@@ -54826,7 +55058,8 @@ function codeControlsPlugin(visibleRect) {
54826
55058
  if (event.key === "ArrowUp") {
54827
55059
  event.preventDefault();
54828
55060
  const options = [...list.querySelectorAll("button")];
54829
- options[(options.indexOf(document.activeElement) - 1 + options.length) % options.length]?.focus();
55061
+ const index = options.indexOf(document.activeElement);
55062
+ options[index < 0 ? options.length - 1 : (index - 1 + options.length) % options.length]?.focus();
54830
55063
  }
54831
55064
  if (event.key === "Enter" && event.target === search) {
54832
55065
  event.preventDefault();
@@ -56472,6 +56705,8 @@ var ImageView = class {
56472
56705
  resolution;
56473
56706
  previewFailed = false;
56474
56707
  suspended = false;
56708
+ /** True while the card is itself the Open control (`activation: 'card'`). */
56709
+ cardKeys = false;
56475
56710
  /** Present when the host sets `files`, which then shows every image. */
56476
56711
  runtime;
56477
56712
  constructor(node, view, getPos, adapter, host, files, cache, canMutate = () => true) {
@@ -56527,7 +56762,7 @@ var ImageView = class {
56527
56762
  return true;
56528
56763
  }
56529
56764
  stopEvent(event) {
56530
- return event.target instanceof Element && !!event.target.closest(".inkkit-image-handle, .inkkit-file-control, audio, video, iframe");
56765
+ return event.target instanceof Element && (!!event.target.closest(".inkkit-image-handle, .inkkit-file-control, audio, video, iframe") || event.type === "keydown" && event.target === this.element && this.cardKeys);
56531
56766
  }
56532
56767
  ignoreMutation() {
56533
56768
  return true;
@@ -56644,7 +56879,25 @@ var ImageView = class {
56644
56879
  const selection = NodeSelection.create(state.doc, pos);
56645
56880
  if (!state.selection.eq(selection)) this.view.dispatch(state.tr.setSelection(selection));
56646
56881
  }
56647
- card(label, status, retry = false) {
56882
+ cardKey = (event) => {
56883
+ if (event.target !== this.element || event.isComposing) return;
56884
+ if (event.key !== "Enter" && event.key !== " ") return;
56885
+ event.preventDefault();
56886
+ this.activate();
56887
+ };
56888
+ cardClick = () => this.activate();
56889
+ /** Makes the whole card the one control that opens the file, in place of the arrow button. */
56890
+ activateCard(label) {
56891
+ const { element } = this;
56892
+ element.setAttribute("role", "button");
56893
+ element.setAttribute("aria-label", `${this.runtime.labels.fileOpen} ${label}`);
56894
+ element.tabIndex = 0;
56895
+ element.dataset.inkkitFileActivation = "card";
56896
+ this.cardKeys = true;
56897
+ element.addEventListener("click", this.cardClick);
56898
+ element.addEventListener("keydown", this.cardKey);
56899
+ }
56900
+ card(label, status, retry = false, activation = false) {
56648
56901
  if (this.resolution?.state.status !== "loading" && !this.handle) this.restoreResizeFocus = false;
56649
56902
  const footer = document.createElement("span");
56650
56903
  footer.className = "inkkit-file-footer";
@@ -56655,7 +56908,8 @@ var ImageView = class {
56655
56908
  text.textContent = label;
56656
56909
  text.title = label;
56657
56910
  name.append(text);
56658
- if (this.runtime?.adapter.open) {
56911
+ if (activation && this.runtime?.adapter.open) this.activateCard(label);
56912
+ else if (this.runtime?.adapter.open) {
56659
56913
  const open = this.button("", this.activate);
56660
56914
  open.classList.add("inkkit-file-open");
56661
56915
  open.setAttribute("aria-label", `${this.runtime.labels.fileOpen} ${label}`);
@@ -56691,6 +56945,12 @@ var ImageView = class {
56691
56945
  } : splitAlt(String(this.node.attrs.alt ?? ""));
56692
56946
  this.width = width;
56693
56947
  this.element.textContent = "";
56948
+ this.element.removeEventListener("click", this.cardClick);
56949
+ this.element.removeEventListener("keydown", this.cardKey);
56950
+ this.element.removeAttribute("tabindex");
56951
+ this.element.removeAttribute("data-inkkit-file-activation");
56952
+ this.element.removeAttribute("data-inkkit-file-layout");
56953
+ this.cardKeys = false;
56694
56954
  this.image = void 0;
56695
56955
  this.handle = void 0;
56696
56956
  if (this.runtime) {
@@ -56754,6 +57014,9 @@ var ImageView = class {
56754
57014
  this.pdf = pdf;
56755
57015
  this.element.append(pdf);
56756
57016
  this.card(label, this.runtime.labels.filePDFPreview);
57017
+ } else if (presentation.kind === "file") {
57018
+ if (presentation.layout === "fill") this.element.dataset.inkkitFileLayout = "fill";
57019
+ this.card(label, void 0, false, presentation.activation === "card");
56757
57020
  } else this.card(label);
56758
57021
  this.restoreHandleFocus();
56759
57022
  return;
@@ -56970,7 +57233,7 @@ async function createMilkdownEditor(root, options, runtime) {
56970
57233
  return true;
56971
57234
  }
56972
57235
  }));
56973
- }).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-CqtvWKCp.js")).highlightPlugin).use(options.rendering?.diagramPreview === false || !diagramsAvailable() ? [] : mermaidPreview(runtime.diagrams, (error) => runtime.report(error))).use(selectionPlugin).use($prose(() => search())).use(runtime.plugins.policy).use(options.wikiLinks ? wikiLinkView(options.wikiLinks, {
57236
+ }).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-ByA5v5o7.js")).highlightPlugin).use(options.rendering?.diagramPreview === false || !diagramsAvailable() ? [] : mermaidPreview(runtime.diagrams, (error) => runtime.report(error))).use(selectionPlugin).use($prose(() => search())).use(runtime.plugins.policy).use(options.wikiLinks ? wikiLinkView(options.wikiLinks, {
56974
57237
  capture: () => runtime.capture(),
56975
57238
  active: () => runtime.active(),
56976
57239
  labels: {
@@ -59576,6 +59839,7 @@ var stateEvents = ["changed", "commandStateChanged"];
59576
59839
  var InkKitEditor = class InkKitEditor {
59577
59840
  options;
59578
59841
  editor;
59842
+ diagnostics = new Diagnostics(() => this.diagnosticState());
59579
59843
  document = new EditorDocument({
59580
59844
  ctx: () => this.editor.ctx,
59581
59845
  literal: () => this.literalSurface,
@@ -59710,7 +59974,7 @@ var InkKitEditor = class InkKitEditor {
59710
59974
  try {
59711
59975
  markdown = this.document.currentText(view.state.doc);
59712
59976
  } catch (error) {
59713
- this.events.error?.(coded(error, "preservation"));
59977
+ this.report(coded(error, "preservation"));
59714
59978
  return;
59715
59979
  }
59716
59980
  if (this.literalSurface) this.source.reconcileFormattedChange(markdown, view.state.doc.attrs[sourceAttribute]);
@@ -59909,12 +60173,23 @@ var InkKitEditor = class InkKitEditor {
59909
60173
  }
59910
60174
  /** Reports a refused edit to the facade call that made it, or else to `events.error`. */
59911
60175
  refuse(error) {
60176
+ this.diagnostics.capture({
60177
+ kind: "error",
60178
+ code: error.code,
60179
+ ...error.code === "preservation" ? { reason: diagnosticReason(error) } : {}
60180
+ });
59912
60181
  if (this.call) this.call.refusal ??= error;
59913
60182
  else this.events.error?.(error);
59914
60183
  }
59915
60184
  /** Reports a failure no call is waiting for. */
59916
60185
  report(error) {
59917
- this.events.error?.(coded(error));
60186
+ const failure = coded(error);
60187
+ this.diagnostics.capture({
60188
+ kind: "error",
60189
+ code: failure.code,
60190
+ ...failure.code === "preservation" ? { reason: diagnosticReason(failure) } : {}
60191
+ });
60192
+ this.events.error?.(failure);
59918
60193
  }
59919
60194
  /** Runs a facade method for something the person did, such as a shortcut. Its failure goes to
59920
60195
  * `events.error`, unless a host call such as `keyDown` is waiting for it. */
@@ -59930,6 +60205,93 @@ var InkKitEditor = class InkKitEditor {
59930
60205
  get composing() {
59931
60206
  return this.literalSurface ? this.source.composing : this.editor.ctx.get(editorViewCtx).composing;
59932
60207
  }
60208
+ diagnosticState() {
60209
+ const view = this.editor?.ctx.get(editorViewCtx);
60210
+ const literal = this.source && this.literalSurface;
60211
+ return {
60212
+ ready: this.ready,
60213
+ revision: this.session.revision,
60214
+ generation: this.session.generation,
60215
+ format: this.document.format,
60216
+ mode: literal ? "source" : "formatted",
60217
+ editable: this.writable,
60218
+ composing: Boolean(literal ? this.source.composing : view?.composing),
60219
+ pending: Boolean(this.pasteController?.pending),
60220
+ ...view ? { selection: literal ? {
60221
+ from: this.source.element.selectionStart,
60222
+ to: this.source.element.selectionEnd
60223
+ } : {
60224
+ from: view.state.selection.from,
60225
+ to: view.state.selection.to
60226
+ } } : {}
60227
+ };
60228
+ }
60229
+ /** Starts or clears content-free local tracing. Disabled by default. */
60230
+ setDiagnosticsEnabled(enabled) {
60231
+ this.assertAlive();
60232
+ if (typeof enabled !== "boolean") throw invalidArgument("enabled must be a boolean");
60233
+ this.diagnostics.setEnabled(enabled, this.root, this.editor.ctx);
60234
+ }
60235
+ /** Reads diagnostics without serializing the document or requiring an editable surface. */
60236
+ diagnosticReport() {
60237
+ this.assertAlive();
60238
+ let presentation;
60239
+ if (this.diagnostics.enabled) try {
60240
+ const view = this.editor.ctx.get(editorViewCtx);
60241
+ const literal = this.literalSurface;
60242
+ const selection = view.state.selection;
60243
+ const dom = literal ? this.source.element : view.domAtPos(selection.from).node;
60244
+ const element = dom.nodeType === 1 ? dom : dom.parentElement ?? view.dom;
60245
+ const window = this.root.ownerDocument.defaultView;
60246
+ const style = window.getComputedStyle(element);
60247
+ const fontFamily = style.fontFamily.slice(0, 160).replace(/[^\p{L}\p{N} ,"'_-]/gu, "");
60248
+ const type = selection.$from.parent.type.name;
60249
+ const block = literal ? "literal" : type === "paragraph" ? "paragraph" : type === "heading" ? "heading" : type === "code_block" ? "code" : "other";
60250
+ const markNames = [
60251
+ "strong",
60252
+ "emphasis",
60253
+ "inlineCode",
60254
+ "strike_through",
60255
+ "link",
60256
+ "highlight"
60257
+ ];
60258
+ const marks = literal ? [] : (view.state.storedMarks ?? selection.$from.marks()).slice(0, 12).map((mark) => markNames.find((name) => name === mark.type.name) ?? "other");
60259
+ const bounds = literal ? void 0 : view.coordsAtPos(selection.from);
60260
+ presentation = {
60261
+ fontFamily,
60262
+ fontSize: diagnosticNumber(Number.parseFloat(style.fontSize)),
60263
+ fontWeight: diagnosticNumber(style.fontWeight === "normal" ? 400 : style.fontWeight === "bold" ? 700 : Number.parseFloat(style.fontWeight)),
60264
+ fontStyle: style.fontStyle === "normal" || style.fontStyle === "italic" || style.fontStyle === "oblique" ? style.fontStyle : "other",
60265
+ ...!literal && type === "heading" && [
60266
+ 1,
60267
+ 2,
60268
+ 3,
60269
+ 4,
60270
+ 5,
60271
+ 6
60272
+ ].includes(selection.$from.parent.attrs.level) ? { headingLevel: selection.$from.parent.attrs.level } : {},
60273
+ ...style.lineHeight !== "normal" ? { lineHeight: diagnosticNumber(Number.parseFloat(style.lineHeight)) } : {},
60274
+ block,
60275
+ marks,
60276
+ caretColor: /^(?:rgba?\([\d.,% ]+\)|#[\da-f]{3,8}|auto|transparent|currentcolor)$/i.test(style.caretColor) ? style.caretColor.slice(0, 80) : "other",
60277
+ ...bounds ? { caret: {
60278
+ left: diagnosticNumber(bounds.left),
60279
+ top: diagnosticNumber(bounds.top),
60280
+ right: diagnosticNumber(bounds.right),
60281
+ bottom: diagnosticNumber(bounds.bottom)
60282
+ } } : {},
60283
+ viewport: {
60284
+ width: diagnosticNumber(window.innerWidth),
60285
+ height: diagnosticNumber(window.innerHeight)
60286
+ },
60287
+ scroll: {
60288
+ left: diagnosticNumber(this.geometry.container.scrollLeft),
60289
+ top: diagnosticNumber(this.geometry.container.scrollTop)
60290
+ }
60291
+ };
60292
+ } catch {}
60293
+ return this.diagnostics.report(presentation);
60294
+ }
59933
60295
  /** The formats the host offered at mount, in its order, with what saving each promises. */
59934
60296
  get formats() {
59935
60297
  this.assertAlive();
@@ -60263,6 +60625,7 @@ var InkKitEditor = class InkKitEditor {
60263
60625
  * throws `destroyed`. */
60264
60626
  async destroy() {
60265
60627
  if (this.destroyed) return;
60628
+ this.diagnostics.destroy(this.editor.ctx);
60266
60629
  this.destroyed = true;
60267
60630
  this.clipboard.clear();
60268
60631
  this.ready = false;
@@ -60971,12 +61334,46 @@ var InkKitEditor = class InkKitEditor {
60971
61334
  "viewport",
60972
61335
  "headings",
60973
61336
  "navigateHeading",
60974
- "destroy"
61337
+ "destroy",
61338
+ "setDiagnosticsEnabled",
61339
+ "diagnosticReport"
60975
61340
  ]) {
60976
61341
  const method = InkKitEditor.prototype[name];
60977
61342
  Object.defineProperty(InkKitEditor.prototype, name, {
60978
61343
  value(...args) {
60979
- return this.facadeCall(() => method.apply(this, args));
61344
+ if (name === "setDiagnosticsEnabled" || name === "diagnosticReport") return method.apply(this, args);
61345
+ if (!this.diagnostics.enabled) return this.facadeCall(() => method.apply(this, args));
61346
+ const operation = diagnosticOperation(name);
61347
+ this.diagnostics.capture({
61348
+ kind: "operation",
61349
+ phase: "begin",
61350
+ operation
61351
+ });
61352
+ const success = (value) => {
61353
+ this.diagnostics.capture({
61354
+ kind: "operation",
61355
+ phase: "success",
61356
+ operation
61357
+ });
61358
+ return value;
61359
+ };
61360
+ const refused = (error) => {
61361
+ const failure = coded(error);
61362
+ this.diagnostics.capture({
61363
+ kind: "operation",
61364
+ phase: "refused",
61365
+ operation,
61366
+ code: failure.code,
61367
+ ...failure.code === "preservation" ? { reason: diagnosticReason(failure) } : {}
61368
+ });
61369
+ throw failure;
61370
+ };
61371
+ try {
61372
+ const result = this.facadeCall(() => method.apply(this, args));
61373
+ return result instanceof Promise ? result.then(success, refused) : success(result);
61374
+ } catch (error) {
61375
+ return refused(error);
61376
+ }
60980
61377
  },
60981
61378
  writable: true,
60982
61379
  configurable: true
@@ -1,4 +1,4 @@
1
- import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-CisgnAp-.js";
1
+ import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-C37056dR.js";
2
2
  //#region node_modules/.pnpm/highlight.js@11.11.2/node_modules/highlight.js/es/languages/arduino.js
3
3
  /** @type LanguageFn */
4
4
  function cPlusPlus(hljs) {
package/dist/core.d.ts CHANGED
@@ -3,3 +3,4 @@ export type { EditorEvents, EditorOptions, TextInputPreferences, CommandState, E
3
3
  export { InkKitError } from './types.js';
4
4
  export type { DocumentFormat, TextDocumentFormat, TextDocumentInput, RichTextDocumentInput, TextDocumentSnapshot, RichTextDocumentSnapshot, RichTextDocument, RichTextBlock, RichTextListItem, RichTextTableCell, RichTextInline, RichTextMark, FormatLoss, FormatLossCode, ConvertedDocument, FormatPromise, OfferedFormat, EditorLabels, Heading, TableCommand, TableOptions, BlockMoveDirection, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, ImageImportContext, WikiLinkReference, WikiLinkAdapter, FileReference, ClientPoint, FileContext, FilePresentation, FileAdapter, CapturedImage, PortableImage, ClipboardInput, ClipboardOutput, ClipboardScope, ClipboardImage, ClipboardDiagram, PrintableDocument, PrintableWarning, TextRange, ReadableTextSnapshot, TextRect, ViewportInsets, ViewportOptions, ViewportSnapshot, } from './types.js';
5
5
  export type { SlashMenuOptions, SlashCommandName, SlashCommand } from './types.js';
6
+ export type { DiagnosticReport, DiagnosticEvent, DiagnosticState, DiagnosticPresentation, } from './diagnostics.js';
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as InkKitError, t as InkKitEditor } from "./chunks/core-CisgnAp-.js";
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-C37056dR.js";
2
2
  export { InkKitEditor, InkKitError };
@@ -0,0 +1,94 @@
1
+ import { type DocumentFormat, type EditorErrorCode } from './types.js';
2
+ /** Content-free editor counters and input guards. */
3
+ export type DiagnosticState = {
4
+ ready: boolean;
5
+ revision: number;
6
+ generation?: number;
7
+ format: DocumentFormat;
8
+ mode: 'formatted' | 'source';
9
+ editable: boolean;
10
+ composing: boolean;
11
+ pending: boolean;
12
+ selection?: {
13
+ from: number;
14
+ to: number;
15
+ };
16
+ };
17
+ /** Closed categories, never raw browser input, method arguments or error messages. */
18
+ export type DiagnosticEvent = {
19
+ sequence: number;
20
+ elapsedMs: number;
21
+ kind: 'input' | 'composition' | 'focus' | 'selection' | 'operation' | 'preservation' | 'error' | 'enabled';
22
+ state: DiagnosticState;
23
+ phase?: 'before' | 'after' | 'start' | 'end' | 'in' | 'out' | 'begin' | 'success' | 'refused';
24
+ input?: 'text' | 'composition' | 'delete' | 'paste' | 'drop' | 'history' | 'format' | 'other';
25
+ operation?: 'snapshot' | 'edit' | 'history' | 'load' | 'configuration' | 'output' | 'selection' | 'lifecycle' | 'other';
26
+ code?: EditorErrorCode;
27
+ path?: 'unchanged' | 'local' | 'regions' | 'whole';
28
+ reason?: 'matching-budget' | 'source-location' | 'reopen-mismatch' | 'parse-refusal' | 'unexpected';
29
+ };
30
+ /** Declared CSS configuration and geometry, measured only when a report is requested. */
31
+ export type DiagnosticPresentation = {
32
+ fontFamily: string;
33
+ fontSize: number;
34
+ fontWeight: number;
35
+ fontStyle: 'normal' | 'italic' | 'oblique' | 'other';
36
+ headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
37
+ lineHeight?: number;
38
+ block: 'paragraph' | 'heading' | 'code' | 'other' | 'literal';
39
+ marks: ('strong' | 'emphasis' | 'inlineCode' | 'strike_through' | 'link' | 'highlight' | 'other')[];
40
+ caretColor: string;
41
+ caret?: {
42
+ left: number;
43
+ top: number;
44
+ right: number;
45
+ bottom: number;
46
+ };
47
+ viewport: {
48
+ width: number;
49
+ height: number;
50
+ };
51
+ scroll: {
52
+ left: number;
53
+ top: number;
54
+ };
55
+ };
56
+ /** An opt-in local report. Disabling diagnostics clears all retained events and the incident. */
57
+ export type DiagnosticReport = {
58
+ schemaVersion: 1;
59
+ enabled: boolean;
60
+ sessionId: string;
61
+ state: DiagnosticState;
62
+ events: DiagnosticEvent[];
63
+ incident?: {
64
+ triggerSequence: number;
65
+ events: DiagnosticEvent[];
66
+ tail: DiagnosticEvent[];
67
+ };
68
+ presentation?: DiagnosticPresentation;
69
+ };
70
+ type Detail = Omit<DiagnosticEvent, 'sequence' | 'elapsedMs' | 'state'>;
71
+ export declare function observePreservation(ctx: object, observer?: (detail: Detail) => void): void;
72
+ export declare function tracePreservation(ctx: object, detail: Detail): void;
73
+ export declare class Diagnostics {
74
+ private readonly state;
75
+ enabled: boolean;
76
+ private sessionId;
77
+ private started;
78
+ private sequence;
79
+ private events;
80
+ private incident?;
81
+ private dispose?;
82
+ private latestState;
83
+ private currentState;
84
+ capture(detail: Detail): void;
85
+ constructor(state: () => DiagnosticState);
86
+ setEnabled(enabled: boolean, root: HTMLElement, ctx: object): void;
87
+ private record;
88
+ report(presentation?: DiagnosticPresentation): DiagnosticReport;
89
+ destroy(ctx: object): void;
90
+ }
91
+ export declare function diagnosticOperation(name: string): DiagnosticEvent['operation'];
92
+ export declare const diagnosticNumber: (value: number) => number;
93
+ export declare function diagnosticReason(error: unknown): DiagnosticEvent['reason'];
94
+ export {};
package/dist/editor.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type DiagnosticReport } from './diagnostics.js';
1
2
  import type { SlashMenuOptions } from './types.js';
2
3
  import { InkKitError, type ClientPoint, type DocumentFormat, type DocumentInput, type DocumentSnapshot, type ConvertedDocument, type TextDocumentFormat, type ImageAdapter, type FileAdapter, type WikiLinkAdapter, type ClipboardInput, type ClipboardOutput, type ClipboardScope, type DocumentVersion, type PrintableDocument, type TextRange, type ReadableTextSnapshot, type TextRect, type ViewportOptions, type ViewportSnapshot, type EditorLabels, type Heading, type TableCommand, type TableOptions, type BlockMoveDirection, type OfferedFormat } from './types.js';
3
4
  /** An inline format that `CaretState` can report. */
@@ -157,6 +158,7 @@ export declare const editorEvents: readonly ["changed", "commandStateChanged", "
157
158
  export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat> {
158
159
  private readonly options;
159
160
  private editor;
161
+ private readonly diagnostics;
160
162
  private readonly document;
161
163
  private readonly history;
162
164
  private readonly text;
@@ -248,6 +250,11 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
248
250
  * `events.error`, unless a host call such as `keyDown` is waiting for it. */
249
251
  private forPerson;
250
252
  private get composing();
253
+ private diagnosticState;
254
+ /** Starts or clears content-free local tracing. Disabled by default. */
255
+ setDiagnosticsEnabled(enabled: boolean): void;
256
+ /** Reads diagnostics without serializing the document or requiring an editable surface. */
257
+ diagnosticReport(): DiagnosticReport;
251
258
  /** The formats the host offered at mount, in its order, with what saving each promises. */
252
259
  get formats(): readonly OfferedFormat[];
253
260
  /** Whether the person can edit. A read-only editor still permits selection, copying and find. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-CisgnAp-.js";
1
+ import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-C37056dR.js";
2
2
  //#region node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
3
3
  /*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
4
4
  function _OverloadYield(e, d) {
package/dist/style.css CHANGED
@@ -3,6 +3,7 @@
3
3
  box-sizing: border-box;
4
4
  color-scheme: var(--inkkit-color-scheme, light dark);
5
5
  color: var(--inkkit-text-color, CanvasText);
6
+ background: var(--inkkit-background-color, transparent);
6
7
  font-family: var(
7
8
  --inkkit-font-family,
8
9
  -apple-system,
@@ -376,6 +377,22 @@
376
377
  white-space: normal;
377
378
  }
378
379
 
380
+ /* A file presentation with `layout: 'fill'` takes the column's width instead of its label's. */
381
+ .inkkit-root
382
+ .ProseMirror
383
+ .inkkit-image.inkkit-file[data-inkkit-file-layout='fill'] {
384
+ display: block;
385
+ width: 100%;
386
+ }
387
+ .inkkit-root .ProseMirror .inkkit-file[data-inkkit-file-activation='card'] {
388
+ cursor: pointer;
389
+ }
390
+ .inkkit-root
391
+ .ProseMirror
392
+ .inkkit-file[data-inkkit-file-activation='card']:hover {
393
+ background: var(--_inkkit-code-bg);
394
+ }
395
+
379
396
  .inkkit-root .ProseMirror .inkkit-file-footer {
380
397
  display: flex;
381
398
  flex-wrap: wrap;
@@ -612,7 +629,7 @@
612
629
  font-size: calc(var(--_inkkit-font-size) * 0.867);
613
630
  line-height: 1.5;
614
631
  background: var(--_inkkit-code-bg);
615
- border-radius: 8px;
632
+ border-radius: var(--inkkit-code-radius, 8px);
616
633
  padding: calc(var(--_inkkit-font-size) * 0.8)
617
634
  calc(var(--_inkkit-font-size) * 0.933);
618
635
  margin: 0 0 calc(var(--_inkkit-font-size) * 0.8);
@@ -663,9 +680,27 @@
663
680
  }
664
681
 
665
682
  .inkkit-root .ProseMirror blockquote {
683
+ position: relative;
666
684
  margin: 0 0 calc(var(--_inkkit-font-size) * 0.8);
667
- padding: 2px 0 2px calc(var(--_inkkit-font-size) * 0.8);
668
- border-left: 2px solid var(--_inkkit-accent);
685
+ padding: 2px 0 2px
686
+ calc(var(--_inkkit-font-size) * 0.8 + var(--inkkit-quote-rule-width, 2px));
687
+ }
688
+
689
+ .inkkit-root .ProseMirror blockquote::before {
690
+ content: '';
691
+ position: absolute;
692
+ inset: 0 auto 0 0;
693
+ width: var(--inkkit-quote-rule-width, 2px);
694
+ border-radius: var(--inkkit-quote-rule-radius, 0px);
695
+ background: var(--inkkit-quote-rule-color, var(--_inkkit-accent));
696
+ pointer-events: none;
697
+ }
698
+
699
+ @media (forced-colors: active) {
700
+ .inkkit-root .ProseMirror blockquote::before {
701
+ background: CanvasText;
702
+ forced-color-adjust: none;
703
+ }
669
704
  }
670
705
 
671
706
  .inkkit-root .ProseMirror blockquote > :first-child {
@@ -1103,6 +1138,7 @@
1103
1138
  /* One ring for every control InkKit draws; the editing surfaces can be set apart. */
1104
1139
  .inkkit-root button:focus-visible,
1105
1140
  .inkkit-root .inkkit-image-handle:focus-visible,
1141
+ .inkkit-root .inkkit-file[data-inkkit-file-activation='card']:focus-visible,
1106
1142
  .inkkit-root .inkkit-file audio:focus-visible,
1107
1143
  .inkkit-root .inkkit-file video:focus-visible {
1108
1144
  outline: var(--inkkit-focus-width, 2px) solid
@@ -1194,6 +1230,9 @@
1194
1230
  user-select: none;
1195
1231
  }
1196
1232
  .inkkit-root .inkkit-code-language {
1233
+ display: inline-flex;
1234
+ align-items: center;
1235
+ gap: 5px;
1197
1236
  height: 24px;
1198
1237
  padding: 0 6px;
1199
1238
  border: 0;
@@ -1203,9 +1242,15 @@
1203
1242
  font: inherit;
1204
1243
  cursor: pointer;
1205
1244
  }
1206
- .inkkit-root .inkkit-code-language::after {
1207
- content: '⌄';
1208
- margin-left: 5px;
1245
+ .inkkit-root .inkkit-code-language svg {
1246
+ flex-shrink: 0;
1247
+ width: 12px;
1248
+ height: 12px;
1249
+ fill: none;
1250
+ stroke: currentColor;
1251
+ stroke-width: 1.25;
1252
+ stroke-linecap: round;
1253
+ stroke-linejoin: round;
1209
1254
  }
1210
1255
  .inkkit-root .inkkit-code-language:hover {
1211
1256
  background: color-mix(in srgb, CanvasText 7%, transparent);
@@ -1223,7 +1268,7 @@
1223
1268
  flex-direction: column;
1224
1269
  width: 220px;
1225
1270
  max-height: min(320px, 50vh);
1226
- padding: 5px;
1271
+ padding: 6px;
1227
1272
  box-sizing: border-box;
1228
1273
  border: 1px solid color-mix(in srgb, CanvasText 15%, transparent);
1229
1274
  border-radius: 8px;
@@ -1235,10 +1280,10 @@
1235
1280
  box-sizing: border-box;
1236
1281
  min-width: 0;
1237
1282
  width: 100%;
1238
- padding: 7px;
1239
- border: 0;
1240
- border-bottom: 1px solid color-mix(in srgb, CanvasText 12%, transparent);
1241
- background: transparent;
1283
+ padding: 7px 8px;
1284
+ border: 1px solid color-mix(in srgb, CanvasText 12%, transparent);
1285
+ border-radius: 5px;
1286
+ background: color-mix(in srgb, CanvasText 3%, transparent);
1242
1287
  color: inherit;
1243
1288
  font: inherit;
1244
1289
  }
@@ -1246,7 +1291,7 @@
1246
1291
  display: flex;
1247
1292
  flex-direction: column;
1248
1293
  overflow-y: auto;
1249
- padding-top: 4px;
1294
+ padding: 4px 0 0;
1250
1295
  }
1251
1296
  .inkkit-root .inkkit-code-language-list button {
1252
1297
  flex-shrink: 0;
@@ -1260,10 +1305,40 @@
1260
1305
  cursor: pointer;
1261
1306
  }
1262
1307
  .inkkit-root .inkkit-code-language-list button:hover,
1263
- .inkkit-root .inkkit-code-language-list button:focus-visible,
1308
+ .inkkit-root
1309
+ .inkkit-code-language-menu[data-inkkit-input-modality='keyboard']
1310
+ .inkkit-code-language-list
1311
+ button:focus,
1264
1312
  .inkkit-root .inkkit-code-language-list button[aria-pressed='true'] {
1265
1313
  background: color-mix(in srgb, CanvasText 8%, transparent);
1266
1314
  }
1315
+ .inkkit-root .inkkit-code-language-menu input:focus,
1316
+ .inkkit-root .inkkit-code-language-menu button:focus {
1317
+ outline: none;
1318
+ }
1319
+ .inkkit-root
1320
+ .inkkit-code-language-menu[data-inkkit-input-modality='keyboard']
1321
+ input:focus,
1322
+ .inkkit-root
1323
+ .inkkit-code-language-menu[data-inkkit-input-modality='keyboard']
1324
+ button:focus {
1325
+ outline: var(--inkkit-focus-width, 2px) solid
1326
+ var(--inkkit-focus-color, var(--_inkkit-accent));
1327
+ outline-offset: var(--inkkit-focus-offset, -2px);
1328
+ }
1329
+ @media (forced-colors: active) {
1330
+ .inkkit-root .inkkit-code-language-menu input {
1331
+ border-color: ButtonBorder;
1332
+ }
1333
+ .inkkit-root
1334
+ .inkkit-code-language-menu[data-inkkit-input-modality='keyboard']
1335
+ input:focus,
1336
+ .inkkit-root
1337
+ .inkkit-code-language-menu[data-inkkit-input-modality='keyboard']
1338
+ button:focus {
1339
+ outline-color: Highlight;
1340
+ }
1341
+ }
1267
1342
 
1268
1343
  .inkkit-root .milkdown-drop-indicator {
1269
1344
  background: var(--inkkit-drop-indicator-color, var(--_inkkit-accent));
@@ -0,0 +1,36 @@
1
+ :where([data-inkkit-theme='calm']) {
2
+ --inkkit-font-family:
3
+ -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
4
+ --inkkit-font-size: 15px;
5
+ --inkkit-paragraph-spacing: calc(var(--inkkit-font-size) * 0.667);
6
+ --inkkit-reading-width: 100%;
7
+ --inkkit-background-color: light-dark(#ffffff, #1d2430);
8
+ --inkkit-text-color: light-dark(#252c36, #e6eaf0);
9
+ --inkkit-muted-color: light-dark(#656f7c, #a4adbb);
10
+ --inkkit-accent-color: light-dark(#3064af, #9abbf5);
11
+ --inkkit-rule-color: light-dark(#dce2e9, #434d5e);
12
+ --inkkit-checkbox-border-color: var(--inkkit-muted-color);
13
+ --inkkit-code-background: light-dark(#f3f5f8, #272e3a);
14
+ --inkkit-table-radius: 8px;
15
+ --inkkit-code-radius: 8px;
16
+ --inkkit-quote-rule-width: 3px;
17
+ --inkkit-quote-rule-radius: 2px;
18
+ --inkkit-quote-rule-color: light-dark(#a6a6a6, #777777);
19
+ --inkkit-code-comment: light-dark(#6e6e6e, #99999a);
20
+ --inkkit-code-keyword: light-dark(#a626a4, #c77bde);
21
+ --inkkit-code-string: light-dark(#3b763a, #98c379);
22
+ --inkkit-code-number: light-dark(#8d6001, #d19a66);
23
+ --inkkit-code-title: light-dark(#8d6101, #e5c07b);
24
+ --inkkit-code-attr: light-dark(#c82c1e, #e37981);
25
+ --inkkit-diagram-background: light-dark(#ffffff, #1d2430);
26
+ --inkkit-diagram-text-color: light-dark(#252c36, #e6eaf0);
27
+ --inkkit-diagram-color-strength: 35%;
28
+ --inkkit-diagram-series-1: light-dark(#4d87d5, #9abbf5);
29
+ --inkkit-diagram-series-2: light-dark(#69ad91, #a1d6bd);
30
+ --inkkit-diagram-series-3: light-dark(#9b80ce, #c4aff0);
31
+ --inkkit-diagram-series-4: light-dark(#d6a660, #edce9b);
32
+ --inkkit-diagram-series-5: light-dark(#ce819a, #eeb4c8);
33
+ --inkkit-diagram-series-6: light-dark(#65b4b1, #9edbd7);
34
+ --inkkit-diagram-series-7: light-dark(#cab85d, #e9dd99);
35
+ --inkkit-diagram-series-8: light-dark(#7ca9c5, #b1d6ed);
36
+ }
@@ -0,0 +1,36 @@
1
+ :where([data-inkkit-theme='essential']) {
2
+ --inkkit-font-family:
3
+ -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
4
+ --inkkit-font-size: 15px;
5
+ --inkkit-paragraph-spacing: calc(var(--inkkit-font-size) * 0.667);
6
+ --inkkit-reading-width: 100%;
7
+ --inkkit-background-color: light-dark(#ffffff, #1c1c1c);
8
+ --inkkit-text-color: light-dark(#262626, #e8e8e8);
9
+ --inkkit-muted-color: light-dark(#707070, #a6a6a6);
10
+ --inkkit-accent-color: light-dark(#555555, #c4c4c4);
11
+ --inkkit-rule-color: light-dark(#dddddd, #444444);
12
+ --inkkit-checkbox-border-color: var(--inkkit-muted-color);
13
+ --inkkit-code-background: light-dark(#f7f7f7, #2a2a2a);
14
+ --inkkit-table-radius: 4px;
15
+ --inkkit-code-radius: 4px;
16
+ --inkkit-quote-rule-width: 3px;
17
+ --inkkit-quote-rule-radius: 2px;
18
+ --inkkit-quote-rule-color: light-dark(#a6a6a6, #777777);
19
+ --inkkit-code-comment: light-dark(#707070, #929292);
20
+ --inkkit-code-keyword: light-dark(#333333, #eeeeee);
21
+ --inkkit-code-string: light-dark(#686868, #bbbbbb);
22
+ --inkkit-code-number: light-dark(#555555, #c8c8c8);
23
+ --inkkit-code-title: light-dark(#444444, #dddddd);
24
+ --inkkit-code-attr: light-dark(#707070, #aaaaaa);
25
+ --inkkit-diagram-background: light-dark(#ffffff, #1c1c1c);
26
+ --inkkit-diagram-text-color: light-dark(#262626, #e8e8e8);
27
+ --inkkit-diagram-color-strength: 75%;
28
+ --inkkit-diagram-series-1: light-dark(#3d3d3d, #eeeeee);
29
+ --inkkit-diagram-series-2: light-dark(#5a5a5a, #d6d6d6);
30
+ --inkkit-diagram-series-3: light-dark(#747474, #bebebe);
31
+ --inkkit-diagram-series-4: light-dark(#8b8b8b, #a6a6a6);
32
+ --inkkit-diagram-series-5: light-dark(#a0a0a0, #8e8e8e);
33
+ --inkkit-diagram-series-6: light-dark(#b4b4b4, #767676);
34
+ --inkkit-diagram-series-7: light-dark(#c6c6c6, #5e5e5e);
35
+ --inkkit-diagram-series-8: light-dark(#d7d7d7, #464646);
36
+ }
@@ -0,0 +1,39 @@
1
+ :where([data-inkkit-theme='standard']) {
2
+ --inkkit-font-family:
3
+ -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
4
+ --inkkit-font-size: 15px;
5
+ --inkkit-paragraph-spacing: calc(var(--inkkit-font-size) * 0.667);
6
+ --inkkit-reading-width: 100%;
7
+ --inkkit-background-color: light-dark(#ffffff, #1c1c1e);
8
+ --inkkit-text-color: CanvasText;
9
+ --inkkit-muted-color: light-dark(#6e6e6e, #99999a);
10
+ --inkkit-accent-color: light-dark(#0069d1, #409cff);
11
+ --inkkit-rule-color: color-mix(in srgb, CanvasText 14%, transparent);
12
+ --inkkit-checkbox-border-color: var(--inkkit-muted-color);
13
+ --inkkit-code-background: light-dark(
14
+ #f3f5f8,
15
+ color-mix(in srgb, CanvasText 8%, transparent)
16
+ );
17
+ --inkkit-table-radius: 8px;
18
+ --inkkit-code-radius: 8px;
19
+ --inkkit-quote-rule-width: 3px;
20
+ --inkkit-quote-rule-radius: 2px;
21
+ --inkkit-quote-rule-color: light-dark(#a6a6a6, #777777);
22
+ --inkkit-code-comment: light-dark(#6e6e6e, #99999a);
23
+ --inkkit-code-keyword: light-dark(#a626a4, #c77bde);
24
+ --inkkit-code-string: light-dark(#3b763a, #98c379);
25
+ --inkkit-code-number: light-dark(#8d6001, #d19a66);
26
+ --inkkit-code-title: light-dark(#8d6101, #e5c07b);
27
+ --inkkit-code-attr: light-dark(#c82c1e, #e37981);
28
+ --inkkit-diagram-background: light-dark(#ffffff, #1c1c1e);
29
+ --inkkit-diagram-text-color: light-dark(#1c1c1e, #f2f2f7);
30
+ --inkkit-diagram-color-strength: 35%;
31
+ --inkkit-diagram-series-1: light-dark(#0088ff, #0091ff);
32
+ --inkkit-diagram-series-2: light-dark(#34c759, #30d158);
33
+ --inkkit-diagram-series-3: light-dark(#6155f5, #6d7cff);
34
+ --inkkit-diagram-series-4: light-dark(#ff8d28, #ff9230);
35
+ --inkkit-diagram-series-5: light-dark(#ff383c, #ff4245);
36
+ --inkkit-diagram-series-6: light-dark(#00c8b3, #00dac3);
37
+ --inkkit-diagram-series-7: light-dark(#ffcc00, #ffd600);
38
+ --inkkit-diagram-series-8: light-dark(#00c0e8, #3cd3fe);
39
+ }
package/dist/types.d.ts CHANGED
@@ -212,7 +212,14 @@ export type FilePresentation = {
212
212
  label?: string;
213
213
  mimeType?: string;
214
214
  } | {
215
- kind: 'file' | 'missing';
215
+ kind: 'file';
216
+ label?: string;
217
+ /** `'fill'` stretches the card to the full width of the column. */
218
+ layout?: 'fill';
219
+ /** `'card'` makes the whole card the one control that calls `FileAdapter.open`. */
220
+ activation?: 'card';
221
+ } | {
222
+ kind: 'missing';
216
223
  label?: string;
217
224
  } | {
218
225
  kind: 'error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,10 @@
17
17
  "types": "./dist/core.d.ts",
18
18
  "import": "./dist/core.js"
19
19
  },
20
- "./style.css": "./dist/style.css"
20
+ "./style.css": "./dist/style.css",
21
+ "./themes/standard.css": "./dist/themes/standard.css",
22
+ "./themes/calm.css": "./dist/themes/calm.css",
23
+ "./themes/essential.css": "./dist/themes/essential.css"
21
24
  },
22
25
  "types": "./dist/index.d.ts",
23
26
  "files": [