@milkdown/crepe 7.15.5 → 7.17.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/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js +27 -22
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/cursor/index.js +1 -1
- package/lib/cjs/feature/cursor/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +2 -2
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +30 -25
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +27 -22
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/cursor/index.js +2 -2
- package/lib/esm/feature/cursor/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +2 -2
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +31 -26
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/block-edit/handle/component.d.ts +2 -1
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts +0 -8
- package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/index.d.ts +2 -1
- package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +2 -15
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/config.d.ts +5 -1
- package/lib/types/feature/toolbar/config.d.ts.map +1 -1
- package/lib/types/utils/group-builder.d.ts +1 -1
- package/lib/types/utils/group-builder.d.ts.map +1 -1
- package/package.json +3 -6
- package/src/feature/block-edit/handle/component.tsx +1 -1
- package/src/feature/block-edit/handle/index.ts +1 -1
- package/src/feature/block-edit/menu/index.ts +1 -1
- package/src/feature/code-mirror/index.ts +6 -23
- package/src/feature/cursor/index.ts +2 -2
- package/src/feature/latex/index.ts +2 -2
- package/src/utils/group-builder.ts +1 -1
package/lib/esm/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
|
|
17
17
|
import { keymap } from '@codemirror/view';
|
|
18
18
|
import { codeBlockConfig, codeBlockComponent } from '@milkdown/kit/component/code-block';
|
|
19
19
|
import { basicSetup } from 'codemirror';
|
|
20
|
-
import {
|
|
20
|
+
import { dropIndicatorConfig, cursor as cursor$1 } from '@milkdown/kit/plugin/cursor';
|
|
21
21
|
import { createVirtualCursor } from 'prosemirror-virtual-cursor';
|
|
22
22
|
import { inlineImageConfig, imageInlineComponent } from '@milkdown/kit/component/image-inline';
|
|
23
23
|
import katex from 'katex';
|
|
@@ -1556,34 +1556,39 @@ const codeMirror = (editor, config = {}) => {
|
|
|
1556
1556
|
if (config.extensions) {
|
|
1557
1557
|
extensions.push(...config.extensions);
|
|
1558
1558
|
}
|
|
1559
|
-
ctx.update(codeBlockConfig.key, (defaultConfig) =>
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1559
|
+
ctx.update(codeBlockConfig.key, (defaultConfig) => {
|
|
1560
|
+
var _a;
|
|
1561
|
+
return {
|
|
1562
|
+
extensions,
|
|
1563
|
+
languages,
|
|
1564
|
+
expandIcon: config.expandIcon || chevronDownIcon,
|
|
1565
|
+
searchIcon: config.searchIcon || searchIcon,
|
|
1566
|
+
clearSearchIcon: config.clearSearchIcon || clearIcon,
|
|
1567
|
+
searchPlaceholder: config.searchPlaceholder || "Search language",
|
|
1568
|
+
copyText: config.copyText || "Copy",
|
|
1569
|
+
copyIcon: config.copyIcon || copyIcon,
|
|
1570
|
+
onCopy: config.onCopy || (() => {
|
|
1571
|
+
}),
|
|
1572
|
+
noResultText: config.noResultText || "No result",
|
|
1573
|
+
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
|
|
1574
|
+
renderPreview: config.renderPreview || defaultConfig.renderPreview,
|
|
1575
|
+
previewToggleButton: (previewOnlyMode) => {
|
|
1576
|
+
var _a2, _b;
|
|
1577
|
+
const icon = ((_a2 = config.previewToggleIcon) == null ? void 0 : _a2.call(config, previewOnlyMode)) || (previewOnlyMode ? editIcon : visibilityOffIcon);
|
|
1578
|
+
const text = ((_b = config.previewToggleText) == null ? void 0 : _b.call(config, previewOnlyMode)) || (previewOnlyMode ? "Edit" : "Hide");
|
|
1579
|
+
return [icon, text].map((v) => v.trim()).join(" ");
|
|
1580
|
+
},
|
|
1581
|
+
previewLabel: config.previewLabel || defaultConfig.previewLabel,
|
|
1582
|
+
previewLoading: config.previewLoading || defaultConfig.previewLoading,
|
|
1583
|
+
previewOnlyByDefault: (_a = config.previewOnlyByDefault) != null ? _a : defaultConfig.previewOnlyByDefault
|
|
1584
|
+
};
|
|
1585
|
+
});
|
|
1581
1586
|
}).use(codeBlockComponent);
|
|
1582
1587
|
};
|
|
1583
1588
|
|
|
1584
1589
|
const cursor = (editor, config) => {
|
|
1585
1590
|
editor.config(crepeFeatureConfig(CrepeFeature.Cursor)).config((ctx) => {
|
|
1586
|
-
ctx.update(
|
|
1591
|
+
ctx.update(dropIndicatorConfig.key, () => {
|
|
1587
1592
|
var _a, _b;
|
|
1588
1593
|
return {
|
|
1589
1594
|
class: "crepe-drop-cursor",
|
|
@@ -1947,12 +1952,12 @@ const latex = (editor, config) => {
|
|
|
1947
1952
|
}
|
|
1948
1953
|
ctx.update(codeBlockConfig.key, (prev) => ({
|
|
1949
1954
|
...prev,
|
|
1950
|
-
renderPreview: (language, content) => {
|
|
1955
|
+
renderPreview: (language, content, applyPreview) => {
|
|
1951
1956
|
if (language.toLowerCase() === "latex" && content.length > 0) {
|
|
1952
1957
|
return renderLatex(content, config == null ? void 0 : config.katexOptions);
|
|
1953
1958
|
}
|
|
1954
1959
|
const renderPreview = prev.renderPreview;
|
|
1955
|
-
return renderPreview(language, content);
|
|
1960
|
+
return renderPreview(language, content, applyPreview);
|
|
1956
1961
|
}
|
|
1957
1962
|
}));
|
|
1958
1963
|
ctx.set(inlineLatexTooltip.key, {
|