rme 0.1.2 → 0.1.4
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +173 -42
- package/dist/index.mjs.map +4 -4
- package/package.json +4 -4
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -283,9 +283,10 @@ declare class MarkdownSerializer {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
type ExtensionsOptions = {
|
|
286
|
+
disableAllBuildInShortcuts?: boolean;
|
|
286
287
|
handleViewImgSrcUrl?: (src: string) => Promise<string>;
|
|
287
288
|
};
|
|
288
|
-
declare function extensions(
|
|
289
|
+
declare function extensions(options: ExtensionsOptions): any[];
|
|
289
290
|
|
|
290
291
|
declare function buildMarkdownParser<Extension extends AnyExtension$1>(manager: RemirrorManager<Extension>): MarkdownParser;
|
|
291
292
|
declare function buildMarkdownSerializer<Extension extends AnyExtension$1>(manager: RemirrorManager<Extension>): MarkdownSerializer;
|
package/dist/index.mjs
CHANGED
|
@@ -4207,9 +4207,9 @@ var require_isobject = __commonJS({
|
|
|
4207
4207
|
}
|
|
4208
4208
|
});
|
|
4209
4209
|
|
|
4210
|
-
// node_modules/is-
|
|
4210
|
+
// node_modules/is-plain-object/index.js
|
|
4211
4211
|
var require_is_plain_object = __commonJS({
|
|
4212
|
-
"node_modules/is-
|
|
4212
|
+
"node_modules/is-plain-object/index.js"(exports, module) {
|
|
4213
4213
|
var import_isobject = __toESM(require_isobject());
|
|
4214
4214
|
var isObject = import_isobject.default;
|
|
4215
4215
|
function isObjectObject(o) {
|
|
@@ -5374,7 +5374,7 @@ import { isTextSelection as isTextSelection2, PlainExtension as PlainExtension2
|
|
|
5374
5374
|
import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@remirror/pm/view";
|
|
5375
5375
|
|
|
5376
5376
|
// src/editor/extensions/Inline/inline-mark-extensions.ts
|
|
5377
|
-
import { MarkExtension, extension
|
|
5377
|
+
import { MarkExtension, extension } from "@remirror/core";
|
|
5378
5378
|
|
|
5379
5379
|
// src/editor/extensions/Inline/format-href.ts
|
|
5380
5380
|
function formatHref(location2) {
|
|
@@ -6207,13 +6207,12 @@ var Emphasis = class extends MarkExtension {
|
|
|
6207
6207
|
toDOM: () => ["em", 0]
|
|
6208
6208
|
};
|
|
6209
6209
|
}
|
|
6210
|
-
|
|
6211
|
-
return
|
|
6210
|
+
createCommands() {
|
|
6211
|
+
return {
|
|
6212
|
+
toggleEmphasis: () => (props) => toggleInlineMark(this.name)(props)
|
|
6213
|
+
};
|
|
6212
6214
|
}
|
|
6213
6215
|
};
|
|
6214
|
-
__decorateClass([
|
|
6215
|
-
keyBinding({ shortcut: "mod-i", command: "toggleEmphasis" })
|
|
6216
|
-
], Emphasis.prototype, "shortcut", 1);
|
|
6217
6216
|
var Strong = class extends MarkExtension {
|
|
6218
6217
|
static {
|
|
6219
6218
|
this.disableExtraAttributes = true;
|
|
@@ -6227,13 +6226,12 @@ var Strong = class extends MarkExtension {
|
|
|
6227
6226
|
toDOM: () => ["strong", 0]
|
|
6228
6227
|
};
|
|
6229
6228
|
}
|
|
6230
|
-
|
|
6231
|
-
return
|
|
6229
|
+
createCommands() {
|
|
6230
|
+
return {
|
|
6231
|
+
toggleStrong: () => (props) => toggleInlineMark(this.name)(props)
|
|
6232
|
+
};
|
|
6232
6233
|
}
|
|
6233
6234
|
};
|
|
6234
|
-
__decorateClass([
|
|
6235
|
-
keyBinding({ shortcut: "mod-b", command: "toggleStrong" })
|
|
6236
|
-
], Strong.prototype, "shortcut", 1);
|
|
6237
6235
|
var CodeText = class extends MarkExtension {
|
|
6238
6236
|
static {
|
|
6239
6237
|
this.disableExtraAttributes = true;
|
|
@@ -6247,13 +6245,12 @@ var CodeText = class extends MarkExtension {
|
|
|
6247
6245
|
toDOM: () => ["code", 0]
|
|
6248
6246
|
};
|
|
6249
6247
|
}
|
|
6250
|
-
|
|
6251
|
-
return
|
|
6248
|
+
createCommands() {
|
|
6249
|
+
return {
|
|
6250
|
+
toggleCodeText: () => (props) => toggleInlineMark(this.name)(props)
|
|
6251
|
+
};
|
|
6252
6252
|
}
|
|
6253
6253
|
};
|
|
6254
|
-
__decorateClass([
|
|
6255
|
-
keyBinding({ shortcut: "mod-e", command: "toggleCodeText" })
|
|
6256
|
-
], CodeText.prototype, "shortcut", 1);
|
|
6257
6254
|
var CodeSpace = class extends MarkExtension {
|
|
6258
6255
|
static {
|
|
6259
6256
|
this.disableExtraAttributes = true;
|
|
@@ -6281,13 +6278,12 @@ var Delete = class extends MarkExtension {
|
|
|
6281
6278
|
toDOM: () => ["del", 0]
|
|
6282
6279
|
};
|
|
6283
6280
|
}
|
|
6284
|
-
|
|
6285
|
-
return
|
|
6281
|
+
createCommands() {
|
|
6282
|
+
return {
|
|
6283
|
+
toggleDelete: () => (props) => toggleInlineMark(this.name)(props)
|
|
6284
|
+
};
|
|
6286
6285
|
}
|
|
6287
6286
|
};
|
|
6288
|
-
__decorateClass([
|
|
6289
|
-
keyBinding({ shortcut: "mod-shift-s", command: "toggleDelete" })
|
|
6290
|
-
], Delete.prototype, "shortcut", 1);
|
|
6291
6287
|
var LinkText = class extends MarkExtension {
|
|
6292
6288
|
static {
|
|
6293
6289
|
this.disableExtraAttributes = true;
|
|
@@ -6382,11 +6378,7 @@ var ImgUri = class extends MarkExtension {
|
|
|
6382
6378
|
default: ""
|
|
6383
6379
|
}
|
|
6384
6380
|
},
|
|
6385
|
-
toDOM: (mark) => [
|
|
6386
|
-
"img",
|
|
6387
|
-
{ src: mark.attrs.href },
|
|
6388
|
-
0
|
|
6389
|
-
]
|
|
6381
|
+
toDOM: (mark) => ["img", { src: mark.attrs.href }, 0]
|
|
6390
6382
|
};
|
|
6391
6383
|
}
|
|
6392
6384
|
};
|
|
@@ -8219,23 +8211,23 @@ var lightTheme = {
|
|
|
8219
8211
|
// src/editor/components/WysiwygEditor/delegate.ts
|
|
8220
8212
|
import { createReactManager } from "@remirror/react";
|
|
8221
8213
|
import { isExtension } from "@remirror/core";
|
|
8222
|
-
function isMarkdownNodeExtension(
|
|
8223
|
-
return !!(isExtension(
|
|
8214
|
+
function isMarkdownNodeExtension(extension11) {
|
|
8215
|
+
return !!(isExtension(extension11) && extension11.fromMarkdown && extension11.toMarkdown);
|
|
8224
8216
|
}
|
|
8225
8217
|
function buildMarkdownParser(manager) {
|
|
8226
8218
|
const parserRules = [];
|
|
8227
|
-
for (const
|
|
8228
|
-
if (isMarkdownNodeExtension(
|
|
8229
|
-
parserRules.push(...
|
|
8219
|
+
for (const extension11 of manager.extensions) {
|
|
8220
|
+
if (isMarkdownNodeExtension(extension11)) {
|
|
8221
|
+
parserRules.push(...extension11.fromMarkdown());
|
|
8230
8222
|
}
|
|
8231
8223
|
}
|
|
8232
8224
|
return new MarkdownParser(manager.schema, parserRules);
|
|
8233
8225
|
}
|
|
8234
8226
|
function buildMarkdownSerializer(manager) {
|
|
8235
8227
|
const specs = {};
|
|
8236
|
-
for (const
|
|
8237
|
-
if (isMarkdownNodeExtension(
|
|
8238
|
-
specs[
|
|
8228
|
+
for (const extension11 of manager.extensions) {
|
|
8229
|
+
if (isMarkdownNodeExtension(extension11)) {
|
|
8230
|
+
specs[extension11.name] = extension11.toMarkdown;
|
|
8239
8231
|
}
|
|
8240
8232
|
}
|
|
8241
8233
|
return new MarkdownSerializer(specs);
|
|
@@ -17840,6 +17832,37 @@ var ClipboardExtension = class extends PlainExtension7 {
|
|
|
17840
17832
|
}
|
|
17841
17833
|
};
|
|
17842
17834
|
}
|
|
17835
|
+
createCommands() {
|
|
17836
|
+
return {
|
|
17837
|
+
rmeParse: () => (props) => {
|
|
17838
|
+
console.log("rmeParse");
|
|
17839
|
+
const { state, dispatch, view } = props;
|
|
17840
|
+
if (!dispatch || !view) return false;
|
|
17841
|
+
navigator.clipboard.readText().then((text) => {
|
|
17842
|
+
console.log("texttext", text);
|
|
17843
|
+
const parser4 = wysiwygTransformer.stringToDoc;
|
|
17844
|
+
const tr = state.tr.replaceSelectionWith(
|
|
17845
|
+
state.schema.text(text)
|
|
17846
|
+
);
|
|
17847
|
+
const slice = parser4?.(text);
|
|
17848
|
+
if (!slice || typeof slice === "string") return false;
|
|
17849
|
+
const res = [];
|
|
17850
|
+
slice.content.forEach((node, index) => {
|
|
17851
|
+
if (node.type.name === "paragraph" && index === 0) {
|
|
17852
|
+
node.content.forEach((child) => {
|
|
17853
|
+
res.push(child);
|
|
17854
|
+
});
|
|
17855
|
+
} else {
|
|
17856
|
+
res.push(node);
|
|
17857
|
+
}
|
|
17858
|
+
});
|
|
17859
|
+
view.dispatch(view.state.tr.replaceSelectionWith(res, false));
|
|
17860
|
+
return true;
|
|
17861
|
+
});
|
|
17862
|
+
return true;
|
|
17863
|
+
}
|
|
17864
|
+
};
|
|
17865
|
+
}
|
|
17843
17866
|
};
|
|
17844
17867
|
|
|
17845
17868
|
// src/editor/extensions/HtmlBr/br-extension.ts
|
|
@@ -18506,8 +18529,113 @@ var MermaidBlockExtension = class extends NodeExtension6 {
|
|
|
18506
18529
|
}
|
|
18507
18530
|
};
|
|
18508
18531
|
|
|
18532
|
+
// src/editor/extensions/Shortcuts/shortcuts-extension.ts
|
|
18533
|
+
import { extension as extension9, PlainExtension as PlainExtension8 } from "@remirror/core";
|
|
18534
|
+
|
|
18535
|
+
// src/editor/extensions/Shortcuts/configs/shortcuts.ts
|
|
18536
|
+
import { cloneDeep as cloneDeep2 } from "lodash";
|
|
18537
|
+
|
|
18538
|
+
// src/editor/extensions/Shortcuts/configs/keymap.ts
|
|
18539
|
+
var rmeDefaultKeymap = {
|
|
18540
|
+
"mod-c": "copy",
|
|
18541
|
+
"mod-v": "rmeParse",
|
|
18542
|
+
"mod-x": "cut",
|
|
18543
|
+
"mod-z": "undo",
|
|
18544
|
+
"mod-y": "redo",
|
|
18545
|
+
"mod-shift-z": "redo",
|
|
18546
|
+
"mod-b": "toggleStrong",
|
|
18547
|
+
"mod-i": "toggleEmphasis",
|
|
18548
|
+
"mod-e": "toggleCodeText",
|
|
18549
|
+
"mod-shift-s": "toggleDelete"
|
|
18550
|
+
};
|
|
18551
|
+
|
|
18552
|
+
// src/editor/extensions/Shortcuts/configs/shortcuts.ts
|
|
18553
|
+
var ShortcutManager = class _ShortcutManager {
|
|
18554
|
+
constructor() {
|
|
18555
|
+
this.shortcuts = {};
|
|
18556
|
+
this.shortcuts = cloneDeep2(rmeDefaultKeymap);
|
|
18557
|
+
}
|
|
18558
|
+
static getInstance() {
|
|
18559
|
+
if (!_ShortcutManager.instance) {
|
|
18560
|
+
_ShortcutManager.instance = new _ShortcutManager();
|
|
18561
|
+
}
|
|
18562
|
+
return _ShortcutManager.instance;
|
|
18563
|
+
}
|
|
18564
|
+
setShortcut(key, command5) {
|
|
18565
|
+
this.shortcuts[key] = command5;
|
|
18566
|
+
}
|
|
18567
|
+
setShortcuts(shortcuts) {
|
|
18568
|
+
this.shortcuts = { ...this.shortcuts, ...shortcuts };
|
|
18569
|
+
}
|
|
18570
|
+
getShortcuts() {
|
|
18571
|
+
return this.shortcuts;
|
|
18572
|
+
}
|
|
18573
|
+
createKeyBindings(commands, config) {
|
|
18574
|
+
const bindings = {};
|
|
18575
|
+
Object.entries(this.shortcuts).forEach(([shortcut, command5]) => {
|
|
18576
|
+
if (typeof commands[command5] === "function") {
|
|
18577
|
+
bindings[shortcut] = (state, dispatch, view) => {
|
|
18578
|
+
if (config?.disableAllBuildInShortcuts) {
|
|
18579
|
+
return true;
|
|
18580
|
+
}
|
|
18581
|
+
commands[command5](state, dispatch, view);
|
|
18582
|
+
return true;
|
|
18583
|
+
};
|
|
18584
|
+
}
|
|
18585
|
+
});
|
|
18586
|
+
return bindings;
|
|
18587
|
+
}
|
|
18588
|
+
};
|
|
18589
|
+
|
|
18590
|
+
// src/editor/extensions/Shortcuts/shortcuts-extension.ts
|
|
18591
|
+
import { keymap as keymap4 } from "@remirror/pm/keymap";
|
|
18592
|
+
var ShortcutsExtension = class extends PlainExtension8 {
|
|
18593
|
+
get name() {
|
|
18594
|
+
return "shortcuts";
|
|
18595
|
+
}
|
|
18596
|
+
createExternalAPI() {
|
|
18597
|
+
return {
|
|
18598
|
+
setShortcut: (key, command5) => {
|
|
18599
|
+
ShortcutManager.getInstance().setShortcut(key, command5);
|
|
18600
|
+
},
|
|
18601
|
+
setShortcuts: (shortcuts) => {
|
|
18602
|
+
ShortcutManager.getInstance().setShortcuts(shortcuts);
|
|
18603
|
+
},
|
|
18604
|
+
getShortcuts: () => {
|
|
18605
|
+
return ShortcutManager.getInstance().getShortcuts();
|
|
18606
|
+
}
|
|
18607
|
+
};
|
|
18608
|
+
}
|
|
18609
|
+
onCreate() {
|
|
18610
|
+
if (this.options.shortcuts) {
|
|
18611
|
+
ShortcutManager.getInstance().setShortcuts(this.options.shortcuts);
|
|
18612
|
+
}
|
|
18613
|
+
}
|
|
18614
|
+
onView(view) {
|
|
18615
|
+
const keyBinds = ShortcutManager.getInstance().createKeyBindings(this.store.commands, {
|
|
18616
|
+
disableAllBuildInShortcuts: this.options.disableAllBuildInShortcuts
|
|
18617
|
+
});
|
|
18618
|
+
const newState = view.state.reconfigure({
|
|
18619
|
+
plugins: [...view.state.plugins, keymap4(keyBinds)]
|
|
18620
|
+
});
|
|
18621
|
+
view.updateState(newState);
|
|
18622
|
+
}
|
|
18623
|
+
};
|
|
18624
|
+
ShortcutsExtension = __decorateClass([
|
|
18625
|
+
extension9({
|
|
18626
|
+
defaultOptions: {
|
|
18627
|
+
shortcuts: void 0,
|
|
18628
|
+
disableAllBuildInShortcuts: false
|
|
18629
|
+
},
|
|
18630
|
+
staticKeys: [],
|
|
18631
|
+
handlerKeys: [],
|
|
18632
|
+
customHandlerKeys: []
|
|
18633
|
+
})
|
|
18634
|
+
], ShortcutsExtension);
|
|
18635
|
+
|
|
18509
18636
|
// src/editor/extensions/index.ts
|
|
18510
|
-
function extensions(
|
|
18637
|
+
function extensions(options) {
|
|
18638
|
+
const { handleViewImgSrcUrl } = options;
|
|
18511
18639
|
return [
|
|
18512
18640
|
...corePreset({ excludeExtensions: ["paragraph", "text"] }),
|
|
18513
18641
|
...markExtensions({
|
|
@@ -18554,7 +18682,10 @@ function extensions({ handleViewImgSrcUrl }) {
|
|
|
18554
18682
|
new SlashMenuExtension(),
|
|
18555
18683
|
new LineInlineMarkExtension(),
|
|
18556
18684
|
new LineInlineDecorationExtension(),
|
|
18557
|
-
new MermaidBlockExtension({})
|
|
18685
|
+
new MermaidBlockExtension({}),
|
|
18686
|
+
new ShortcutsExtension({
|
|
18687
|
+
disableAllBuildInShortcuts: options.disableAllBuildInShortcuts
|
|
18688
|
+
})
|
|
18558
18689
|
];
|
|
18559
18690
|
}
|
|
18560
18691
|
var extensions_default = extensions;
|
|
@@ -19541,12 +19672,12 @@ var codemirror_lang_menu_default = createCodeMirrorMenuDecorations;
|
|
|
19541
19672
|
// src/editor/extensions/CodeMirror/codemirror-extension.ts
|
|
19542
19673
|
import {
|
|
19543
19674
|
command as command4,
|
|
19544
|
-
extension as
|
|
19675
|
+
extension as extension10,
|
|
19545
19676
|
findParentNodeOfType as findParentNodeOfType5,
|
|
19546
19677
|
isElementDomNode as isElementDomNode5,
|
|
19547
19678
|
isEqual,
|
|
19548
19679
|
isTextSelection as isTextSelection3,
|
|
19549
|
-
keyBinding
|
|
19680
|
+
keyBinding,
|
|
19550
19681
|
NodeExtension as NodeExtension7,
|
|
19551
19682
|
nodeInputRule as nodeInputRule7,
|
|
19552
19683
|
setBlockType as setBlockType2
|
|
@@ -19793,7 +19924,7 @@ var LineCodeMirrorExtension = class extends NodeExtension7 {
|
|
|
19793
19924
|
}
|
|
19794
19925
|
};
|
|
19795
19926
|
__decorateClass([
|
|
19796
|
-
|
|
19927
|
+
keyBinding({ shortcut: "Enter" })
|
|
19797
19928
|
], LineCodeMirrorExtension.prototype, "enterKey", 1);
|
|
19798
19929
|
__decorateClass([
|
|
19799
19930
|
command4()
|
|
@@ -19802,7 +19933,7 @@ __decorateClass([
|
|
|
19802
19933
|
command4()
|
|
19803
19934
|
], LineCodeMirrorExtension.prototype, "updateCodeMirror", 1);
|
|
19804
19935
|
LineCodeMirrorExtension = __decorateClass([
|
|
19805
|
-
|
|
19936
|
+
extension10({
|
|
19806
19937
|
defaultOptions: {
|
|
19807
19938
|
hideDecoration: false,
|
|
19808
19939
|
extensions: null,
|