@meowdown/core 0.81.2 → 0.82.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.d.ts CHANGED
@@ -1110,7 +1110,38 @@ interface EditorConfig extends InlineMarkOptions, FollowLinkHandlers, FilePasteO
1110
1110
  wikilinkEnabled?: boolean | undefined;
1111
1111
  placeholder?: PlaceholderOptions$1['placeholder'] | undefined;
1112
1112
  readOnly?: boolean | undefined;
1113
+ /**
1114
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/spellcheck
1115
+ */
1113
1116
  spellCheck?: boolean | undefined;
1117
+ /**
1118
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/writingsuggestions
1119
+ */
1120
+ writingSuggestions?: boolean | undefined;
1121
+ /**
1122
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/autocorrect
1123
+ */
1124
+ autoCorrect?: boolean | undefined;
1125
+ /**
1126
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/autocapitalize
1127
+ */
1128
+ autoCapitalize?: 'off' | 'sentences' | 'words' | 'characters' | undefined;
1129
+ /**
1130
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/enterkeyhint
1131
+ */
1132
+ enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined;
1133
+ /**
1134
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir
1135
+ */
1136
+ dir?: 'ltr' | 'rtl' | 'auto' | undefined;
1137
+ /**
1138
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang
1139
+ */
1140
+ lang?: string | undefined;
1141
+ /**
1142
+ * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
1143
+ */
1144
+ ariaLabel?: string | undefined;
1114
1145
  editorClassName?: string | undefined;
1115
1146
  }
1116
1147
  //#endregion
package/dist/index.js CHANGED
@@ -17,9 +17,9 @@ import { defineEnterRule } from "@prosekit/extensions/enter-rule";
17
17
  import { InputRule } from "@prosekit/pm/inputrules";
18
18
  import { createTextBlockEnterRule } from "prosemirror-enter-rules";
19
19
  import { NO_BREAK_SPACE } from "unicode-by-name";
20
+ import { fromDom } from "hast-util-from-dom";
20
21
  import { defaultHandlers } from "hast-util-to-mdast";
21
22
  import { defaultHandlers as defaultHandlers$1 } from "mdast-util-to-markdown";
22
- import rehypeParse from "rehype-parse";
23
23
  import rehypeRemark from "rehype-remark";
24
24
  import remarkGfm from "remark-gfm";
25
25
  import remarkStringify from "remark-stringify";
@@ -945,7 +945,7 @@ const textToMarkdown = (node, parent, state, info) => {
945
945
  }, info);
946
946
  };
