rme 0.0.58 → 0.0.60
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 +9 -1
- package/dist/index.mjs +67 -26
- package/dist/index.mjs.map +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { useCommands, useHelpers, useKeymap, useRemirrorContext } from '@remirro
|
|
|
9
9
|
import * as _drl990114_codemirror_themes from '@drl990114/codemirror-themes';
|
|
10
10
|
import { CreateThemeOptions } from '@drl990114/codemirror-themes';
|
|
11
11
|
export { CreateThemeOptions, createTheme } from '@drl990114/codemirror-themes';
|
|
12
|
+
import { EditorViewConfig } from '@codemirror/view';
|
|
12
13
|
import { LanguageDescription, LanguageSupport } from '@codemirror/language';
|
|
13
14
|
import * as styled_components from 'styled-components';
|
|
14
15
|
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
@@ -214,6 +215,13 @@ declare const wysiwygTransformer: {
|
|
|
214
215
|
declare const _default: react.NamedExoticComponent<EditorProps>;
|
|
215
216
|
|
|
216
217
|
declare const changeTheme: (theme: CreateThemeOptions) => void;
|
|
218
|
+
type CreateCodemirrorOptions = {
|
|
219
|
+
/**
|
|
220
|
+
* when it is true, undo and redo will use prosemirror view.
|
|
221
|
+
*/
|
|
222
|
+
useProsemirrorHistoryKey?: boolean;
|
|
223
|
+
codemirrorEditorViewConfig?: EditorViewConfig;
|
|
224
|
+
};
|
|
217
225
|
declare const getLanguageMap: () => Record<string, LanguageDescription>;
|
|
218
226
|
declare const loadLanguage: (languageName: string) => Promise<LanguageSupport> | LanguageSupport | undefined;
|
|
219
227
|
declare function computeChange(oldVal: string, newVal: string): {
|
|
@@ -433,4 +441,4 @@ declare const lightTheme: {
|
|
|
433
441
|
};
|
|
434
442
|
};
|
|
435
443
|
|
|
436
|
-
export { type CreateWysiwygDelegateOptions, type DocToString, Editor, type EditorChangeEventParams, type EditorChangeHandler, type EditorContext, type EditorDelegate, extensions as EditorExtensions, type EditorProps, type EditorRef, type EditorState, type EditorViewType, type Note, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, type StringToDoc, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, buildMarkdownParser, buildMarkdownSerializer, changeTheme, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, getLanguageMap, lightTheme, loadLanguage, tableSelectorSize, wysiwygTransformer };
|
|
444
|
+
export { type CreateCodemirrorOptions, type CreateWysiwygDelegateOptions, type DocToString, Editor, type EditorChangeEventParams, type EditorChangeHandler, type EditorContext, type EditorDelegate, extensions as EditorExtensions, type EditorProps, type EditorRef, type EditorState, type EditorViewType, type Note, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, type StringToDoc, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, buildMarkdownParser, buildMarkdownSerializer, changeTheme, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, getLanguageMap, lightTheme, loadLanguage, tableSelectorSize, wysiwygTransformer };
|
package/dist/index.mjs
CHANGED
|
@@ -5801,7 +5801,7 @@ var fromMarkdownOptions = {
|
|
|
5801
5801
|
};
|
|
5802
5802
|
function parseInlineMarkdown(text) {
|
|
5803
5803
|
try {
|
|
5804
|
-
const root = fromMarkdown(text, fromMarkdownOptions);
|
|
5804
|
+
const root = fromMarkdown(text, "utf-8", fromMarkdownOptions);
|
|
5805
5805
|
if (root.children.length === 0) {
|
|
5806
5806
|
return [];
|
|
5807
5807
|
}
|
|
@@ -5955,6 +5955,7 @@ function hasHtmlToken(mdastToken) {
|
|
|
5955
5955
|
}
|
|
5956
5956
|
function fromInlineMarkdown(text) {
|
|
5957
5957
|
const phrasingContents = parseInlineMarkdown(text);
|
|
5958
|
+
console.log("phrasingContents", phrasingContents);
|
|
5958
5959
|
if (hasHtmlToken(phrasingContents)) {
|
|
5959
5960
|
const nodes = flatHTMLInlineToken(phrasingContents);
|
|
5960
5961
|
return nodes;
|
|
@@ -8301,6 +8302,7 @@ import { nanoid as nanoid2 } from "nanoid";
|
|
|
8301
8302
|
import { createTheme } from "@drl990114/codemirror-themes";
|
|
8302
8303
|
|
|
8303
8304
|
// src/editor/codemirror/codemirror.ts
|
|
8305
|
+
import { redo, undo } from "@remirror/pm/history";
|
|
8304
8306
|
var cmInstanceMap = /* @__PURE__ */ new Map();
|
|
8305
8307
|
var themeRef = { current: createTheme(lightTheme.codemirrorTheme) };
|
|
8306
8308
|
var changeTheme = (theme) => {
|
|
@@ -8318,7 +8320,7 @@ var MfCodemirrorView = class {
|
|
|
8318
8320
|
node,
|
|
8319
8321
|
extensions: extensions2 = [],
|
|
8320
8322
|
languageName,
|
|
8321
|
-
|
|
8323
|
+
options = {}
|
|
8322
8324
|
}) {
|
|
8323
8325
|
this.toggleName = "paragraph";
|
|
8324
8326
|
this.id = nanoid2();
|
|
@@ -8332,6 +8334,7 @@ var MfCodemirrorView = class {
|
|
|
8332
8334
|
this.schema = node.type.schema;
|
|
8333
8335
|
this.languageName = languageName;
|
|
8334
8336
|
this.loadLanguage = loadLanguage;
|
|
8337
|
+
this.options = options;
|
|
8335
8338
|
this.content = this.node.textContent;
|
|
8336
8339
|
const changeFilter = CodeMirrorEditorState.changeFilter.of((tr) => {
|
|
8337
8340
|
if (!tr.docChanged) {
|
|
@@ -8352,7 +8355,7 @@ var MfCodemirrorView = class {
|
|
|
8352
8355
|
this.cm = new CodeMirrorEditorView({
|
|
8353
8356
|
state: startState,
|
|
8354
8357
|
dispatch: this.valueChanged.bind(this),
|
|
8355
|
-
...
|
|
8358
|
+
...this.options.codemirrorEditorViewConfig || {}
|
|
8356
8359
|
});
|
|
8357
8360
|
cmInstanceMap.set(this.id, this);
|
|
8358
8361
|
this.updateLanguage();
|
|
@@ -8442,7 +8445,7 @@ var MfCodemirrorView = class {
|
|
|
8442
8445
|
return TextSelection3.between(doc.resolve(anchor + start), doc.resolve(head + start));
|
|
8443
8446
|
}
|
|
8444
8447
|
codeMirrorKeymap() {
|
|
8445
|
-
|
|
8448
|
+
const keymaps = [
|
|
8446
8449
|
{
|
|
8447
8450
|
key: "ArrowUp",
|
|
8448
8451
|
run: this.maybeEscape("line", -1)
|
|
@@ -8498,6 +8501,38 @@ var MfCodemirrorView = class {
|
|
|
8498
8501
|
}
|
|
8499
8502
|
}
|
|
8500
8503
|
];
|
|
8504
|
+
if (this.options?.useProsemirrorHistoryKey) {
|
|
8505
|
+
keymaps.push(
|
|
8506
|
+
{
|
|
8507
|
+
key: "Mod-z",
|
|
8508
|
+
run: () => {
|
|
8509
|
+
undo(this.view.state, this.view.dispatch);
|
|
8510
|
+
this.view.focus();
|
|
8511
|
+
return false;
|
|
8512
|
+
}
|
|
8513
|
+
},
|
|
8514
|
+
{
|
|
8515
|
+
key: "Mod-y",
|
|
8516
|
+
mac: "Mod-Shift-z",
|
|
8517
|
+
run: () => {
|
|
8518
|
+
redo(this.view.state, this.view.dispatch);
|
|
8519
|
+
this.view.focus();
|
|
8520
|
+
return false;
|
|
8521
|
+
},
|
|
8522
|
+
preventDefault: true
|
|
8523
|
+
},
|
|
8524
|
+
{
|
|
8525
|
+
linux: "Ctrl-Shift-z",
|
|
8526
|
+
run: () => {
|
|
8527
|
+
redo(this.view.state, this.view.dispatch);
|
|
8528
|
+
this.view.focus();
|
|
8529
|
+
return false;
|
|
8530
|
+
},
|
|
8531
|
+
preventDefault: true
|
|
8532
|
+
}
|
|
8533
|
+
);
|
|
8534
|
+
}
|
|
8535
|
+
return keymaps;
|
|
8501
8536
|
}
|
|
8502
8537
|
maybeEscape(unit, dir) {
|
|
8503
8538
|
return (view) => {
|
|
@@ -8626,8 +8661,6 @@ var minimalSetup = (() => [
|
|
|
8626
8661
|
dropCursor(),
|
|
8627
8662
|
lineNumbers(),
|
|
8628
8663
|
highlightSpecialChars(),
|
|
8629
|
-
history(),
|
|
8630
|
-
indentOnInput(),
|
|
8631
8664
|
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
8632
8665
|
bracketMatching(),
|
|
8633
8666
|
closeBrackets(),
|
|
@@ -8635,13 +8668,7 @@ var minimalSetup = (() => [
|
|
|
8635
8668
|
crosshairCursor(),
|
|
8636
8669
|
highlightSelectionMatches(),
|
|
8637
8670
|
keymap2.of([
|
|
8638
|
-
...
|
|
8639
|
-
...defaultKeymap,
|
|
8640
|
-
...searchKeymap,
|
|
8641
|
-
...historyKeymap,
|
|
8642
|
-
...foldKeymap,
|
|
8643
|
-
...completionKeymap,
|
|
8644
|
-
...lintKeymap
|
|
8671
|
+
...defaultKeymap
|
|
8645
8672
|
])
|
|
8646
8673
|
])();
|
|
8647
8674
|
|
|
@@ -15042,6 +15069,7 @@ function removeNewlines(str) {
|
|
|
15042
15069
|
var HtmlNodeView = class {
|
|
15043
15070
|
constructor(node, view, getPos) {
|
|
15044
15071
|
this._htmlSrcElt = null;
|
|
15072
|
+
this.destroying = false;
|
|
15045
15073
|
this.ignoreMutation = () => true;
|
|
15046
15074
|
this.handleMouseEnter = () => {
|
|
15047
15075
|
this.dom.classList.add("node-enter");
|
|
@@ -15147,13 +15175,13 @@ var HtmlNodeView = class {
|
|
|
15147
15175
|
node: this._node,
|
|
15148
15176
|
getPos: this._getPos,
|
|
15149
15177
|
languageName: "html",
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15178
|
+
extensions: [minimalSetup, htmlLang],
|
|
15179
|
+
options: {
|
|
15180
|
+
useProsemirrorHistoryKey: true,
|
|
15181
|
+
codemirrorEditorViewConfig: {
|
|
15182
|
+
parent: this._htmlSrcElt
|
|
15183
|
+
}
|
|
15184
|
+
}
|
|
15157
15185
|
});
|
|
15158
15186
|
this._htmlSrcElt.classList.remove("node-hide");
|
|
15159
15187
|
this._innerView = this.mfCodemirrorView.cm;
|
|
@@ -15162,11 +15190,14 @@ var HtmlNodeView = class {
|
|
|
15162
15190
|
this.setSelection(prevCursorPos, prevCursorPos);
|
|
15163
15191
|
this._innerView.focus();
|
|
15164
15192
|
this._innerView.contentDOM.addEventListener("blur", () => {
|
|
15193
|
+
if (this.destroying)
|
|
15194
|
+
return;
|
|
15165
15195
|
this.closeEditor(true);
|
|
15166
15196
|
});
|
|
15167
15197
|
this.mfCodemirrorView.forwardSelection();
|
|
15168
15198
|
}
|
|
15169
15199
|
destroy() {
|
|
15200
|
+
this.destroying = true;
|
|
15170
15201
|
this.closeEditor(false);
|
|
15171
15202
|
if (this._htmlRenderElt) {
|
|
15172
15203
|
this._htmlRenderElt.remove();
|
|
@@ -17614,7 +17645,8 @@ function extensions({ handleViewImgSrcUrl }) {
|
|
|
17614
17645
|
new LineHeadingExtension({}),
|
|
17615
17646
|
new LineListExtension(),
|
|
17616
17647
|
new LineCodeMirrorExtension({
|
|
17617
|
-
extensions: [minimalSetup]
|
|
17648
|
+
extensions: [minimalSetup],
|
|
17649
|
+
useProsemirrorHistoryKey: true
|
|
17618
17650
|
}),
|
|
17619
17651
|
new LineTableExtension({ resizable: false }),
|
|
17620
17652
|
new LineTableRowExtension(),
|
|
@@ -18633,7 +18665,8 @@ var CodeMirror6NodeView = class {
|
|
|
18633
18665
|
node,
|
|
18634
18666
|
view,
|
|
18635
18667
|
getPos,
|
|
18636
|
-
extensions: extensions2
|
|
18668
|
+
extensions: extensions2,
|
|
18669
|
+
options
|
|
18637
18670
|
}) {
|
|
18638
18671
|
this.node = node;
|
|
18639
18672
|
this.view = view;
|
|
@@ -18644,7 +18677,8 @@ var CodeMirror6NodeView = class {
|
|
|
18644
18677
|
getPos: this.getPos,
|
|
18645
18678
|
node: this.node,
|
|
18646
18679
|
extensions: extensions2,
|
|
18647
|
-
languageName: this.languageName
|
|
18680
|
+
languageName: this.languageName,
|
|
18681
|
+
options
|
|
18648
18682
|
});
|
|
18649
18683
|
this.cm = this.mfCodemirrorView.cm;
|
|
18650
18684
|
this.dom = this.cm.dom;
|
|
@@ -18714,7 +18748,10 @@ var LineCodeMirrorExtension = class extends NodeExtension4 {
|
|
|
18714
18748
|
view,
|
|
18715
18749
|
getPos,
|
|
18716
18750
|
extensions: this.options.extensions,
|
|
18717
|
-
toggleName: this.options.toggleName
|
|
18751
|
+
toggleName: this.options.toggleName,
|
|
18752
|
+
options: {
|
|
18753
|
+
useProsemirrorHistoryKey: this.options.useProsemirrorHistoryKey
|
|
18754
|
+
}
|
|
18718
18755
|
});
|
|
18719
18756
|
return this.nodeview;
|
|
18720
18757
|
};
|
|
@@ -18870,8 +18907,12 @@ LineCodeMirrorExtension = __decorateClass([
|
|
|
18870
18907
|
defaultOptions: {
|
|
18871
18908
|
hideDecoration: false,
|
|
18872
18909
|
extensions: null,
|
|
18873
|
-
toggleName: "paragraph"
|
|
18874
|
-
|
|
18910
|
+
toggleName: "paragraph",
|
|
18911
|
+
useProsemirrorHistoryKey: false
|
|
18912
|
+
},
|
|
18913
|
+
staticKeys: [],
|
|
18914
|
+
handlerKeys: [],
|
|
18915
|
+
customHandlerKeys: []
|
|
18875
18916
|
})
|
|
18876
18917
|
], LineCodeMirrorExtension);
|
|
18877
18918
|
|