@mdxeditor/editor 2.20.0 → 2.20.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.
@@ -50,7 +50,7 @@ const ImageDialog = () => {
50
50
  },
51
51
  className: styles.multiFieldForm
52
52
  },
53
- /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "file" }, t("uploadImage.uploadInstructions", "Upload an image from your device:")), /* @__PURE__ */ React__default.createElement("input", { type: "file", ...register("file") })),
53
+ /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "file" }, t("uploadImage.uploadInstructions", "Upload an image from your device:")), /* @__PURE__ */ React__default.createElement("input", { type: "file", accept: "image/*", ...register("file") })),
54
54
  /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "src" }, t("uploadImage.addViaUrlInstructions", "Or add an image from an URL:")), /* @__PURE__ */ React__default.createElement(
55
55
  DownshiftAutoComplete,
56
56
  {
@@ -2,7 +2,7 @@ import { TOGGLE_LINK_COMMAND, $isLinkNode } from "@lexical/link";
2
2
  import { KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_LOW, KEY_MODIFIER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, $createTextNode, $insertNodes } from "lexical";
3
3
  import { IS_APPLE } from "../../utils/detectMac.js";
4
4
  import { getSelectionRectangle, getSelectedNode } from "../../utils/lexicalHelpers.js";
5
- import { createActiveEditorSubscription$, activeEditor$, currentSelection$, addComposerChild$ } from "../core/index.js";
5
+ import { createActiveEditorSubscription$, readOnly$, activeEditor$, currentSelection$, addComposerChild$ } from "../core/index.js";
6
6
  import { LinkDialog } from "./LinkDialog.js";
7
7
  import { Signal, Cell, withLatestFrom, map, Action, filter } from "@mdxeditor/gurx";
8
8
  import { realmPlugin } from "../../RealmWithPlugins.js";
@@ -42,7 +42,7 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
42
42
  return editor.registerCommand(
43
43
  KEY_MODIFIER_COMMAND,
44
44
  (event) => {
45
- if (event.key === "k" && (IS_APPLE ? event.metaKey : event.ctrlKey)) {
45
+ if (event.key === "k" && (IS_APPLE ? event.metaKey : event.ctrlKey) && !r.getValue(readOnly$)) {
46
46
  const selection = $getSelection();
47
47
  if ($isRangeSelection(selection)) {
48
48
  r.pub(openLinkEditDialog$);
@@ -143,9 +143,9 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
143
143
  r.link(
144
144
  r.pipe(
145
145
  r.combine(currentSelection$, onWindowChange$),
146
- withLatestFrom(activeEditor$, linkDialogState$),
147
- map(([[selection], activeEditor]) => {
148
- if ($isRangeSelection(selection) && activeEditor) {
146
+ withLatestFrom(activeEditor$, linkDialogState$, readOnly$),
147
+ map(([[selection], activeEditor, readOnly]) => {
148
+ if ($isRangeSelection(selection) && activeEditor && !readOnly) {
149
149
  const node = getLinkNodeInSelection(selection);
150
150
  if (node) {
151
151
  return {
@@ -17,6 +17,12 @@ import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
17
17
  import { uuidv4 } from "../../utils/uuid4.js";
18
18
  import { iconComponentFor$, readOnly$, useTranslation, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, rootEditor$, NESTED_EDITOR_UPDATED_COMMAND, editorRootElementRef$ } from "../core/index.js";
19
19
  import { useCellValues } from "@mdxeditor/gurx";
20
+ const getCellType = (rowIndex) => {
21
+ if (rowIndex === 0) {
22
+ return "th";
23
+ }
24
+ return "td";
25
+ };
20
26
  const AlignToTailwindClassMap = {
21
27
  center: styles.centeredCell,
22
28
  left: styles.leftAlignedCell,
@@ -151,7 +157,8 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
151
157
  }
152
158
  ));
153
159
  }), /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn }))), /* @__PURE__ */ React__default.createElement("tbody", null, mdastNode.children.map((row, rowIndex) => {
154
- return /* @__PURE__ */ React__default.createElement("tr", { key: rowIndex }, readOnly || /* @__PURE__ */ React__default.createElement("td", { className: styles.toolCell, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(RowEditor, { ...{ setActiveCellWithBoundaries, parentEditor, rowIndex, highlightedCoordinates, lexicalTable } })), row.children.map((mdastCell, colIndex) => {
160
+ const CellElement = getCellType(rowIndex);
161
+ return /* @__PURE__ */ React__default.createElement("tr", { key: rowIndex }, readOnly || /* @__PURE__ */ React__default.createElement(CellElement, { className: styles.toolCell, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(RowEditor, { ...{ setActiveCellWithBoundaries, parentEditor, rowIndex, highlightedCoordinates, lexicalTable } })), row.children.map((mdastCell, colIndex) => {
155
162
  var _a;
156
163
  return /* @__PURE__ */ React__default.createElement(
157
164
  Cell,
@@ -176,8 +183,9 @@ const Cell = ({ align, ...props }) => {
176
183
  const { activeCell, setActiveCell } = props;
177
184
  const isActive = Boolean(activeCell && activeCell[0] === props.colIndex && activeCell[1] === props.rowIndex);
178
185
  const className = AlignToTailwindClassMap[align || "left"];
186
+ const CellElement = getCellType(props.rowIndex);
179
187
  return /* @__PURE__ */ React__default.createElement(
180
- "td",
188
+ CellElement,
181
189
  {
182
190
  className,
183
191
  "data-active": isActive,