947
947
  function createProcessor() {
948
- return unified().use(rehypeParse).use(rehypeRemark, { handlers: {
948
+ return unified().use(rehypeRemark, { handlers: {
949
949
  mark: markToHighlight,
950
950
  li: taskAwareListItem
951
951
  } }).use(remarkGfm).use(remarkStringify, {
@@ -967,8 +967,11 @@ const getProcessor = once(createProcessor);
967
967
  /**
968
968
  * Convert HTML into Markdown text.
969
969
  */
970
- function htmlToMarkdown(html) {
971
- return String(getProcessor().processSync(html));
970
+ function htmlToMarkdown(html, parser) {
971
+ const processor = getProcessor();
972
+ const domDoc = (parser ?? new window.DOMParser()).parseFromString(html, "text/html");
973
+ const hast = fromDom(domDoc);
974
+ return processor.stringify(processor.runSync(hast));
972
975
  }
973
976
 
974
977
  //#endregion
@@ -2110,6 +2113,13 @@ const refreshKeys = /* @__PURE__ */ new Set([
2110
2113
  "placeholder",
2111
2114
  "readOnly",
2112
2115
  "spellCheck",
2116
+ "writingSuggestions",
2117
+ "autoCorrect",
2118
+ "autoCapitalize",
2119
+ "enterKeyHint",
2120
+ "dir",
2121
+ "lang",
2122
+ "ariaLabel",
2113
2123
  "editorClassName"
2114
2124
  ]);
2115
2125
  function updateEditorConfig(editor, patch) {
@@ -7348,10 +7358,17 @@ function defineEditorExtensionImpl(options) {
7348
7358
  },
7349
7359
  strategy: "doc"
7350
7360
  }), defineReadonly((state) => !!getEditorConfig(state).readOnly), defineViewAttributes((state) => {
7351
- const { editorClassName, spellCheck } = getEditorConfig(state);
7361
+ const config = getEditorConfig(state);
7352
7362
  const attributes = { class: "meowdown-content" };
7353
- if (editorClassName) attributes.class += ` ${editorClassName}`;
7354
- if (spellCheck != null) attributes.spellcheck = String(spellCheck);
7363
+ if (config.editorClassName) attributes.class += ` ${config.editorClassName}`;
7364
+ if (config.spellCheck != null) attributes.spellcheck = String(config.spellCheck);
7365
+ if (config.writingSuggestions != null) attributes.writingsuggestions = String(config.writingSuggestions);
7366
+ if (config.autoCorrect != null) attributes.autocorrect = config.autoCorrect ? "on" : "off";
7367
+ if (config.autoCapitalize != null) attributes.autocapitalize = config.autoCapitalize;
7368
+ if (config.enterKeyHint != null) attributes.enterkeyhint = config.enterKeyHint;
7369
+ if (config.dir != null) attributes.dir = config.dir;
7370
+ if (config.lang != null) attributes.lang = config.lang;
7371
+ if (config.ariaLabel != null) attributes["aria-label"] = config.ariaLabel;
7355
7372
  return attributes;
7356
7373
  }), defineCodeBlockSyntaxHighlight(), defineCrossEditorDrag(), defineClickBelow(), defineEscapeCollapse(), defineSoftBreak(), defineMoveBlock(), defineSelectDocBoundary(), defineSingleParagraph(), defineInlineMarkPlugin(getEditorConfig), defineInlineToggle(), defineLinkCommands(), defineWikilink(), defineMath(), defineMarkMode(getMarkMode), defineClipboard(), defineScrollToSelection(), defineHiddenRunCaret(), defineSystemSubstitutionGuard(), defineAtomMarkNavigation({ marks: ATOM_SOURCE_MARK_NAMES.map((name) => ({
7357
7374
  name,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/core",
3
3
  "type": "module",
4
- "version": "0.81.2",
4
+ "version": "0.82.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,6 +35,7 @@
35
35
  "@prosekit/extensions": "^0.18.4",
36
36
  "@prosekit/pm": "^0.1.20",
37
37
  "@prosekit/web": "^0.9.4",
38
+ "hast-util-from-dom": "^5.0.1",
38
39
  "hast-util-to-mdast": "^10.1.2",
39
40
  "katex": "^0.19.0",
40
41
  "lru.min": "^1.1.5",
@@ -44,7 +45,6 @@
44
45
  "prosemirror-enter-rules": "^0.1.6",
45
46
  "prosemirror-flat-list": "^0.7.3",
46
47
  "prosemirror-highlight": "^0.16.0",
47
- "rehype-parse": "^9.0.1",
48
48
  "rehype-remark": "^10.0.1",
49
49
  "remark-gfm": "^4.0.1",
50
50
  "remark-stringify": "^11.0.0",
@@ -58,11 +58,11 @@
58
58
  "@tsdown/css": "^0.23.1",
59
59
  "@types/hast": "^3.0.5",
60
60
  "@types/mdast": "^4.0.4",
61
- "@vitest/browser-playwright": "^5.0.3",
61
+ "@vitest/browser-playwright": "^5.0.5",
62
62
  "dedent": "^1.7.2",
63
63
  "diffable-html-snapshot": "^0.3.0",
64
64
  "tsdown": "^0.23.1",
65
- "vitest": "^5.0.3"
65
+ "vitest": "^5.0.5"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"