wysimark-lite 0.15.7 → 0.16.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.
package/dist/index.mjs CHANGED
@@ -4,13 +4,13 @@ import {
4
4
  useCallback as useCallback16,
5
5
  useImperativeHandle,
6
6
  useRef as useRef13,
7
- useState as useState12
7
+ useState as useState13
8
8
  } from "react";
9
9
  import { createRoot } from "react-dom/client";
10
10
 
11
11
  // src/entry/index.tsx
12
12
  import throttle3 from "lodash.throttle";
13
- import { useCallback as useCallback15, useRef as useRef12 } from "react";
13
+ import { useCallback as useCallback15, useRef as useRef12, useState as useState12 } from "react";
14
14
  import { Editor as Editor59, Transforms as Transforms41 } from "slate";
15
15
  import { ReactEditor as ReactEditor17, Slate as Slate2 } from "slate-react";
16
16
 
@@ -137,6 +137,29 @@ function customRemarkGfm() {
137
137
  }
138
138
 
139
139
  // src/convert/utils.ts
140
+ function escapeUrlSlashes(text) {
141
+ const markdownLinkPattern = /\[([^\]]+)\]\(([^)]+)\)/g;
142
+ const links = [];
143
+ let linkIndex = 0;
144
+ const textWithoutLinks = text.replace(markdownLinkPattern, (match) => {
145
+ links.push(match);
146
+ return `__MARKDOWN_LINK_${linkIndex++}__`;
147
+ });
148
+ const urlPattern = /(https?:\/\/[^\s]+)/g;
149
+ const textWithEscapedUrls = textWithoutLinks.replace(urlPattern, (url) => {
150
+ return url.replace(/\//g, "\\/");
151
+ });
152
+ let result = textWithEscapedUrls;
153
+ for (let i = 0; i < links.length; i++) {
154
+ result = result.replace(`__MARKDOWN_LINK_${i}__`, links[i]);
155
+ }
156
+ return result;
157
+ }
158
+ function unescapeUrlSlashes(text) {
159
+ return text.replace(/\\(.)/g, (match, char) => {
160
+ return char;
161
+ });
162
+ }
140
163
  function assert(pass, message) {
141
164
  if (!pass)
142
165
  throw new Error(`${message}`);
@@ -1467,6 +1490,104 @@ function serialize(elements) {
1467
1490
  return serializeElements(normalizedElements);
1468
1491
  }
1469
1492
 
1493
+ // src/utils/translations.ts
1494
+ var translations = {
1495
+ ja: {
1496
+ bold: "\u592A\u5B57",
1497
+ italic: "\u659C\u4F53",
1498
+ strike: "\u53D6\u308A\u6D88\u3057\u7DDA",
1499
+ inlineCode: "\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",
1500
+ underline: "\u4E0B\u7DDA",
1501
+ increaseDepth: "\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",
1502
+ decreaseDepth: "\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",
1503
+ heading1: "\u898B\u51FA\u30571",
1504
+ heading2: "\u898B\u51FA\u30572",
1505
+ heading3: "\u898B\u51FA\u30573",
1506
+ normal: "\u6A19\u6E96",
1507
+ paragraph: "\u6BB5\u843D",
1508
+ paragraphStyle: "\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",
1509
+ bulletList: "\u7B87\u6761\u66F8\u304D",
1510
+ numberedList: "\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",
1511
+ checkList: "\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",
1512
+ list: "\u30EA\u30B9\u30C8",
1513
+ linkUrl: "\u30EA\u30F3\u30AF\u306EURL",
1514
+ tooltipText: "\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",
1515
+ tooltipHint: "\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",
1516
+ apply: "\u9069\u7528",
1517
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
1518
+ insertLink: "\u30EA\u30F3\u30AF\u306E\u633F\u5165",
1519
+ quote: "\u5F15\u7528",
1520
+ insertTable: "\u8868\u306E\u633F\u5165",
1521
+ insertImage: "\u753B\u50CF\u306E\u633F\u5165",
1522
+ insertImageFromUrl: "URL\u304B\u3089\u753B\u50CF\u3092\u633F\u5165",
1523
+ insert: "\u633F\u5165",
1524
+ imageUrlRequired: "\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",
1525
+ altText: "\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",
1526
+ title: "\u30BF\u30A4\u30C8\u30EB\uFF1A",
1527
+ imageDescription: "\u753B\u50CF\u306E\u8AAC\u660E",
1528
+ imageTitle: "\u753B\u50CF\u306E\u30BF\u30A4\u30C8\u30EB",
1529
+ switchToVisualEditor: "\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",
1530
+ switchToRawMarkdown: "\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048"
1531
+ },
1532
+ en: {
1533
+ bold: "Bold",
1534
+ italic: "Italic",
1535
+ strike: "Strikethrough",
1536
+ inlineCode: "Inline Code",
1537
+ underline: "Underline",
1538
+ increaseDepth: "Increase Depth",
1539
+ decreaseDepth: "Decrease Depth",
1540
+ heading1: "Heading 1",
1541
+ heading2: "Heading 2",
1542
+ heading3: "Heading 3",
1543
+ normal: "Normal",
1544
+ paragraph: "Paragraph",
1545
+ paragraphStyle: "Paragraph Style",
1546
+ bulletList: "Bullet List",
1547
+ numberedList: "Numbered List",
1548
+ checkList: "Check List",
1549
+ list: "List",
1550
+ linkUrl: "Link URL",
1551
+ tooltipText: "Tooltip Text",
1552
+ tooltipHint: "Tooltip shown on mouse hover",
1553
+ apply: "Apply",
1554
+ cancel: "Cancel",
1555
+ insertLink: "Insert Link",
1556
+ quote: "Quote",
1557
+ insertTable: "Insert Table",
1558
+ insertImage: "Insert Image",
1559
+ insertImageFromUrl: "Insert Image from URL",
1560
+ insert: "Insert",
1561
+ imageUrlRequired: "Image URL (required):",
1562
+ altText: "Alt Text:",
1563
+ title: "Title:",
1564
+ imageDescription: "Description of the image",
1565
+ imageTitle: "Image title",
1566
+ switchToVisualEditor: "Switch to visual editor",
1567
+ switchToRawMarkdown: "Switch to raw markdown"
1568
+ }
1569
+ };
1570
+ var getLanguage = () => {
1571
+ try {
1572
+ if (typeof window !== "undefined" && window.navigator) {
1573
+ return window.navigator.language.split("-")[0];
1574
+ }
1575
+ } catch (e) {
1576
+ }
1577
+ return "en";
1578
+ };
1579
+ var t = (key2) => {
1580
+ const lang = getLanguage();
1581
+ return translations[lang === "ja" ? "ja" : "en"][key2];
1582
+ };
1583
+ var r = (value) => {
1584
+ const lang = getLanguage();
1585
+ const key2 = Object.keys(translations[lang === "ja" ? "ja" : "en"]).find(
1586
+ (k) => translations[lang === "ja" ? "ja" : "en"][k] === value
1587
+ );
1588
+ return key2 || "";
1589
+ };
1590
+
1470
1591
  // src/sink/create-plugin/index.ts
1471
1592
  var createPlugin = (fn) => {
1472
1593
  return { fn };
@@ -2959,98 +3080,6 @@ import styled13 from "@emotion/styled";
2959
3080
  import { useCallback as useCallback3, useRef as useRef3, useState as useState3 } from "react";
2960
3081
  import { useSlateStatic as useSlateStatic3 } from "slate-react";
2961
3082
 
2962
- // src/utils/translations.ts
2963
- var translations = {
2964
- ja: {
2965
- bold: "\u592A\u5B57",
2966
- italic: "\u659C\u4F53",
2967
- strike: "\u53D6\u308A\u6D88\u3057\u7DDA",
2968
- inlineCode: "\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",
2969
- underline: "\u4E0B\u7DDA",
2970
- increaseDepth: "\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",
2971
- decreaseDepth: "\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",
2972
- heading1: "\u898B\u51FA\u30571",
2973
- heading2: "\u898B\u51FA\u30572",
2974
- heading3: "\u898B\u51FA\u30573",
2975
- paragraph: "\u6BB5\u843D",
2976
- paragraphStyle: "\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",
2977
- bulletList: "\u7B87\u6761\u66F8\u304D",
2978
- numberedList: "\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",
2979
- checkList: "\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",
2980
- list: "\u30EA\u30B9\u30C8",
2981
- linkUrl: "\u30EA\u30F3\u30AF\u306EURL",
2982
- tooltipText: "\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",
2983
- tooltipHint: "\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",
2984
- apply: "\u9069\u7528",
2985
- cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
2986
- insertLink: "\u30EA\u30F3\u30AF\u306E\u633F\u5165",
2987
- quote: "\u5F15\u7528",
2988
- insertTable: "\u8868\u306E\u633F\u5165",
2989
- insertImage: "\u753B\u50CF\u306E\u633F\u5165",
2990
- insertImageFromUrl: "URL\u304B\u3089\u753B\u50CF\u3092\u633F\u5165",
2991
- insert: "\u633F\u5165",
2992
- imageUrlRequired: "\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",
2993
- altText: "\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",
2994
- title: "\u30BF\u30A4\u30C8\u30EB\uFF1A",
2995
- imageDescription: "\u753B\u50CF\u306E\u8AAC\u660E",
2996
- imageTitle: "\u753B\u50CF\u306E\u30BF\u30A4\u30C8\u30EB"
2997
- },
2998
- en: {
2999
- bold: "Bold",
3000
- italic: "Italic",
3001
- strike: "Strikethrough",
3002
- inlineCode: "Inline Code",
3003
- underline: "Underline",
3004
- increaseDepth: "Increase Depth",
3005
- decreaseDepth: "Decrease Depth",
3006
- heading1: "Heading 1",
3007
- heading2: "Heading 2",
3008
- heading3: "Heading 3",
3009
- paragraph: "Paragraph",
3010
- paragraphStyle: "Paragraph Style",
3011
- bulletList: "Bullet List",
3012
- numberedList: "Numbered List",
3013
- checkList: "Check List",
3014
- list: "List",
3015
- linkUrl: "Link URL",
3016
- tooltipText: "Tooltip Text",
3017
- tooltipHint: "Tooltip shown on mouse hover",
3018
- apply: "Apply",
3019
- cancel: "Cancel",
3020
- insertLink: "Insert Link",
3021
- quote: "Quote",
3022
- insertTable: "Insert Table",
3023
- insertImage: "Insert Image",
3024
- insertImageFromUrl: "Insert Image from URL",
3025
- insert: "Insert",
3026
- imageUrlRequired: "Image URL (required):",
3027
- altText: "Alt Text:",
3028
- title: "Title:",
3029
- imageDescription: "Description of the image",
3030
- imageTitle: "Image title"
3031
- }
3032
- };
3033
- var getLanguage = () => {
3034
- try {
3035
- if (typeof window !== "undefined" && window.navigator) {
3036
- return window.navigator.language.split("-")[0];
3037
- }
3038
- } catch (e) {
3039
- }
3040
- return "en";
3041
- };
3042
- var t = (key2) => {
3043
- const lang = getLanguage();
3044
- return translations[lang === "ja" ? "ja" : "en"][key2];
3045
- };
3046
- var r = (value) => {
3047
- const lang = getLanguage();
3048
- const key2 = Object.keys(translations[lang === "ja" ? "ja" : "en"]).find(
3049
- (k) => translations[lang === "ja" ? "ja" : "en"][k] === value
3050
- );
3051
- return key2 || "";
3052
- };
3053
-
3054
3083
  // src/shared-styles/index.ts
3055
3084
  import styled12 from "@emotion/styled";
3056
3085
  var $FormGroup = styled12("div")`
@@ -7081,7 +7110,7 @@ var LinkPlus = () => /* @__PURE__ */ jsx52(TablerIcon, { width: "0.5em", viewBox
7081
7110
  var H1 = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
7082
7111
  var H2 = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
7083
7112
  var H3 = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
7084
- var Paragraph2 = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M7 20V4h5.5a4 4 0 0 1 0 9H7" }) });
7113
+ var Normal = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z" }) });
7085
7114
  var Bold = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7" }) });
7086
7115
  var Italic = () => /* @__PURE__ */ jsx52(TablerIcon, { children: /* @__PURE__ */ jsx52("path", { d: "M11 5h6M7 19h6M14 5l-4 14" }) });
7087
7116
  var Link = () => /* @__PURE__ */ jsxs26(TablerIcon, { children: [
@@ -7136,6 +7165,14 @@ var listDepthItems = [
7136
7165
  }
7137
7166
  ];
7138
7167
  var blockItems = [
7168
+ {
7169
+ icon: Normal,
7170
+ title: t("normal"),
7171
+ hotkey: "super+0",
7172
+ action: (editor) => {
7173
+ editor.collapsibleParagraph.convertParagraph();
7174
+ }
7175
+ },
7139
7176
  {
7140
7177
  icon: H1,
7141
7178
  title: t("heading1"),
@@ -7156,14 +7193,6 @@ var blockItems = [
7156
7193
  hotkey: "super+3",
7157
7194
  action: (editor) => editor.heading.convertHeading(3, true),
7158
7195
  active: (editor) => editor.heading.isHeadingActive(3)
7159
- },
7160
- {
7161
- icon: Paragraph2,
7162
- title: t("paragraph"),
7163
- hotkey: "super+0",
7164
- action: (editor) => {
7165
- editor.collapsibleParagraph.convertParagraph();
7166
- }
7167
7196
  }
7168
7197
  ];
7169
7198
  var expandedBlockItems = [...blockItems, "divider", ...listDepthItems];
@@ -7965,7 +7994,7 @@ function useEditor({
7965
7994
  }
7966
7995
 
7967
7996
  // src/entry/index.tsx
7968
- import { jsx as jsx59 } from "react/jsx-runtime";
7997
+ import { jsx as jsx59, jsxs as jsxs31 } from "react/jsx-runtime";
7969
7998
  function renderLeaf({ children, attributes }) {
7970
7999
  return /* @__PURE__ */ jsx59("span", { ...attributes, children });
7971
8000
  }
@@ -7978,6 +8007,8 @@ function Editable2({
7978
8007
  className,
7979
8008
  style
7980
8009
  }) {
8010
+ const [isRawMode, setIsRawMode] = useState12(false);
8011
+ const [rawText, setRawText] = useState12(value);
7981
8012
  const ignoreNextChangeRef = useRef12(false);
7982
8013
  const initialValueRef = useRef12(void 0);
7983
8014
  const prevValueRef = useRef12(void 0);
@@ -8005,8 +8036,8 @@ function Editable2({
8005
8036
  }, [onThrottledSlateChange]);
8006
8037
  if (editor.wysimark.prevValue == null || initialValueRef.current == null) {
8007
8038
  ignoreNextChangeRef.current = true;
8008
- const escapedValue = escapeUrlSlashes(value);
8009
- const children = parse(escapedValue);
8039
+ const valueToProcess = isRawMode ? value : escapeUrlSlashes(value);
8040
+ const children = parse(valueToProcess);
8010
8041
  prevValueRef.current = initialValueRef.current = children;
8011
8042
  editor.wysimark.prevValue = {
8012
8043
  markdown: value,
@@ -8016,8 +8047,8 @@ function Editable2({
8016
8047
  } else {
8017
8048
  if (value !== editor.wysimark.prevValue.markdown) {
8018
8049
  ignoreNextChangeRef.current = true;
8019
- const escapedValue = escapeUrlSlashes(value);
8020
- const documentValue = parse(escapedValue);
8050
+ const valueToProcess = isRawMode ? value : escapeUrlSlashes(value);
8051
+ const documentValue = parse(valueToProcess);
8021
8052
  editor.children = documentValue;
8022
8053
  editor.selection = null;
8023
8054
  Transforms41.select(editor, Editor59.start(editor, [0]));
@@ -8031,52 +8062,148 @@ function Editable2({
8031
8062
  const onBlur = useCallback15(() => {
8032
8063
  onThrottledSlateChange.flush();
8033
8064
  }, [onThrottledSlateChange]);
8034
- return /* @__PURE__ */ jsx59(
8035
- Slate2,
8036
- {
8037
- editor,
8038
- value: initialValueRef.current,
8039
- onChange: onSlateChange,
8040
- children: /* @__PURE__ */ jsx59(
8041
- SinkEditable2,
8042
- {
8043
- renderLeaf,
8044
- onMouseDown: onSinkeEditableMouseDown,
8045
- onBlur,
8046
- placeholder,
8047
- className,
8048
- style
8049
- }
8050
- )
8065
+ const handleRawTextChange = (e) => {
8066
+ const newText = e.target.value;
8067
+ setRawText(newText);
8068
+ onChange(newText);
8069
+ };
8070
+ const applyRawTextToEditor = useCallback15(() => {
8071
+ if (rawText !== editor.getMarkdown()) {
8072
+ editor.setMarkdown(rawText);
8051
8073
  }
8052
- );
8074
+ }, [editor, rawText]);
8075
+ const updateRawTextFromEditor = useCallback15(() => {
8076
+ const currentMarkdown = editor.getMarkdown();
8077
+ setRawText(currentMarkdown);
8078
+ }, [editor]);
8079
+ const handleRawModeToggle = () => {
8080
+ if (isRawMode) {
8081
+ applyRawTextToEditor();
8082
+ } else {
8083
+ updateRawTextFromEditor();
8084
+ }
8085
+ setIsRawMode(!isRawMode);
8086
+ };
8087
+ return /* @__PURE__ */ jsxs31("div", { style: { position: "relative" }, children: [
8088
+ /* @__PURE__ */ jsx59("div", { style: { position: "absolute", top: "5px", right: "25px", zIndex: 10 }, children: /* @__PURE__ */ jsx59(
8089
+ "button",
8090
+ {
8091
+ onClick: handleRawModeToggle,
8092
+ style: {
8093
+ background: "none",
8094
+ border: isRawMode ? "1px solid #4a90e2" : "1px solid transparent",
8095
+ cursor: "pointer",
8096
+ padding: "6px",
8097
+ borderRadius: "4px",
8098
+ backgroundColor: isRawMode ? "rgba(74, 144, 226, 0.1)" : "transparent",
8099
+ boxShadow: isRawMode ? "0 1px 3px rgba(0, 0, 0, 0.1)" : "none",
8100
+ transition: "all 0.2s ease-in-out",
8101
+ display: "flex",
8102
+ alignItems: "center",
8103
+ justifyContent: "center"
8104
+ },
8105
+ title: isRawMode ? t("switchToVisualEditor") : t("switchToRawMarkdown"),
8106
+ children: /* @__PURE__ */ jsxs31("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
8107
+ /* @__PURE__ */ jsx59(
8108
+ "rect",
8109
+ {
8110
+ x: "3",
8111
+ y: "3",
8112
+ width: "18",
8113
+ height: "18",
8114
+ rx: "2",
8115
+ stroke: isRawMode ? "#4a90e2" : "currentColor",
8116
+ strokeWidth: "1.5",
8117
+ fill: isRawMode ? "rgba(74, 144, 226, 0.05)" : "transparent"
8118
+ }
8119
+ ),
8120
+ /* @__PURE__ */ jsx59(
8121
+ "path",
8122
+ {
8123
+ d: "M7 15V9L10 12L13 9V15",
8124
+ stroke: isRawMode ? "#4a90e2" : "currentColor",
8125
+ strokeWidth: "1.5",
8126
+ strokeLinecap: "round",
8127
+ strokeLinejoin: "round"
8128
+ }
8129
+ ),
8130
+ /* @__PURE__ */ jsx59(
8131
+ "path",
8132
+ {
8133
+ d: "M16 9H18V15",
8134
+ stroke: isRawMode ? "#4a90e2" : "currentColor",
8135
+ strokeWidth: "1.5",
8136
+ strokeLinecap: "round",
8137
+ strokeLinejoin: "round"
8138
+ }
8139
+ ),
8140
+ /* @__PURE__ */ jsx59(
8141
+ "path",
8142
+ {
8143
+ d: "M16 12H18",
8144
+ stroke: isRawMode ? "#4a90e2" : "currentColor",
8145
+ strokeWidth: "1.5",
8146
+ strokeLinecap: "round",
8147
+ strokeLinejoin: "round"
8148
+ }
8149
+ )
8150
+ ] })
8151
+ }
8152
+ ) }),
8153
+ /* @__PURE__ */ jsx59("div", { style: { display: isRawMode ? "block" : "none", textAlign: "center" }, children: /* @__PURE__ */ jsx59(
8154
+ "textarea",
8155
+ {
8156
+ value: unescapeUrlSlashes(rawText).replace(/&nbsp;/g, ""),
8157
+ onChange: handleRawTextChange,
8158
+ placeholder,
8159
+ className,
8160
+ style: {
8161
+ width: "calc(100% - 60px)",
8162
+ /* Full width minus 200px on each side */
8163
+ margin: "0 auto",
8164
+ /* Center the textarea */
8165
+ minHeight: "200px",
8166
+ padding: "20px",
8167
+ fontFamily: "monospace",
8168
+ fontSize: "14px",
8169
+ color: "#333",
8170
+ lineHeight: "1.5",
8171
+ backgroundColor: "#fff",
8172
+ border: "1px solid #ddd",
8173
+ borderRadius: "4px",
8174
+ ...style
8175
+ }
8176
+ }
8177
+ ) }),
8178
+ /* @__PURE__ */ jsx59("div", { style: { display: isRawMode ? "none" : "block" }, children: /* @__PURE__ */ jsx59(
8179
+ Slate2,
8180
+ {
8181
+ editor,
8182
+ value: initialValueRef.current,
8183
+ onChange: onSlateChange,
8184
+ children: /* @__PURE__ */ jsx59(
8185
+ SinkEditable2,
8186
+ {
8187
+ renderLeaf,
8188
+ onMouseDown: onSinkeEditableMouseDown,
8189
+ onBlur,
8190
+ placeholder,
8191
+ className,
8192
+ style
8193
+ }
8194
+ )
8195
+ }
8196
+ ) })
8197
+ ] });
8053
8198
  }
8054
8199
 
8055
8200
  // src/index.tsx
8056
8201
  import { jsx as jsx60 } from "react/jsx-runtime";
8057
- function escapeUrlSlashes(text) {
8058
- const markdownLinkPattern = /\[([^\]]+)\]\(([^)]+)\)/g;
8059
- const links = [];
8060
- let linkIndex = 0;
8061
- const textWithoutLinks = text.replace(markdownLinkPattern, (match) => {
8062
- links.push(match);
8063
- return `__MARKDOWN_LINK_${linkIndex++}__`;
8064
- });
8065
- const urlPattern = /(https?:\/\/[^\s]+)/g;
8066
- const textWithEscapedUrls = textWithoutLinks.replace(urlPattern, (url) => {
8067
- return url.replace(/\//g, "\\/");
8068
- });
8069
- let result = textWithEscapedUrls;
8070
- for (let i = 0; i < links.length; i++) {
8071
- result = result.replace(`__MARKDOWN_LINK_${i}__`, links[i]);
8072
- }
8073
- return result;
8074
- }
8075
8202
  function StandaloneEditor({
8076
8203
  standaloneOptions: { onChange, placeholder, className, ...options },
8077
8204
  standaloneMethodsRef
8078
8205
  }) {
8079
- const [markdown, setMarkdown] = useState12(options.initialMarkdown || "");
8206
+ const [markdown, setMarkdown] = useState13(options.initialMarkdown || "");
8080
8207
  const markdownRef = useRef13(markdown);
8081
8208
  const editor = useEditor(options);
8082
8209
  markdownRef.current = markdown;
@@ -8144,7 +8271,6 @@ function createWysimark(containerElement, options) {
8144
8271
  export {
8145
8272
  Editable2 as Editable,
8146
8273
  createWysimark,
8147
- escapeUrlSlashes,
8148
8274
  useEditor
8149
8275
  };
8150
8276
  //# sourceMappingURL=index.mjs.map