@meowdown/core 0.64.3 → 0.65.1
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 +86 -40
- package/dist/index.js +305 -197
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -810,7 +810,7 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
810
810
|
Commands: {
|
|
811
811
|
setMarkMode: [mode: MarkMode];
|
|
812
812
|
};
|
|
813
|
-
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
813
|
+
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
814
814
|
Commands: {
|
|
815
815
|
insertMarkdown: [markdown: string];
|
|
816
816
|
insertTrigger: [text: string];
|
|
@@ -1055,6 +1055,11 @@ interface FileClickPayload {
|
|
|
1055
1055
|
* pill. Read modifier keys or position a popover from it.
|
|
1056
1056
|
*/
|
|
1057
1057
|
event: MouseEvent | KeyboardEvent;
|
|
1058
|
+
/**
|
|
1059
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1060
|
+
* beyond the gesture that triggered the activation.
|
|
1061
|
+
*/
|
|
1062
|
+
mod: boolean;
|
|
1058
1063
|
}
|
|
1059
1064
|
type FileClickHandler = (payload: FileClickPayload) => void;
|
|
1060
1065
|
/**
|
|
@@ -1140,6 +1145,45 @@ declare function getFileKind(href: string): string;
|
|
|
1140
1145
|
*/
|
|
1141
1146
|
declare function defineFileView(options?: FileViewOptions): PlainExtension;
|
|
1142
1147
|
//#endregion
|
|
1148
|
+
//#region src/extensions/image-click.d.ts
|
|
1149
|
+
/**
|
|
1150
|
+
* Payload for {@link ImageClickHandler}.
|
|
1151
|
+
*/
|
|
1152
|
+
interface ImageClickPayload {
|
|
1153
|
+
/**
|
|
1154
|
+
* The resolved source from `` or a claimed `![[target]]`.
|
|
1155
|
+
*/
|
|
1156
|
+
src: string;
|
|
1157
|
+
/**
|
|
1158
|
+
* The image alt text.
|
|
1159
|
+
*/
|
|
1160
|
+
alt: string;
|
|
1161
|
+
/**
|
|
1162
|
+
* The originating click or touch tap, or the `Enter`/`Mod-Enter` key press
|
|
1163
|
+
* that followed the selected image. Read the target or position a popover
|
|
1164
|
+
* from it; a touch surface delivers the `touchend` instead of a click.
|
|
1165
|
+
*/
|
|
1166
|
+
event: MouseEvent | TouchEvent | KeyboardEvent;
|
|
1167
|
+
/**
|
|
1168
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1169
|
+
* beyond the gesture that triggered the activation.
|
|
1170
|
+
*/
|
|
1171
|
+
mod: boolean;
|
|
1172
|
+
}
|
|
1173
|
+
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
1174
|
+
/**
|
|
1175
|
+
* Call `onClick` when the user clicks or taps a rendered image preview, with
|
|
1176
|
+
* the image's markdown `src`, `alt`, and the originating event.
|
|
1177
|
+
*
|
|
1178
|
+
* Touch taps are handled from `touchend` rather than the synthetic click:
|
|
1179
|
+
* previews live inside the editor contenteditable, and iOS WebKit's
|
|
1180
|
+
* tap-to-focus is a native gesture default action that only cancelling the
|
|
1181
|
+
* `touchend` can suppress — otherwise a tap briefly focuses the editor and
|
|
1182
|
+
* raises the software keyboard before the handler opens its own surface
|
|
1183
|
+
* (such as a lightbox).
|
|
1184
|
+
*/
|
|
1185
|
+
declare function defineImageClickHandler(onClick: ImageClickHandler): PlainExtension;
|
|
1186
|
+
//#endregion
|
|
1143
1187
|
//#region src/extensions/link-click.d.ts
|
|
1144
1188
|
interface LinkClickPayload {
|
|
1145
1189
|
href: string;
|
|
@@ -1147,6 +1191,11 @@ interface LinkClickPayload {
|
|
|
1147
1191
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1148
1192
|
*/
|
|
1149
1193
|
event: MouseEvent | KeyboardEvent;
|
|
1194
|
+
/**
|
|
1195
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1196
|
+
* beyond the gesture that triggered the activation.
|
|
1197
|
+
*/
|
|
1198
|
+
mod: boolean;
|
|
1150
1199
|
}
|
|
1151
1200
|
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
1152
1201
|
interface LinkCopyPayload {
|
|
@@ -1171,6 +1220,11 @@ interface TagClickPayload {
|
|
|
1171
1220
|
* Read modifier keys or position a popover from it.
|
|
1172
1221
|
*/
|
|
1173
1222
|
event: MouseEvent | KeyboardEvent;
|
|
1223
|
+
/**
|
|
1224
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1225
|
+
* beyond the gesture that triggered the activation.
|
|
1226
|
+
*/
|
|
1227
|
+
mod: boolean;
|
|
1174
1228
|
}
|
|
1175
1229
|
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
1176
1230
|
/**
|
|
@@ -1192,6 +1246,11 @@ interface WikilinkClickPayload {
|
|
|
1192
1246
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1193
1247
|
*/
|
|
1194
1248
|
event: MouseEvent | KeyboardEvent;
|
|
1249
|
+
/**
|
|
1250
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1251
|
+
* beyond the gesture that triggered the activation.
|
|
1252
|
+
*/
|
|
1253
|
+
mod: boolean;
|
|
1195
1254
|
}
|
|
1196
1255
|
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
1197
1256
|
/**
|
|
@@ -1207,49 +1266,24 @@ interface FollowLinkHandlers {
|
|
|
1207
1266
|
onTagClick?: TagClickHandler;
|
|
1208
1267
|
onFileClick?: FileClickHandler;
|
|
1209
1268
|
onLinkClick?: LinkClickHandler;
|
|
1269
|
+
onImageClick?: ImageClickHandler;
|
|
1210
1270
|
}
|
|
1211
1271
|
/**
|
|
1212
1272
|
* Binds `Mod-Enter` to follow the wikilink, tag, file pill, or Markdown link
|
|
1213
|
-
* under the caret, and plain `Enter` to follow a selected atom unit
|
|
1214
|
-
* the same handlers a click does.
|
|
1215
|
-
* the
|
|
1216
|
-
*
|
|
1217
|
-
* keymap
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
//#endregion
|
|
1221
|
-
//#region src/extensions/image-click.d.ts
|
|
1222
|
-
/**
|
|
1223
|
-
* Payload for {@link ImageClickHandler}.
|
|
1224
|
-
*/
|
|
1225
|
-
interface ImageClickPayload {
|
|
1226
|
-
/**
|
|
1227
|
-
* The resolved source from `` or a claimed `![[target]]`.
|
|
1228
|
-
*/
|
|
1229
|
-
src: string;
|
|
1230
|
-
/**
|
|
1231
|
-
* The image alt text.
|
|
1232
|
-
*/
|
|
1233
|
-
alt: string;
|
|
1234
|
-
/**
|
|
1235
|
-
* The originating click or touch tap. Read the target or position a popover
|
|
1236
|
-
* from it; a touch surface delivers the `touchend` instead of a click.
|
|
1237
|
-
*/
|
|
1238
|
-
event: MouseEvent | TouchEvent;
|
|
1239
|
-
}
|
|
1240
|
-
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
1241
|
-
/**
|
|
1242
|
-
* Call `onClick` when the user clicks or taps a rendered image preview, with
|
|
1243
|
-
* the image's markdown `src`, `alt`, and the originating event.
|
|
1273
|
+
* under the caret, and plain `Enter` to follow a selected atom unit (a
|
|
1274
|
+
* wikilink, file pill, or image), firing the same handlers a click does.
|
|
1275
|
+
* "Under the caret" means strictly inside the unit: a caret merely touching
|
|
1276
|
+
* a unit's edge is next to it, not on it.
|
|
1277
|
+
* Off a link, `Mod-Enter` falls through so the list keymap keeps cycling
|
|
1278
|
+
* checkbox tasks; off a selected unit, `Enter` falls through to the regular
|
|
1279
|
+
* split. High priority puts this ahead of every keymap binding.
|
|
1244
1280
|
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
* raises the software keyboard before the handler opens its own surface
|
|
1250
|
-
* (such as a lightbox).
|
|
1281
|
+
* A selected-unit follow reports `mod: true` when the platform's mod key
|
|
1282
|
+
* (`⌘` on Apple, `Ctrl` elsewhere) was held beyond its plain-`Enter` trigger;
|
|
1283
|
+
* a caret follow always reports `mod: false`, its mod key being the trigger
|
|
1284
|
+
* itself.
|
|
1251
1285
|
*/
|
|
1252
|
-
declare function
|
|
1286
|
+
declare function defineFollowLinkHandler(handlers: FollowLinkHandlers): PlainExtension;
|
|
1253
1287
|
//#endregion
|
|
1254
1288
|
//#region src/extensions/image.d.ts
|
|
1255
1289
|
type ImageUrlResolver = (src: string) => string | undefined;
|
|
@@ -1362,6 +1396,9 @@ type NodeName = (typeof NODE_NAMES)[number];
|
|
|
1362
1396
|
declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boolean;
|
|
1363
1397
|
//#endregion
|
|
1364
1398
|
//#region src/extensions/spell-check.d.ts
|
|
1399
|
+
/**
|
|
1400
|
+
* @deprecated This will be removed in future versions.
|
|
1401
|
+
*/
|
|
1365
1402
|
declare function defineSpellCheckPlugin(spellCheck: boolean): PlainExtension;
|
|
1366
1403
|
//#endregion
|
|
1367
1404
|
//#region src/extensions/substitution.d.ts
|
|
@@ -1455,6 +1492,15 @@ declare function getTextblockDisplayText(textblock: ProseMirrorNode): string;
|
|
|
1455
1492
|
*/
|
|
1456
1493
|
declare function formatFileSize(bytes: number): string;
|
|
1457
1494
|
//#endregion
|
|
1495
|
+
//#region src/utils/is-mod-event.d.ts
|
|
1496
|
+
/**
|
|
1497
|
+
* Whether the platform's mod key is held on `event`: `Command` on Apple, `Ctrl` elsewhere.
|
|
1498
|
+
*/
|
|
1499
|
+
declare function isModEvent(event: MouseEvent | KeyboardEvent | TouchEvent | {
|
|
1500
|
+
metaKey: boolean;
|
|
1501
|
+
ctrlKey: boolean;
|
|
1502
|
+
}): boolean;
|
|
1503
|
+
//#endregion
|
|
1458
1504
|
//#region src/utils/katex-chunk.d.ts
|
|
1459
1505
|
type KaTeXRender = typeof render;
|
|
1460
1506
|
//#endregion
|
|
@@ -1492,4 +1538,4 @@ declare function getSelectedText(state: EditorState): string;
|
|
|
1492
1538
|
*/
|
|
1493
1539
|
declare function getVirtualElementFromRange(view: EditorView, range: PositionRange): VirtualElement;
|
|
1494
1540
|
//#endregion
|
|
1495
|
-
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineVirtualCaret, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getIsComposing, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
|
1541
|
+
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineVirtualCaret, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getIsComposing, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isModEvent, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -2537,7 +2537,7 @@ const emptyBatchSetMarkStep = new BatchSetMarkStep([]);
|
|
|
2537
2537
|
//#endregion
|
|
2538
2538
|
//#region src/extensions/magic-comment.ts
|
|
2539
2539
|
const MAGIC_COMMENT_RE = /^<!--\s*(\{[^}]*\})\s*-->$/;
|
|
2540
|
-
const TRAILING_MAGIC_COMMENT_RE =
|
|
2540
|
+
const TRAILING_MAGIC_COMMENT_RE = /(?:<!--\s*\{[^}]*\}\s*-->)+$/;
|
|
2541
2541
|
/**
|
|
2542
2542
|
* Read the metadata out of a `<!-- {...} -->` comment, or `undefined` when the
|
|
2543
2543
|
* text is not a comment carrying at least one recognized field.
|
|
@@ -2570,7 +2570,7 @@ function formatMagicComment(magic) {
|
|
|
2570
2570
|
return `<!-- ${JSON.stringify(magic)} -->`;
|
|
2571
2571
|
}
|
|
2572
2572
|
/**
|
|
2573
|
-
* Drop
|
|
2573
|
+
* Drop the trailing run of magic comments from the source text.
|
|
2574
2574
|
*/
|
|
2575
2575
|
function stripMagicComment(source) {
|
|
2576
2576
|
return source.replace(TRAILING_MAGIC_COMMENT_RE, "");
|
|
@@ -2889,12 +2889,11 @@ function walk(nodes, parentMarks, rangeStart, rangeEnd, text, marks, out, option
|
|
|
2889
2889
|
let pos = rangeStart;
|
|
2890
2890
|
for (let index = 0; index < nodes.length; index++) {
|
|
2891
2891
|
const node = nodes[index];
|
|
2892
|
+
if (node.to <= pos) continue;
|
|
2892
2893
|
if (node.from > pos) emit(out, pos, node.from, parentMarks);
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
if (trailing) index++;
|
|
2897
|
-
pos = trailing ? trailing.to : node.to;
|
|
2894
|
+
const atomEnd = walkAtomChild(nodes, index, parentMarks, text, marks, out, options, context);
|
|
2895
|
+
if (atomEnd != null) {
|
|
2896
|
+
pos = atomEnd;
|
|
2898
2897
|
continue;
|
|
2899
2898
|
}
|
|
2900
2899
|
walkNode(node, parentMarks, text, marks, out, options, context);
|
|
@@ -2905,8 +2904,6 @@ function walk(nodes, parentMarks, rangeStart, rangeEnd, text, marks, out, option
|
|
|
2905
2904
|
function walkNode(node, parentMarks, text, marks, out, options, context) {
|
|
2906
2905
|
switch (node.type) {
|
|
2907
2906
|
case LEZER_NODE_IDS.Link: return walkLink(node, parentMarks, text, marks, out, options, context);
|
|
2908
|
-
case LEZER_NODE_IDS.Wikilink: return walkWikilink(node, parentMarks, text, marks, out);
|
|
2909
|
-
case LEZER_NODE_IDS.WikiEmbed: return walkWikiEmbed(node, parentMarks, text, marks, out, options);
|
|
2910
2907
|
case LEZER_NODE_IDS.InlineMath: return walkMath(node, parentMarks, text, marks, out);
|
|
2911
2908
|
case LEZER_NODE_IDS.Autolink: return walkAutolink(node, parentMarks, text, marks, out);
|
|
2912
2909
|
case LEZER_NODE_IDS.URL: return walkURL(node, parentMarks, text, marks, out);
|
|
@@ -2914,6 +2911,31 @@ function walkNode(node, parentMarks, text, marks, out, options, context) {
|
|
|
2914
2911
|
}
|
|
2915
2912
|
}
|
|
2916
2913
|
/**
|
|
2914
|
+
* Walk `nodes[index]` when it is a source-backed atom (wikilink, wiki embed,
|
|
2915
|
+
* or image); returns the source position after everything the atom consumed,
|
|
2916
|
+
* or undefined for any other node type. An image also consumes the magic
|
|
2917
|
+
* comments chained behind it, so callers must skip children ending at or
|
|
2918
|
+
* before the returned position. Shared by `walk` and `walkResolvedLink` so an
|
|
2919
|
+
* atom behaves the same at the top level and inside a link label.
|
|
2920
|
+
*/
|
|
2921
|
+
function walkAtomChild(nodes, index, parentMarks, text, marks, out, options, context) {
|
|
2922
|
+
const node = nodes[index];
|
|
2923
|
+
switch (node.type) {
|
|
2924
|
+
case LEZER_NODE_IDS.Wikilink:
|
|
2925
|
+
walkWikilink(node, parentMarks, text, marks, out);
|
|
2926
|
+
return node.to;
|
|
2927
|
+
case LEZER_NODE_IDS.WikiEmbed:
|
|
2928
|
+
walkWikiEmbed(node, parentMarks, text, marks, out, options);
|
|
2929
|
+
return node.to;
|
|
2930
|
+
case LEZER_NODE_IDS.Image: {
|
|
2931
|
+
const trailing = takeMagicComments(nodes, index, text);
|
|
2932
|
+
walkImage(node, parentMarks, text, marks, out, options, context, trailing);
|
|
2933
|
+
return trailing ? trailing.to : node.to;
|
|
2934
|
+
}
|
|
2935
|
+
default: return;
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
/**
|
|
2917
2939
|
* A node with no source-backed atom of its own: it contributes its `mdPack` and
|
|
2918
2940
|
* syntax marks, then recurses into its children.
|
|
2919
2941
|
*/
|
|
@@ -3131,25 +3153,17 @@ function walkResolvedLink(node, parts, resolution, parentMarks, text, marks, out
|
|
|
3131
3153
|
});
|
|
3132
3154
|
const base = [...parentMarks, pack];
|
|
3133
3155
|
let pos = node.from;
|
|
3134
|
-
for (
|
|
3156
|
+
for (let index = 0; index < node.children.length; index++) {
|
|
3157
|
+
const child = node.children[index];
|
|
3158
|
+
if (child.to <= pos) continue;
|
|
3135
3159
|
if (child.from > pos) {
|
|
3136
3160
|
const childMarks = inLabel(pos) ? [...base, linkTextMark] : base;
|
|
3137
3161
|
emit(out, pos, child.from, childMarks);
|
|
3138
3162
|
}
|
|
3139
3163
|
const baseForChild = inLabel(child.from) ? [...base, linkTextMark] : base;
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
pos =
|
|
3143
|
-
continue;
|
|
3144
|
-
}
|
|
3145
|
-
if (child.type === LEZER_NODE_IDS.WikiEmbed) {
|
|
3146
|
-
walkWikiEmbed(child, baseForChild, text, marks, out, options);
|
|
3147
|
-
pos = child.to;
|
|
3148
|
-
continue;
|
|
3149
|
-
}
|
|
3150
|
-
if (child.type === LEZER_NODE_IDS.Image) {
|
|
3151
|
-
walkImage(child, baseForChild, text, marks, out, options, context);
|
|
3152
|
-
pos = child.to;
|
|
3164
|
+
const atomEnd = walkAtomChild(node.children, index, baseForChild, text, marks, out, options, context);
|
|
3165
|
+
if (atomEnd != null) {
|
|
3166
|
+
pos = atomEnd;
|
|
3153
3167
|
continue;
|
|
3154
3168
|
}
|
|
3155
3169
|
if (isReference && child.type === LEZER_NODE_IDS.LinkLabel) {
|
|
@@ -3170,19 +3184,33 @@ function walkResolvedLink(node, parts, resolution, parentMarks, text, marks, out
|
|
|
3170
3184
|
}
|
|
3171
3185
|
if (pos < node.to) emit(out, pos, node.to, base);
|
|
3172
3186
|
}
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3187
|
+
/**
|
|
3188
|
+
* The run of magic comments chained immediately behind `nodes[index]` (an
|
|
3189
|
+
* image), or undefined when no magic comment directly abuts it. The first
|
|
3190
|
+
* comment's data wins: a rewrite of an unfolded image inserted the fresh
|
|
3191
|
+
* comment right at the image's end, so in a stacked run left is newest.
|
|
3192
|
+
*/
|
|
3193
|
+
function takeMagicComments(nodes, index, text) {
|
|
3194
|
+
let magic;
|
|
3195
|
+
let to = nodes[index].to;
|
|
3196
|
+
for (let i = index + 1; i < nodes.length; i++) {
|
|
3197
|
+
const next = nodes[i];
|
|
3198
|
+
if (next.type !== LEZER_NODE_IDS.Comment || next.from !== to) break;
|
|
3199
|
+
const parsed = parseMagicComment(text.slice(next.from, next.to));
|
|
3200
|
+
if (!parsed) break;
|
|
3201
|
+
magic ??= parsed;
|
|
3202
|
+
to = next.to;
|
|
3203
|
+
}
|
|
3176
3204
|
if (!magic) return void 0;
|
|
3177
3205
|
return {
|
|
3178
3206
|
magic,
|
|
3179
|
-
to
|
|
3207
|
+
to
|
|
3180
3208
|
};
|
|
3181
3209
|
}
|
|
3182
3210
|
/**
|
|
3183
3211
|
* Special walker for a direct image ``.
|
|
3184
3212
|
*
|
|
3185
|
-
* A `trailing` magic
|
|
3213
|
+
* A `trailing` run of magic comments immediately after the image (e.g.
|
|
3186
3214
|
* `<!-- {"width":320} -->`) is folded into the mark range so it round-trips as
|
|
3187
3215
|
* source while supplying the image's `width`.
|
|
3188
3216
|
*/
|
|
@@ -4428,11 +4456,13 @@ function defineMeowdownListSerializer() {
|
|
|
4428
4456
|
return (...args) => {
|
|
4429
4457
|
return {
|
|
4430
4458
|
...nodesFromSchema(...args),
|
|
4431
|
-
list: (node) =>
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4459
|
+
list: (node) => {
|
|
4460
|
+
return listToDOM({
|
|
4461
|
+
node,
|
|
4462
|
+
nativeList: true,
|
|
4463
|
+
getAttributes: getListClipboardAttributes
|
|
4464
|
+
});
|
|
4465
|
+
}
|
|
4436
4466
|
};
|
|
4437
4467
|
};
|
|
4438
4468
|
}
|
|
@@ -5541,6 +5571,33 @@ function defineSelectDocBoundary() {
|
|
|
5541
5571
|
});
|
|
5542
5572
|
}
|
|
5543
5573
|
|
|
5574
|
+
//#endregion
|
|
5575
|
+
//#region src/extensions/system-substitution-guard.ts
|
|
5576
|
+
const EM_DASH = "—";
|
|
5577
|
+
/**
|
|
5578
|
+
* Block the macOS "smart dashes" rewrite. With the `spellcheck` attribute on,
|
|
5579
|
+
* WebKit rewrites already-typed `--` near the caret into an em dash and
|
|
5580
|
+
* delivers the rewrite as a cancelable `beforeinput` with
|
|
5581
|
+
* `inputType: 'insertReplacementText'`. That corrupts Markdown such as the
|
|
5582
|
+
* `-->` closing an image sizing comment, so cancel any replacement that
|
|
5583
|
+
* inserts an em dash; word-level autocorrect passes through.
|
|
5584
|
+
*/
|
|
5585
|
+
function defineSystemSubstitutionGuard() {
|
|
5586
|
+
const plugin = new Plugin({ props: { handleDOMEvents: { beforeinput: (view, event) => {
|
|
5587
|
+
if (event.inputType !== "insertReplacementText") return false;
|
|
5588
|
+
if (!(event.dataTransfer?.getData("text/plain") || event.data || "").includes(EM_DASH)) return false;
|
|
5589
|
+
event.preventDefault();
|
|
5590
|
+
const { doc, selection } = view.state;
|
|
5591
|
+
requestAnimationFrame(() => {
|
|
5592
|
+
const { state } = view;
|
|
5593
|
+
if (view.isDestroyed || state.doc !== doc || state.selection.eq(selection)) return;
|
|
5594
|
+
view.dispatch(state.tr.setSelection(selection));
|
|
5595
|
+
});
|
|
5596
|
+
return true;
|
|
5597
|
+
} } } });
|
|
5598
|
+
return withPriority$1(definePlugin(plugin), Priority$1.highest);
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5544
5601
|
//#endregion
|
|
5545
5602
|
//#region src/extensions/view-attributes.ts
|
|
5546
5603
|
/**
|
|
@@ -5555,7 +5612,7 @@ function defineViewAttributes(attributes) {
|
|
|
5555
5612
|
//#endregion
|
|
5556
5613
|
//#region src/extensions/extension.ts
|
|
5557
5614
|
function defineEditorExtensionImpl(options) {
|
|
5558
|
-
return union(defineMeowdownParagraph(), defineDoc(), defineDocFrontmatterAttr(), defineText(), defineBlockquote(), defineMeowdownList(), defineHeading(), defineTable(), defineCodeBlock$1(), defineMeowdownHorizontalRule(), defineHTMLComment(), defineInlineMarks(), defineViewAttributes({ class: "meowdown-content" }), defineCodeBlockSyntaxHighlight(), defineCrossEditorDrag(), defineEscapeCollapse(), defineMoveBlock(), defineSelectDocBoundary(), defineInlineMarkPlugin(options), defineInlineToggle(), defineLinkCommands(), defineWikilink(), defineMath(), defineMarkMode(options.markMode ?? "focus"), defineClipboard(), defineScrollToSelection(), defineHiddenRunCaret(), defineAtomMarkNavigation({ marks: ATOM_SOURCE_MARK_NAMES.map((name) => ({
|
|
5615
|
+
return union(defineMeowdownParagraph(), defineDoc(), defineDocFrontmatterAttr(), defineText(), defineBlockquote(), defineMeowdownList(), defineHeading(), defineTable(), defineCodeBlock$1(), defineMeowdownHorizontalRule(), defineHTMLComment(), defineInlineMarks(), defineViewAttributes({ class: "meowdown-content" }), defineCodeBlockSyntaxHighlight(), defineCrossEditorDrag(), defineEscapeCollapse(), defineMoveBlock(), defineSelectDocBoundary(), defineInlineMarkPlugin(options), defineInlineToggle(), defineLinkCommands(), defineWikilink(), defineMath(), defineMarkMode(options.markMode ?? "focus"), defineClipboard(), defineScrollToSelection(), defineHiddenRunCaret(), defineSystemSubstitutionGuard(), defineAtomMarkNavigation({ marks: ATOM_SOURCE_MARK_NAMES.map((name) => ({
|
|
5559
5616
|
name,
|
|
5560
5617
|
modes: [
|
|
5561
5618
|
"hide",
|
|
@@ -6430,6 +6487,15 @@ function defineExitBoundaryHandler(onExitBoundary) {
|
|
|
6430
6487
|
return withPriority$1(definePlugin(createExitBoundaryPlugin(onExitBoundary)), Priority$1.low);
|
|
6431
6488
|
}
|
|
6432
6489
|
|
|
6490
|
+
//#endregion
|
|
6491
|
+
//#region src/utils/is-mod-event.ts
|
|
6492
|
+
/**
|
|
6493
|
+
* Whether the platform's mod key is held on `event`: `Command` on Apple, `Ctrl` elsewhere.
|
|
6494
|
+
*/
|
|
6495
|
+
function isModEvent(event) {
|
|
6496
|
+
return isApple ? event.metaKey : event.ctrlKey;
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6433
6499
|
//#endregion
|
|
6434
6500
|
//#region src/extensions/file-click.ts
|
|
6435
6501
|
const fileClickKey = new PluginKey("meowdown-file-click");
|
|
@@ -6438,6 +6504,8 @@ function findFileAt(state, pos) {
|
|
|
6438
6504
|
if (!range) return;
|
|
6439
6505
|
const { href, name } = range.mark.attrs;
|
|
6440
6506
|
return {
|
|
6507
|
+
from: range.from,
|
|
6508
|
+
to: range.to,
|
|
6441
6509
|
href,
|
|
6442
6510
|
name
|
|
6443
6511
|
};
|
|
@@ -6460,7 +6528,8 @@ function defineFileClickHandler(onClick) {
|
|
|
6460
6528
|
onClick({
|
|
6461
6529
|
href: hit.href,
|
|
6462
6530
|
name: hit.name,
|
|
6463
|
-
event
|
|
6531
|
+
event,
|
|
6532
|
+
mod: isModEvent(event)
|
|
6464
6533
|
});
|
|
6465
6534
|
return true;
|
|
6466
6535
|
} }
|
|
@@ -6748,6 +6817,126 @@ function defineFileView(options = {}) {
|
|
|
6748
6817
|
});
|
|
6749
6818
|
}
|
|
6750
6819
|
|
|
6820
|
+
//#endregion
|
|
6821
|
+
//#region src/extensions/image-click.ts
|
|
6822
|
+
const imageClickKey = new PluginKey("meowdown-image-click");
|
|
6823
|
+
function getClosestImagePreview(target) {
|
|
6824
|
+
return target instanceof HTMLElement && target.closest(".md-image-view-preview");
|
|
6825
|
+
}
|
|
6826
|
+
function findImageAt(state, pos) {
|
|
6827
|
+
const range = getMarkRangeAt(state, pos, "mdImage");
|
|
6828
|
+
if (!range) return;
|
|
6829
|
+
const { src, alt } = range.mark.attrs;
|
|
6830
|
+
return {
|
|
6831
|
+
from: range.from,
|
|
6832
|
+
to: range.to,
|
|
6833
|
+
src,
|
|
6834
|
+
alt
|
|
6835
|
+
};
|
|
6836
|
+
}
|
|
6837
|
+
/**
|
|
6838
|
+
* Resolve the image hit for a preview element via its content holder, not the
|
|
6839
|
+
* event's document position: an event on the non-editable preview lands on the
|
|
6840
|
+
* run boundary, where `getMarkRange` would pick the next adjacent image.
|
|
6841
|
+
*/
|
|
6842
|
+
function findImageForPreview(view, preview) {
|
|
6843
|
+
const content = preview.closest(".md-image-view")?.querySelector(".md-image-view-content");
|
|
6844
|
+
if (!content) return;
|
|
6845
|
+
return findImageAt(view.state, view.posAtDOM(content, 0));
|
|
6846
|
+
}
|
|
6847
|
+
/**
|
|
6848
|
+
* Fingers wander a little during a tap; past this it is a scroll or a drag.
|
|
6849
|
+
*/
|
|
6850
|
+
const TAP_MOVE_TOLERANCE = 10;
|
|
6851
|
+
function findTouch(touches, identifier) {
|
|
6852
|
+
return Array.from(touches).find((touch) => touch.identifier === identifier);
|
|
6853
|
+
}
|
|
6854
|
+
function isWithinTapTolerance(pending, touch) {
|
|
6855
|
+
return Math.abs(touch.clientX - pending.clientX) <= TAP_MOVE_TOLERANCE && Math.abs(touch.clientY - pending.clientY) <= TAP_MOVE_TOLERANCE;
|
|
6856
|
+
}
|
|
6857
|
+
/**
|
|
6858
|
+
* Call `onClick` when the user clicks or taps a rendered image preview, with
|
|
6859
|
+
* the image's markdown `src`, `alt`, and the originating event.
|
|
6860
|
+
*
|
|
6861
|
+
* Touch taps are handled from `touchend` rather than the synthetic click:
|
|
6862
|
+
* previews live inside the editor contenteditable, and iOS WebKit's
|
|
6863
|
+
* tap-to-focus is a native gesture default action that only cancelling the
|
|
6864
|
+
* `touchend` can suppress — otherwise a tap briefly focuses the editor and
|
|
6865
|
+
* raises the software keyboard before the handler opens its own surface
|
|
6866
|
+
* (such as a lightbox).
|
|
6867
|
+
*/
|
|
6868
|
+
function defineImageClickHandler(onClick) {
|
|
6869
|
+
const pendingTaps = /* @__PURE__ */ new WeakMap();
|
|
6870
|
+
const handleTouchEnd = (view, event) => {
|
|
6871
|
+
const pending = pendingTaps.get(view);
|
|
6872
|
+
pendingTaps.delete(view);
|
|
6873
|
+
if (!pending || event.touches.length > 0) return false;
|
|
6874
|
+
const touch = findTouch(event.changedTouches, pending.identifier);
|
|
6875
|
+
if (!touch || !isWithinTapTolerance(pending, touch)) return false;
|
|
6876
|
+
const preview = getClosestImagePreview(event.target);
|
|
6877
|
+
if (!preview) return false;
|
|
6878
|
+
event.preventDefault();
|
|
6879
|
+
const hit = findImageForPreview(view, preview);
|
|
6880
|
+
if (hit) onClick({
|
|
6881
|
+
src: hit.src,
|
|
6882
|
+
alt: hit.alt,
|
|
6883
|
+
event,
|
|
6884
|
+
mod: isModEvent(event)
|
|
6885
|
+
});
|
|
6886
|
+
return true;
|
|
6887
|
+
};
|
|
6888
|
+
return definePlugin(new Plugin({
|
|
6889
|
+
key: imageClickKey,
|
|
6890
|
+
props: {
|
|
6891
|
+
handleDOMEvents: {
|
|
6892
|
+
pointerdown: (view, event) => {
|
|
6893
|
+
if (getClosestImagePreview(event.target) && event.pointerType !== "mouse") event.preventDefault();
|
|
6894
|
+
return false;
|
|
6895
|
+
},
|
|
6896
|
+
touchstart: (view, event) => {
|
|
6897
|
+
pendingTaps.delete(view);
|
|
6898
|
+
if (event.touches.length !== 1) return false;
|
|
6899
|
+
if (!getClosestImagePreview(event.target)) return false;
|
|
6900
|
+
if (event.target instanceof HTMLElement && event.target.closest(".md-image-resize-handle")) return false;
|
|
6901
|
+
const touch = event.changedTouches[0];
|
|
6902
|
+
if (!touch) return false;
|
|
6903
|
+
pendingTaps.set(view, {
|
|
6904
|
+
identifier: touch.identifier,
|
|
6905
|
+
clientX: touch.clientX,
|
|
6906
|
+
clientY: touch.clientY
|
|
6907
|
+
});
|
|
6908
|
+
return false;
|
|
6909
|
+
},
|
|
6910
|
+
touchmove: (view, event) => {
|
|
6911
|
+
const pending = pendingTaps.get(view);
|
|
6912
|
+
if (!pending) return false;
|
|
6913
|
+
const touch = findTouch(event.changedTouches, pending.identifier);
|
|
6914
|
+
if (touch && !isWithinTapTolerance(pending, touch)) pendingTaps.delete(view);
|
|
6915
|
+
return false;
|
|
6916
|
+
},
|
|
6917
|
+
touchcancel: (view) => {
|
|
6918
|
+
pendingTaps.delete(view);
|
|
6919
|
+
return false;
|
|
6920
|
+
},
|
|
6921
|
+
touchend: handleTouchEnd
|
|
6922
|
+
},
|
|
6923
|
+
handleClick: (view, _pos, event) => {
|
|
6924
|
+
const preview = getClosestImagePreview(event.target);
|
|
6925
|
+
if (!preview) return false;
|
|
6926
|
+
const hit = findImageForPreview(view, preview);
|
|
6927
|
+
if (!hit) return false;
|
|
6928
|
+
onClick({
|
|
6929
|
+
src: hit.src,
|
|
6930
|
+
alt: hit.alt,
|
|
6931
|
+
event,
|
|
6932
|
+
mod: isModEvent(event)
|
|
6933
|
+
});
|
|
6934
|
+
return true;
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6937
|
+
}));
|
|
6938
|
+
}
|
|
6939
|
+
|
|
6751
6940
|
//#endregion
|
|
6752
6941
|
//#region src/extensions/mark-click.ts
|
|
6753
6942
|
/**
|
|
@@ -6801,7 +6990,8 @@ function defineTagClickHandler(onClick) {
|
|
|
6801
6990
|
findPayloadAt: (state, pos) => findTagAt(state, pos)?.tag,
|
|
6802
6991
|
onClick: (tag, event) => onClick({
|
|
6803
6992
|
tag,
|
|
6804
|
-
event
|
|
6993
|
+
event,
|
|
6994
|
+
mod: isModEvent(event)
|
|
6805
6995
|
})
|
|
6806
6996
|
});
|
|
6807
6997
|
}
|
|
@@ -6848,7 +7038,8 @@ function defineWikilinkClickHandler(onClick) {
|
|
|
6848
7038
|
findPayloadForElement: (view, element) => findWikilinkForElement(view, element)?.target,
|
|
6849
7039
|
onClick: (target, event) => onClick({
|
|
6850
7040
|
target,
|
|
6851
|
-
event
|
|
7041
|
+
event,
|
|
7042
|
+
mod: isModEvent(event)
|
|
6852
7043
|
})
|
|
6853
7044
|
});
|
|
6854
7045
|
}
|
|
@@ -6863,173 +7054,86 @@ function createFollowLinkPlugin(handlers) {
|
|
|
6863
7054
|
if (getIsComposing() || event.key !== "Enter" || event.shiftKey) return false;
|
|
6864
7055
|
const { state } = view;
|
|
6865
7056
|
const selectedAtom = getSelectedAtomRange(state);
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
if (
|
|
6870
|
-
handlers.onWikilinkClick?.({
|
|
6871
|
-
target: wikilink.target,
|
|
6872
|
-
event
|
|
6873
|
-
});
|
|
6874
|
-
return true;
|
|
6875
|
-
}
|
|
6876
|
-
const tag = handlers.onTagClick && findTagAt(state, pos);
|
|
6877
|
-
if (tag) {
|
|
6878
|
-
handlers.onTagClick?.({
|
|
6879
|
-
tag: tag.tag,
|
|
6880
|
-
event
|
|
6881
|
-
});
|
|
6882
|
-
return true;
|
|
6883
|
-
}
|
|
6884
|
-
const file = handlers.onFileClick && findFileAt(state, pos);
|
|
6885
|
-
if (file) {
|
|
6886
|
-
handlers.onFileClick?.({
|
|
6887
|
-
href: file.href,
|
|
6888
|
-
name: file.name,
|
|
6889
|
-
event
|
|
6890
|
-
});
|
|
6891
|
-
return true;
|
|
6892
|
-
}
|
|
6893
|
-
const link = handlers.onLinkClick && getLinkUnitAt(state, pos);
|
|
6894
|
-
if (link) {
|
|
6895
|
-
handlers.onLinkClick?.({
|
|
6896
|
-
href: link.href,
|
|
6897
|
-
event
|
|
6898
|
-
});
|
|
6899
|
-
return true;
|
|
6900
|
-
}
|
|
7057
|
+
const mod = isModEvent(event);
|
|
7058
|
+
if (!selectedAtom && !mod) return;
|
|
7059
|
+
if (selectedAtom && handlerAtomMarkTrigger(state, event, handlers, mod, selectedAtom)) return true;
|
|
7060
|
+
if (handlerTextMarkTrigger(state, event, handlers, mod)) return true;
|
|
6901
7061
|
return false;
|
|
6902
7062
|
} }
|
|
6903
7063
|
});
|
|
6904
7064
|
}
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
* run boundary, where `getMarkRange` would pick the next adjacent image.
|
|
6938
|
-
*/
|
|
6939
|
-
function findImageForPreview(view, preview) {
|
|
6940
|
-
const content = preview.closest(".md-image-view")?.querySelector(".md-image-view-content");
|
|
6941
|
-
if (!content) return;
|
|
6942
|
-
return findImageAt(view.state, view.posAtDOM(content, 0));
|
|
6943
|
-
}
|
|
6944
|
-
/**
|
|
6945
|
-
* Fingers wander a little during a tap; past this it is a scroll or a drag.
|
|
6946
|
-
*/
|
|
6947
|
-
const TAP_MOVE_TOLERANCE = 10;
|
|
6948
|
-
function findTouch(touches, identifier) {
|
|
6949
|
-
return Array.from(touches).find((touch) => touch.identifier === identifier);
|
|
7065
|
+
function handlerAtomMarkTrigger(state, event, handlers, mod, selectedAtom) {
|
|
7066
|
+
const pos = selectedAtom.from + 1;
|
|
7067
|
+
const { onWikilinkClick, onFileClick, onImageClick } = handlers;
|
|
7068
|
+
const wikilink = onWikilinkClick && findWikilinkAt(state, pos);
|
|
7069
|
+
if (wikilink) {
|
|
7070
|
+
onWikilinkClick({
|
|
7071
|
+
target: wikilink.target,
|
|
7072
|
+
event,
|
|
7073
|
+
mod
|
|
7074
|
+
});
|
|
7075
|
+
return true;
|
|
7076
|
+
}
|
|
7077
|
+
const file = onFileClick && findFileAt(state, pos);
|
|
7078
|
+
if (file) {
|
|
7079
|
+
onFileClick({
|
|
7080
|
+
href: file.href,
|
|
7081
|
+
name: file.name,
|
|
7082
|
+
event,
|
|
7083
|
+
mod
|
|
7084
|
+
});
|
|
7085
|
+
return true;
|
|
7086
|
+
}
|
|
7087
|
+
const image = onImageClick && findImageAt(state, pos);
|
|
7088
|
+
if (image) {
|
|
7089
|
+
onImageClick({
|
|
7090
|
+
src: image.src,
|
|
7091
|
+
alt: image.alt,
|
|
7092
|
+
event,
|
|
7093
|
+
mod
|
|
7094
|
+
});
|
|
7095
|
+
return true;
|
|
7096
|
+
}
|
|
6950
7097
|
}
|
|
6951
|
-
function
|
|
6952
|
-
|
|
7098
|
+
function handlerTextMarkTrigger(state, event, handlers, mod) {
|
|
7099
|
+
const pos = state.selection.head;
|
|
7100
|
+
const { onTagClick, onLinkClick } = handlers;
|
|
7101
|
+
const tag = onTagClick && findTagAt(state, pos);
|
|
7102
|
+
if (tag && tag.from < pos && pos < tag.to) {
|
|
7103
|
+
onTagClick({
|
|
7104
|
+
tag: tag.tag,
|
|
7105
|
+
event,
|
|
7106
|
+
mod
|
|
7107
|
+
});
|
|
7108
|
+
return true;
|
|
7109
|
+
}
|
|
7110
|
+
const link = onLinkClick && getLinkUnitAt(state, pos);
|
|
7111
|
+
if (link && link.unit.from < pos && pos < link.unit.to) {
|
|
7112
|
+
onLinkClick({
|
|
7113
|
+
href: link.href,
|
|
7114
|
+
event,
|
|
7115
|
+
mod
|
|
7116
|
+
});
|
|
7117
|
+
return true;
|
|
7118
|
+
}
|
|
6953
7119
|
}
|
|
6954
7120
|
/**
|
|
6955
|
-
*
|
|
6956
|
-
* the
|
|
7121
|
+
* Binds `Mod-Enter` to follow the wikilink, tag, file pill, or Markdown link
|
|
7122
|
+
* under the caret, and plain `Enter` to follow a selected atom unit (a
|
|
7123
|
+
* wikilink, file pill, or image), firing the same handlers a click does.
|
|
7124
|
+
* "Under the caret" means strictly inside the unit: a caret merely touching
|
|
7125
|
+
* a unit's edge is next to it, not on it.
|
|
7126
|
+
* Off a link, `Mod-Enter` falls through so the list keymap keeps cycling
|
|
7127
|
+
* checkbox tasks; off a selected unit, `Enter` falls through to the regular
|
|
7128
|
+
* split. High priority puts this ahead of every keymap binding.
|
|
6957
7129
|
*
|
|
6958
|
-
*
|
|
6959
|
-
*
|
|
6960
|
-
*
|
|
6961
|
-
*
|
|
6962
|
-
* raises the software keyboard before the handler opens its own surface
|
|
6963
|
-
* (such as a lightbox).
|
|
7130
|
+
* A selected-unit follow reports `mod: true` when the platform's mod key
|
|
7131
|
+
* (`⌘` on Apple, `Ctrl` elsewhere) was held beyond its plain-`Enter` trigger;
|
|
7132
|
+
* a caret follow always reports `mod: false`, its mod key being the trigger
|
|
7133
|
+
* itself.
|
|
6964
7134
|
*/
|
|
6965
|
-
function
|
|
6966
|
-
|
|
6967
|
-
const handleTouchEnd = (view, event) => {
|
|
6968
|
-
const pending = pendingTaps.get(view);
|
|
6969
|
-
pendingTaps.delete(view);
|
|
6970
|
-
if (!pending || event.touches.length > 0) return false;
|
|
6971
|
-
const touch = findTouch(event.changedTouches, pending.identifier);
|
|
6972
|
-
if (!touch || !isWithinTapTolerance(pending, touch)) return false;
|
|
6973
|
-
const preview = getClosestImagePreview(event.target);
|
|
6974
|
-
if (!preview) return false;
|
|
6975
|
-
event.preventDefault();
|
|
6976
|
-
const hit = findImageForPreview(view, preview);
|
|
6977
|
-
if (hit) onClick({
|
|
6978
|
-
src: hit.src,
|
|
6979
|
-
alt: hit.alt,
|
|
6980
|
-
event
|
|
6981
|
-
});
|
|
6982
|
-
return true;
|
|
6983
|
-
};
|
|
6984
|
-
return definePlugin(new Plugin({
|
|
6985
|
-
key: imageClickKey,
|
|
6986
|
-
props: {
|
|
6987
|
-
handleDOMEvents: {
|
|
6988
|
-
pointerdown: (view, event) => {
|
|
6989
|
-
if (getClosestImagePreview(event.target) && event.pointerType !== "mouse") event.preventDefault();
|
|
6990
|
-
return false;
|
|
6991
|
-
},
|
|
6992
|
-
touchstart: (view, event) => {
|
|
6993
|
-
pendingTaps.delete(view);
|
|
6994
|
-
if (event.touches.length !== 1) return false;
|
|
6995
|
-
if (!getClosestImagePreview(event.target)) return false;
|
|
6996
|
-
if (event.target instanceof HTMLElement && event.target.closest(".md-image-resize-handle")) return false;
|
|
6997
|
-
const touch = event.changedTouches[0];
|
|
6998
|
-
if (!touch) return false;
|
|
6999
|
-
pendingTaps.set(view, {
|
|
7000
|
-
identifier: touch.identifier,
|
|
7001
|
-
clientX: touch.clientX,
|
|
7002
|
-
clientY: touch.clientY
|
|
7003
|
-
});
|
|
7004
|
-
return false;
|
|
7005
|
-
},
|
|
7006
|
-
touchmove: (view, event) => {
|
|
7007
|
-
const pending = pendingTaps.get(view);
|
|
7008
|
-
if (!pending) return false;
|
|
7009
|
-
const touch = findTouch(event.changedTouches, pending.identifier);
|
|
7010
|
-
if (touch && !isWithinTapTolerance(pending, touch)) pendingTaps.delete(view);
|
|
7011
|
-
return false;
|
|
7012
|
-
},
|
|
7013
|
-
touchcancel: (view) => {
|
|
7014
|
-
pendingTaps.delete(view);
|
|
7015
|
-
return false;
|
|
7016
|
-
},
|
|
7017
|
-
touchend: handleTouchEnd
|
|
7018
|
-
},
|
|
7019
|
-
handleClick: (view, _pos, event) => {
|
|
7020
|
-
const preview = getClosestImagePreview(event.target);
|
|
7021
|
-
if (!preview) return false;
|
|
7022
|
-
const hit = findImageForPreview(view, preview);
|
|
7023
|
-
if (!hit) return false;
|
|
7024
|
-
onClick({
|
|
7025
|
-
src: hit.src,
|
|
7026
|
-
alt: hit.alt,
|
|
7027
|
-
event
|
|
7028
|
-
});
|
|
7029
|
-
return true;
|
|
7030
|
-
}
|
|
7031
|
-
}
|
|
7032
|
-
}));
|
|
7135
|
+
function defineFollowLinkHandler(handlers) {
|
|
7136
|
+
return withPriority$1(definePlugin(createFollowLinkPlugin(handlers)), Priority$1.high);
|
|
7033
7137
|
}
|
|
7034
7138
|
|
|
7035
7139
|
//#endregion
|
|
@@ -7359,7 +7463,8 @@ function defineLinkClickHandler(onClick) {
|
|
|
7359
7463
|
findPayloadAt: (state, pos) => getLinkUnitAt(state, pos)?.href,
|
|
7360
7464
|
onClick: (href, event) => onClick({
|
|
7361
7465
|
href,
|
|
7362
|
-
event
|
|
7466
|
+
event,
|
|
7467
|
+
mod: isModEvent(event)
|
|
7363
7468
|
})
|
|
7364
7469
|
});
|
|
7365
7470
|
}
|
|
@@ -7582,6 +7687,9 @@ function createSpellCheckPlugin(spellCheck) {
|
|
|
7582
7687
|
}
|
|
7583
7688
|
});
|
|
7584
7689
|
}
|
|
7690
|
+
/**
|
|
7691
|
+
* @deprecated This will be removed in future versions.
|
|
7692
|
+
*/
|
|
7585
7693
|
function defineSpellCheckPlugin(spellCheck) {
|
|
7586
7694
|
return definePlugin(createSpellCheckPlugin(spellCheck));
|
|
7587
7695
|
}
|
|
@@ -8087,4 +8195,4 @@ function getVirtualElementFromRange(view, range) {
|
|
|
8087
8195
|
}
|
|
8088
8196
|
|
|
8089
8197
|
//#endregion
|
|
8090
|
-
export { EDITOR_KEY_BINDINGS, Priority, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineVirtualCaret, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getIsComposing, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
|
8198
|
+
export { EDITOR_KEY_BINDINGS, Priority, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineVirtualCaret, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getIsComposing, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isModEvent, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.65.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"remark-stringify": "^11.0.0",
|
|
44
44
|
"unicode-by-name": "^0.2.0",
|
|
45
45
|
"unified": "^11.0.5",
|
|
46
|
-
"@meowdown/markdown": "^0.
|
|
46
|
+
"@meowdown/markdown": "^0.65.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@ocavue/tsconfig": "^0.7.1",
|