autumnnote 1.4.2 → 1.5.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.
@@ -922,13 +922,6 @@
922
922
  }
923
923
  };
924
924
  var removeFormatBtn = btn("removeFormat", "remove-format", "Remove Format", () => execCommand("removeFormat"));
925
- btn("direction", "direction", "Toggle Text Direction (LTR / RTL)", (ctx) => {
926
- const editable = ctx.layoutInfo.editable;
927
- const next = (editable.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
928
- editable.setAttribute("dir", next);
929
- editable.style.textAlign = next === "rtl" ? "right" : "left";
930
- ctx.invoke("editor.afterCommand");
931
- });
932
925
  /** @type {DropdownDef} */
933
926
  var fontFamilyBtn = {
934
927
  name: "fontFamily",
@@ -1048,7 +1041,6 @@
1048
1041
  var fullscreenBtn = btn("fullscreen", "expand", "Fullscreen", (ctx) => ctx.invoke("fullscreen.toggle"), (ctx) => ctx.invoke("fullscreen.isActive"));
1049
1042
  var shortcutsBtn = btn("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (ctx) => ctx.invoke("shortcutsDialog.show"));
1050
1043
  var findBtn = btn("find", "search", "Find (Ctrl+F)", (ctx) => ctx.invoke("findReplace.show", "find"));
1051
- btn("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (ctx) => ctx.invoke("findReplace.show", "replace"));
1052
1044
  var inlineCodeBtn = btn("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (ctx) => ctx.invoke("editor.inlineCode"), () => isInlineCode());
1053
1045
  var checklistBtn = btn("checklist", "checklist", "Checklist", (ctx) => ctx.invoke("editor.toggleChecklist"), () => isInChecklist());
1054
1046
  var printBtn = btn("print", "print", "Print", (ctx) => ctx.invoke("editor.print"));
@@ -1295,6 +1287,7 @@
1295
1287
  chooseHighlightColor: "Choose highlight color",
1296
1288
  customColor: "Custom color",
1297
1289
  insertTableLabel: "Insert Table",
1290
+ /** Map of paragraph-style value → label (only values needing translation) */
1298
1291
  paragraphItems: {
1299
1292
  p: "Normal",
1300
1293
  blockquote: "Quote",
@@ -1337,6 +1330,7 @@
1337
1330
  widthPlaceholder: "560",
1338
1331
  insertBtn: "Insert",
1339
1332
  cancelBtn: "Cancel",
1333
+ /** @param {string} type */
1340
1334
  detected: (type) => `Detected: ${type}`,
1341
1335
  unknownFormat: "Unknown format — will try direct video embed",
1342
1336
  invalidUrl: "Invalid URL — please enter a valid video link."
@@ -1499,9 +1493,13 @@
1499
1493
  },
1500
1494
  statusbar: {
1501
1495
  resizeHandle: "Resize editor",
1496
+ /** @param {number} n */
1502
1497
  words: (n) => `Words: ${n}`,
1498
+ /** @param {number} n @param {number} max */
1503
1499
  wordsLimit: (n, max) => `Words: ${n}/${max}`,
1500
+ /** @param {number} n */
1504
1501
  chars: (n) => `Chars: ${n}`,
1502
+ /** @param {number} n @param {number} max */
1505
1503
  charsLimit: (n, max) => `Chars: ${n}/${max}`
1506
1504
  },
1507
1505
  tooltips: {
@@ -1574,7 +1572,9 @@
1574
1572
  }
1575
1573
  },
1576
1574
  errors: {
1575
+ /** @param {string} type */
1577
1576
  imageFormat: (type) => `Format "${type}" is not supported for display in web browsers. Please convert to JPEG, PNG, or WebP first.`,
1577
+ /** @param {number} maxSize */
1578
1578
  imageSize: (maxSize) => `Image file is too large. Maximum allowed size is ${maxSize} MB.`
1579
1579
  }
1580
1580
  };
@@ -15961,6 +15961,13 @@
15961
15961
  /** @type {WeakMap<Element, Context>} */
15962
15962
  var instances = /* @__PURE__ */ new WeakMap();
15963
15963
  var AutumnNote = {
15964
+ /**
15965
+ * Creates (or returns existing) editor instance on one or more elements.
15966
+ *
15967
+ * @param {string|Element|NodeList|Element[]} selector
15968
+ * @param {import('./settings.js').AsnOptions} [options]
15969
+ * @returns {Context|Context[]} single Context or array of Contexts
15970
+ */
15964
15971
  create(selector, options = {}) {
15965
15972
  const ctxs = resolveElements(selector).map((el) => {
15966
15973
  if (instances.has(el)) return instances.get(el);
@@ -15971,6 +15978,10 @@
15971
15978
  });
15972
15979
  return ctxs.length === 1 ? ctxs[0] : ctxs;
15973
15980
  },
15981
+ /**
15982
+ * Destroys the editor(s) on the given selector.
15983
+ * @param {string|Element|NodeList|Element[]} selector
15984
+ */
15974
15985
  destroy(selector) {
15975
15986
  resolveElements(selector).forEach((el) => {
15976
15987
  const ctx = instances.get(el);
@@ -15980,23 +15991,45 @@
15980
15991
  }
15981
15992
  });
15982
15993
  },
15994
+ /**
15995
+ * Returns the Context instance for a given element (or null).
15996
+ * @param {string|Element} selector
15997
+ * @returns {Context|null}
15998
+ */
15983
15999
  getInstance(selector) {
15984
16000
  const el = typeof selector === "string" ? document.querySelector(selector) : selector;
15985
16001
  return el ? instances.get(el) || null : null;
15986
16002
  },
16003
+ /** Returns a shallow copy of the default options (read-only snapshot). */
15987
16004
  get defaults() {
15988
16005
  return { ...defaultOptions };
15989
16006
  },
16007
+ /** Merges properties into the global defaults, applied to all future instances. */
15990
16008
  setDefaults(overrides) {
15991
16009
  Object.assign(defaultOptions, overrides);
15992
16010
  },
16011
+ /** Restores global defaults to their original factory values. */
15993
16012
  resetDefaults() {
15994
16013
  Object.keys(defaultOptions).forEach((k) => delete defaultOptions[k]);
15995
16014
  Object.assign(defaultOptions, _originalDefaults);
15996
16015
  },
16016
+ /**
16017
+ * Registers a custom module to be included in every new editor instance.
16018
+ * @param {string} name - unique module key used for ctx.invoke() calls
16019
+ * @param {Function} ModuleClass - class with initialize() and optional destroy()
16020
+ */
15997
16021
  registerModule(name, ModuleClass) {
15998
16022
  _customModules.set(name, ModuleClass);
15999
16023
  },
16024
+ /**
16025
+ * Installs a plugin globally — applied to every future editor instance.
16026
+ * Plugin `buttons` are registered to the global button registry immediately
16027
+ * so they are available when Toolbar initialises inside create().
16028
+ * Plugin `install()` is called after all built-in modules have initialised.
16029
+ * @param {object} plugin - { name, version?, buttons?, install?, uninstall? }
16030
+ * @param {object} [options] - Forwarded to plugin.install(context, options)
16031
+ * @returns {typeof AutumnNote}
16032
+ */
16000
16033
  use(plugin, options = {}) {
16001
16034
  if (!plugin || typeof plugin.name !== "string") throw new TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
16002
16035
  if (_globalPlugins.has(plugin.name)) {
@@ -16010,14 +16043,26 @@
16010
16043
  });
16011
16044
  return this;
16012
16045
  },
16046
+ /**
16047
+ * Returns true if a plugin with the given name has been registered globally.
16048
+ * @param {string} name
16049
+ * @returns {boolean}
16050
+ */
16013
16051
  hasPlugin(name) {
16014
16052
  return _globalPlugins.has(name);
16015
16053
  },
16054
+ /**
16055
+ * Registers a single button definition in the global button registry.
16056
+ * After create(), call ctx.invoke('toolbar.rebuild') to render new buttons.
16057
+ * @param {object} btnDef - ButtonDef-compatible object with a `name` string
16058
+ * @returns {typeof AutumnNote}
16059
+ */
16016
16060
  registerButton(btnDef) {
16017
16061
  registerButton(btnDef);
16018
16062
  return this;
16019
16063
  },
16020
- version: "1.4.2"
16064
+ /** Library version */
16065
+ version: "1.5.0"
16021
16066
  };
16022
16067
  /**
16023
16068
  * @param {string|Element|NodeList|Element[]} selector