@milkdown/preset-commonmark 5.3.0 → 5.3.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/lib/index.d.ts +1 -34
- package/lib/index.es.js +118 -58
- package/lib/index.es.js.map +1 -1
- package/lib/src/index.d.ts +34 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/{mark → src/mark}/code-inline.d.ts +1 -1
- package/lib/src/mark/code-inline.d.ts.map +1 -0
- package/lib/{mark → src/mark}/em.d.ts +1 -1
- package/lib/src/mark/em.d.ts.map +1 -0
- package/lib/src/mark/index.d.ts +6 -0
- package/lib/src/mark/index.d.ts.map +1 -0
- package/lib/{mark → src/mark}/link.d.ts +1 -1
- package/lib/src/mark/link.d.ts.map +1 -0
- package/lib/{mark → src/mark}/strong.d.ts +1 -1
- package/lib/src/mark/strong.d.ts.map +1 -0
- package/lib/{node → src/node}/blockquote.d.ts +1 -1
- package/lib/src/node/blockquote.d.ts.map +1 -0
- package/lib/{node → src/node}/bullet-list.d.ts +1 -1
- package/lib/src/node/bullet-list.d.ts.map +1 -0
- package/lib/{node → src/node}/code-fence.d.ts +1 -1
- package/lib/src/node/code-fence.d.ts.map +1 -0
- package/lib/{node → src/node}/doc.d.ts +1 -1
- package/lib/src/node/doc.d.ts.map +1 -0
- package/lib/{node → src/node}/hardbreak.d.ts +1 -1
- package/lib/src/node/hardbreak.d.ts.map +1 -0
- package/lib/{node → src/node}/heading.d.ts +3 -1
- package/lib/src/node/heading.d.ts.map +1 -0
- package/lib/{node → src/node}/hr.d.ts +1 -1
- package/lib/src/node/hr.d.ts.map +1 -0
- package/lib/{node → src/node}/image.d.ts +1 -1
- package/lib/src/node/image.d.ts.map +1 -0
- package/lib/{node → src/node}/index.d.ts +2 -2
- package/lib/src/node/index.d.ts.map +1 -0
- package/lib/{node → src/node}/list-item.d.ts +1 -1
- package/lib/src/node/list-item.d.ts.map +1 -0
- package/lib/{node → src/node}/ordered-list.d.ts +1 -1
- package/lib/src/node/ordered-list.d.ts.map +1 -0
- package/lib/{node → src/node}/paragraph.d.ts +1 -1
- package/lib/src/node/paragraph.d.ts.map +1 -0
- package/lib/{node → src/node}/text.d.ts +1 -1
- package/lib/src/node/text.d.ts.map +1 -0
- package/lib/{plugin → src/plugin}/filter-html.d.ts +0 -0
- package/lib/src/plugin/filter-html.d.ts.map +1 -0
- package/lib/src/plugin/index.d.ts +2 -0
- package/lib/src/plugin/index.d.ts.map +1 -0
- package/lib/{supported-keys.d.ts → src/supported-keys.d.ts} +0 -0
- package/lib/src/supported-keys.d.ts.map +1 -0
- package/lib/src/types.d.ts +5 -0
- package/package.json +10 -23
- package/src/mark/code-inline.ts +6 -7
- package/src/mark/link.ts +1 -2
- package/src/mark/strong.ts +1 -2
- package/src/node/blockquote.ts +1 -2
- package/src/node/bullet-list.ts +1 -1
- package/src/node/code-fence.ts +7 -6
- package/src/node/heading.ts +75 -28
- package/src/node/hr.ts +1 -2
- package/src/node/image.ts +20 -9
- package/src/node/list-item.ts +1 -2
- package/src/node/ordered-list.ts +1 -1
- package/src/node/paragraph.ts +8 -9
- package/lib/index.cjs.js +0 -261
- package/lib/index.cjs.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/mark/code-inline.d.ts.map +0 -1
- package/lib/mark/em.d.ts.map +0 -1
- package/lib/mark/index.d.ts +0 -6
- package/lib/mark/index.d.ts.map +0 -1
- package/lib/mark/link.d.ts.map +0 -1
- package/lib/mark/strong.d.ts.map +0 -1
- package/lib/node/blockquote.d.ts.map +0 -1
- package/lib/node/bullet-list.d.ts.map +0 -1
- package/lib/node/code-fence.d.ts.map +0 -1
- package/lib/node/doc.d.ts.map +0 -1
- package/lib/node/hardbreak.d.ts.map +0 -1
- package/lib/node/heading.d.ts.map +0 -1
- package/lib/node/hr.d.ts.map +0 -1
- package/lib/node/image.d.ts.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/list-item.d.ts.map +0 -1
- package/lib/node/ordered-list.d.ts.map +0 -1
- package/lib/node/paragraph.d.ts.map +0 -1
- package/lib/node/text.d.ts.map +0 -1
- package/lib/plugin/filter-html.d.ts.map +0 -1
- package/lib/plugin/index.d.ts +0 -2
- package/lib/plugin/index.d.ts.map +0 -1
- package/lib/supported-keys.d.ts.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { commonmarkPlugins } from './plugin';
|
|
3
|
-
export * from './mark';
|
|
4
|
-
export * from './node';
|
|
5
|
-
export * from './supported-keys';
|
|
6
|
-
export declare const commonmarkNodes: AtomList<(import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<"CodeFence", {
|
|
7
|
-
languageList?: string[] | undefined;
|
|
8
|
-
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<string, import("./node").ImageOptions>> & import("@milkdown/core").MilkdownPlugin)>;
|
|
9
|
-
export { commonmarkPlugins };
|
|
10
|
-
export declare const commonmark: AtomList<(import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<"CodeFence", {
|
|
11
|
-
languageList?: string[] | undefined;
|
|
12
|
-
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<string, import("./node").ImageOptions>> & import("@milkdown/core").MilkdownPlugin)>;
|
|
13
|
-
export declare const commands: {
|
|
14
|
-
readonly ToggleInlineCode: import("@milkdown/core").CmdKey<undefined>;
|
|
15
|
-
readonly ToggleItalic: import("@milkdown/core").CmdKey<undefined>;
|
|
16
|
-
readonly ToggleLink: import("@milkdown/core").CmdKey<string>;
|
|
17
|
-
readonly ToggleBold: import("@milkdown/core").CmdKey<undefined>;
|
|
18
|
-
readonly ModifyLink: import("@milkdown/core").CmdKey<string>;
|
|
19
|
-
readonly ModifyImage: import("@milkdown/core").CmdKey<string>;
|
|
20
|
-
readonly WrapInBlockquote: import("@milkdown/core").CmdKey<undefined>;
|
|
21
|
-
readonly WrapInBulletList: import("@milkdown/core").CmdKey<undefined>;
|
|
22
|
-
readonly WrapInOrderedList: import("@milkdown/core").CmdKey<undefined>;
|
|
23
|
-
readonly TurnIntoCodeFence: import("@milkdown/core").CmdKey<undefined>;
|
|
24
|
-
readonly TurnIntoHeading: import("@milkdown/core").CmdKey<number>;
|
|
25
|
-
readonly TurnIntoText: import("@milkdown/core").CmdKey<undefined>;
|
|
26
|
-
readonly InsertHardbreak: import("@milkdown/core").CmdKey<undefined>;
|
|
27
|
-
readonly InsertHr: import("@milkdown/core").CmdKey<string>;
|
|
28
|
-
readonly InsertImage: import("@milkdown/core").CmdKey<string>;
|
|
29
|
-
readonly SplitListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
30
|
-
readonly SinkListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
31
|
-
readonly LiftListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
32
|
-
};
|
|
33
|
-
export declare type Commands = typeof commands;
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from './src/index'
|
package/lib/index.es.js
CHANGED
|
@@ -18,7 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { createMark, createShortcut, createNode, createPlugin, AtomList } from "@milkdown/utils";
|
|
21
|
-
import { css } from "@emotion/css";
|
|
22
21
|
import { createCmdKey, createCmd, schemaCtx, themeToolCtx } from "@milkdown/core";
|
|
23
22
|
import { markRule, toggleMark, TextSelection, InputRule, wrappingInputRule, wrapIn, textblockTypeInputRule, setBlockType, Plugin, PluginKey, ReplaceStep, AddMarkStep, Selection, findSelectedNodeOfType, splitListItem, sinkListItem, liftListItem } from "@milkdown/prose";
|
|
24
23
|
import links from "remark-inline-links";
|
|
@@ -45,7 +44,7 @@ const SupportedKeys = {
|
|
|
45
44
|
const id$a = "code_inline";
|
|
46
45
|
const ToggleInlineCode = createCmdKey();
|
|
47
46
|
const codeInline = createMark((utils) => {
|
|
48
|
-
const style = utils.getStyle(({ palette, size, font }) => css`
|
|
47
|
+
const style = utils.getStyle(({ palette, size, font }, { css }) => css`
|
|
49
48
|
background-color: ${palette("neutral")};
|
|
50
49
|
color: ${palette("background")};
|
|
51
50
|
border-radius: ${size.radius};
|
|
@@ -56,7 +55,9 @@ const codeInline = createMark((utils) => {
|
|
|
56
55
|
return {
|
|
57
56
|
id: id$a,
|
|
58
57
|
schema: () => ({
|
|
59
|
-
|
|
58
|
+
priority: 100,
|
|
59
|
+
code: true,
|
|
60
|
+
inclusive: false,
|
|
60
61
|
parseDOM: [{ tag: "code" }],
|
|
61
62
|
toDOM: (mark) => ["code", { class: utils.getClassName(mark.attrs, "code-inline", style) }],
|
|
62
63
|
parseMarkdown: {
|
|
@@ -69,9 +70,8 @@ const codeInline = createMark((utils) => {
|
|
|
69
70
|
},
|
|
70
71
|
toMarkdown: {
|
|
71
72
|
match: (mark) => mark.type.name === id$a,
|
|
72
|
-
runner: (state,
|
|
73
|
-
state.
|
|
74
|
-
return true;
|
|
73
|
+
runner: (state, mark, node) => {
|
|
74
|
+
state.withMark(mark, "inlineCode", node.text || "");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}),
|
|
@@ -121,7 +121,7 @@ const ToggleLink = createCmdKey();
|
|
|
121
121
|
const ModifyLink = createCmdKey();
|
|
122
122
|
const id$8 = "link";
|
|
123
123
|
const link = createMark((utils) => {
|
|
124
|
-
const style = utils.getStyle((themeTool) => {
|
|
124
|
+
const style = utils.getStyle((themeTool, { css }) => {
|
|
125
125
|
const lineColor = themeTool.palette("line");
|
|
126
126
|
return css`
|
|
127
127
|
color: ${themeTool.palette("secondary")};
|
|
@@ -220,7 +220,7 @@ const link = createMark((utils) => {
|
|
|
220
220
|
const id$7 = "strong";
|
|
221
221
|
const ToggleBold = createCmdKey();
|
|
222
222
|
const strong = createMark((utils) => {
|
|
223
|
-
const style = utils.getStyle(() => css`
|
|
223
|
+
const style = utils.getStyle((_, { css }) => css`
|
|
224
224
|
font-weight: 600;
|
|
225
225
|
`);
|
|
226
226
|
return {
|
|
@@ -261,7 +261,7 @@ const marks = [codeInline(), em(), strong(), link()];
|
|
|
261
261
|
const id$6 = "blockquote";
|
|
262
262
|
const WrapInBlockquote = createCmdKey();
|
|
263
263
|
const blockquote = createNode((utils) => {
|
|
264
|
-
const style = utils.getStyle((themeTool) => css`
|
|
264
|
+
const style = utils.getStyle((themeTool, { css }) => css`
|
|
265
265
|
padding-left: 1.875rem;
|
|
266
266
|
line-height: 1.75rem;
|
|
267
267
|
border-left: 4px solid ${themeTool.palette("primary")};
|
|
@@ -326,7 +326,7 @@ const bulletList = createNode((utils) => {
|
|
|
326
326
|
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
327
327
|
commands: (nodeType) => [createCmd(WrapInBulletList, () => wrapIn(nodeType))],
|
|
328
328
|
shortcuts: {
|
|
329
|
-
[SupportedKeys.BulletList]: createShortcut(WrapInBulletList, "Mod-
|
|
329
|
+
[SupportedKeys.BulletList]: createShortcut(WrapInBulletList, "Mod-Alt-8")
|
|
330
330
|
}
|
|
331
331
|
};
|
|
332
332
|
});
|
|
@@ -353,7 +353,7 @@ const tildeInputRegex = /^~~~(?<language>[a-z]*)?[\s\n]$/;
|
|
|
353
353
|
const TurnIntoCodeFence = createCmdKey();
|
|
354
354
|
const id$5 = "fence";
|
|
355
355
|
const codeFence = createNode((utils, options) => {
|
|
356
|
-
const style = utils.getStyle(({ palette, mixin, size, font }) => {
|
|
356
|
+
const style = utils.getStyle(({ palette, mixin, size, font }, { css }) => {
|
|
357
357
|
const { shadow, scrollbar, border } = mixin;
|
|
358
358
|
const { lineWidth, radius } = size;
|
|
359
359
|
return css`
|
|
@@ -388,7 +388,7 @@ const codeFence = createNode((utils, options) => {
|
|
|
388
388
|
height: 2.625rem;
|
|
389
389
|
align-items: center;
|
|
390
390
|
|
|
391
|
-
& >
|
|
391
|
+
& > .icon {
|
|
392
392
|
width: 2.625rem;
|
|
393
393
|
height: 100%;
|
|
394
394
|
display: flex;
|
|
@@ -489,12 +489,12 @@ const codeFence = createNode((utils, options) => {
|
|
|
489
489
|
],
|
|
490
490
|
toDOM: (node) => {
|
|
491
491
|
return [
|
|
492
|
-
"
|
|
492
|
+
"pre",
|
|
493
493
|
{
|
|
494
494
|
"data-language": node.attrs.language,
|
|
495
495
|
class: utils.getClassName(node.attrs, "code-fence", style)
|
|
496
496
|
},
|
|
497
|
-
["
|
|
497
|
+
["code", { spellCheck: "false" }, 0]
|
|
498
498
|
];
|
|
499
499
|
},
|
|
500
500
|
parseMarkdown: {
|
|
@@ -547,7 +547,9 @@ const codeFence = createNode((utils, options) => {
|
|
|
547
547
|
valueWrapper.className = "code-fence_value";
|
|
548
548
|
const value = document.createElement("span");
|
|
549
549
|
valueWrapper.appendChild(value);
|
|
550
|
-
|
|
550
|
+
if (view.editable) {
|
|
551
|
+
valueWrapper.appendChild(ctx.get(themeToolCtx).slots.icon("downArrow"));
|
|
552
|
+
}
|
|
551
553
|
select.className = "code-fence_select";
|
|
552
554
|
select.addEventListener("mousedown", (e) => {
|
|
553
555
|
e.preventDefault();
|
|
@@ -708,45 +710,70 @@ const hardbreak = createNode((utils) => {
|
|
|
708
710
|
});
|
|
709
711
|
const headingIndex = Array(6).fill(0).map((_, i) => i + 1);
|
|
710
712
|
const TurnIntoHeading = createCmdKey();
|
|
711
|
-
const
|
|
713
|
+
const headingPluginKey = new PluginKey("MILKDOWN_PLUGIN_ID");
|
|
714
|
+
const heading = createNode((utils) => {
|
|
712
715
|
const id2 = "heading";
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
716
|
+
const style = (level) => utils.getStyle((_, { css }) => {
|
|
717
|
+
const headingMap = {
|
|
718
|
+
1: css`
|
|
719
|
+
font-size: 3rem;
|
|
720
|
+
line-height: 3.5rem;
|
|
721
|
+
`,
|
|
722
|
+
2: css`
|
|
723
|
+
font-size: 2.5rem;
|
|
724
|
+
line-height: 3rem;
|
|
725
|
+
`,
|
|
726
|
+
3: css`
|
|
727
|
+
font-size: 2.125rem;
|
|
728
|
+
line-height: 2.25rem;
|
|
729
|
+
`,
|
|
730
|
+
4: css`
|
|
731
|
+
font-size: 1.75rem;
|
|
732
|
+
line-height: 2rem;
|
|
733
|
+
`,
|
|
734
|
+
5: css`
|
|
735
|
+
font-size: 1.5rem;
|
|
736
|
+
line-height: 1.5rem;
|
|
737
|
+
`,
|
|
738
|
+
6: css`
|
|
739
|
+
font-size: 1.25rem;
|
|
740
|
+
line-height: 1.25rem;
|
|
741
|
+
`
|
|
742
|
+
};
|
|
743
|
+
return css`
|
|
744
|
+
${headingMap[level] || ""}
|
|
745
|
+
margin: 2.5rem 0 !important;
|
|
746
|
+
font-weight: 400;
|
|
747
|
+
`;
|
|
748
|
+
});
|
|
732
749
|
return {
|
|
733
750
|
id: id2,
|
|
734
751
|
schema: () => ({
|
|
735
752
|
content: "inline*",
|
|
736
753
|
group: "block",
|
|
754
|
+
defining: true,
|
|
737
755
|
attrs: {
|
|
738
|
-
level: {
|
|
739
|
-
default: 1
|
|
740
|
-
},
|
|
741
756
|
id: {
|
|
742
757
|
default: ""
|
|
758
|
+
},
|
|
759
|
+
level: {
|
|
760
|
+
default: 1
|
|
743
761
|
}
|
|
744
762
|
},
|
|
745
|
-
parseDOM: headingIndex.map((x) => ({
|
|
763
|
+
parseDOM: headingIndex.map((x) => ({
|
|
764
|
+
tag: `h${x}`,
|
|
765
|
+
getAttrs: (node) => {
|
|
766
|
+
if (!(node instanceof HTMLElement)) {
|
|
767
|
+
throw new Error();
|
|
768
|
+
}
|
|
769
|
+
return { level: x, id: node.id };
|
|
770
|
+
}
|
|
771
|
+
})),
|
|
746
772
|
toDOM: (node) => {
|
|
747
773
|
return [
|
|
748
774
|
`h${node.attrs.level}`,
|
|
749
775
|
{
|
|
776
|
+
id: node.attrs.id || node.textContent.split(" ").join("-").toLocaleLowerCase(),
|
|
750
777
|
class: utils.getClassName(node.attrs, `heading h${node.attrs.level}`, style(node.attrs.level))
|
|
751
778
|
},
|
|
752
779
|
0
|
|
@@ -781,13 +808,34 @@ const heading = createNode((utils, options) => {
|
|
|
781
808
|
[SupportedKeys.H4]: createShortcut(TurnIntoHeading, "Mod-Alt-4", 4),
|
|
782
809
|
[SupportedKeys.H5]: createShortcut(TurnIntoHeading, "Mod-Alt-5", 5),
|
|
783
810
|
[SupportedKeys.H6]: createShortcut(TurnIntoHeading, "Mod-Alt-6", 6)
|
|
784
|
-
}
|
|
811
|
+
},
|
|
812
|
+
prosePlugins: (type) => [
|
|
813
|
+
new Plugin({
|
|
814
|
+
key: headingPluginKey,
|
|
815
|
+
appendTransaction: (transactions, _, nextState) => {
|
|
816
|
+
const tr = nextState.tr;
|
|
817
|
+
let modified = false;
|
|
818
|
+
if (transactions.some((transaction) => transaction.docChanged)) {
|
|
819
|
+
nextState.doc.descendants((node, pos) => {
|
|
820
|
+
if (node.type === type) {
|
|
821
|
+
const attrs = node.attrs;
|
|
822
|
+
tr.setNodeMarkup(pos, void 0, __spreadProps(__spreadValues({}, attrs), {
|
|
823
|
+
id: node.textContent.split(" ").join("-").toLocaleLowerCase()
|
|
824
|
+
}));
|
|
825
|
+
modified = true;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
return modified ? tr : null;
|
|
830
|
+
}
|
|
831
|
+
})
|
|
832
|
+
]
|
|
785
833
|
};
|
|
786
834
|
});
|
|
787
835
|
const id$4 = "hr";
|
|
788
836
|
const InsertHr = createCmdKey();
|
|
789
837
|
const hr = createNode((utils) => {
|
|
790
|
-
const style = utils.getStyle((themeTool) => css`
|
|
838
|
+
const style = utils.getStyle((themeTool, { css }) => css`
|
|
791
839
|
height: ${themeTool.size.lineWidth};
|
|
792
840
|
background-color: ${themeTool.palette("line")};
|
|
793
841
|
border-width: 0;
|
|
@@ -852,7 +900,7 @@ const image = createNode((utils, options) => {
|
|
|
852
900
|
failed: "Image loads failed"
|
|
853
901
|
}, (_a = options == null ? void 0 : options.placeholder) != null ? _a : {});
|
|
854
902
|
const isBlock = (_b = options == null ? void 0 : options.isBlock) != null ? _b : false;
|
|
855
|
-
const containerStyle = utils.getStyle((themeTool) => css`
|
|
903
|
+
const containerStyle = utils.getStyle((themeTool, { css }) => css`
|
|
856
904
|
display: inline-block;
|
|
857
905
|
position: relative;
|
|
858
906
|
text-align: center;
|
|
@@ -944,7 +992,7 @@ const image = createNode((utils, options) => {
|
|
|
944
992
|
}
|
|
945
993
|
}
|
|
946
994
|
`);
|
|
947
|
-
const style = utils.getStyle(() => css`
|
|
995
|
+
const style = utils.getStyle((_, { css }) => css`
|
|
948
996
|
display: inline-block;
|
|
949
997
|
margin: 0 auto;
|
|
950
998
|
object-fit: contain;
|
|
@@ -970,7 +1018,7 @@ const image = createNode((utils, options) => {
|
|
|
970
1018
|
title: { default: null },
|
|
971
1019
|
failed: { default: false },
|
|
972
1020
|
loading: { default: true },
|
|
973
|
-
width: { default:
|
|
1021
|
+
width: { default: null }
|
|
974
1022
|
},
|
|
975
1023
|
parseDOM: [
|
|
976
1024
|
{
|
|
@@ -985,7 +1033,7 @@ const image = createNode((utils, options) => {
|
|
|
985
1033
|
src: dom.getAttribute("src") || "",
|
|
986
1034
|
alt: dom.getAttribute("alt"),
|
|
987
1035
|
title: dom.getAttribute("title") || dom.getAttribute("alt"),
|
|
988
|
-
width: dom.getAttribute("width")
|
|
1036
|
+
width: dom.getAttribute("width")
|
|
989
1037
|
};
|
|
990
1038
|
}
|
|
991
1039
|
}
|
|
@@ -1076,8 +1124,11 @@ const image = createNode((utils, options) => {
|
|
|
1076
1124
|
const img = document.createElement("img");
|
|
1077
1125
|
img.src = src2;
|
|
1078
1126
|
img.onerror = () => {
|
|
1127
|
+
const pos = getPos();
|
|
1128
|
+
if (!pos)
|
|
1129
|
+
return;
|
|
1079
1130
|
const { tr } = view.state;
|
|
1080
|
-
const _tr = tr.setNodeMarkup(
|
|
1131
|
+
const _tr = tr.setNodeMarkup(pos, nodeType, __spreadProps(__spreadValues({}, node.attrs), {
|
|
1081
1132
|
src: src2,
|
|
1082
1133
|
loading: false,
|
|
1083
1134
|
failed: true
|
|
@@ -1086,7 +1137,10 @@ const image = createNode((utils, options) => {
|
|
|
1086
1137
|
};
|
|
1087
1138
|
img.onload = () => {
|
|
1088
1139
|
const { tr } = view.state;
|
|
1089
|
-
const
|
|
1140
|
+
const pos = getPos();
|
|
1141
|
+
if (!pos)
|
|
1142
|
+
return;
|
|
1143
|
+
const _tr = tr.setNodeMarkup(pos, nodeType, __spreadProps(__spreadValues({}, node.attrs), {
|
|
1090
1144
|
width: img.width,
|
|
1091
1145
|
src: src2,
|
|
1092
1146
|
loading: false,
|
|
@@ -1099,7 +1153,9 @@ const image = createNode((utils, options) => {
|
|
|
1099
1153
|
content.src = src;
|
|
1100
1154
|
content.title = title || alt;
|
|
1101
1155
|
content.alt = alt;
|
|
1102
|
-
|
|
1156
|
+
if (width) {
|
|
1157
|
+
content.width = width;
|
|
1158
|
+
}
|
|
1103
1159
|
if (src.length === 0) {
|
|
1104
1160
|
container.classList.add("system", "empty");
|
|
1105
1161
|
setIcon("image");
|
|
@@ -1115,7 +1171,9 @@ const image = createNode((utils, options) => {
|
|
|
1115
1171
|
content.src = src2;
|
|
1116
1172
|
content.alt = alt2;
|
|
1117
1173
|
content.title = title2 || alt2;
|
|
1118
|
-
|
|
1174
|
+
if (width2) {
|
|
1175
|
+
content.width = width2;
|
|
1176
|
+
}
|
|
1119
1177
|
if (loading2) {
|
|
1120
1178
|
loadImage(src2);
|
|
1121
1179
|
return true;
|
|
@@ -1149,7 +1207,7 @@ const SplitListItem = createCmdKey();
|
|
|
1149
1207
|
const SinkListItem = createCmdKey();
|
|
1150
1208
|
const LiftListItem = createCmdKey();
|
|
1151
1209
|
const listItem = createNode((utils) => {
|
|
1152
|
-
const style = utils.getStyle((themeTool) => css`
|
|
1210
|
+
const style = utils.getStyle((themeTool, { css }) => css`
|
|
1153
1211
|
&,
|
|
1154
1212
|
& > * {
|
|
1155
1213
|
margin: 0.5rem 0;
|
|
@@ -1250,17 +1308,19 @@ const orderedList = createNode((utils) => ({
|
|
|
1250
1308
|
],
|
|
1251
1309
|
commands: (nodeType) => [createCmd(WrapInOrderedList, () => wrapIn(nodeType))],
|
|
1252
1310
|
shortcuts: {
|
|
1253
|
-
[SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, "Mod-
|
|
1311
|
+
[SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, "Mod-Alt-7")
|
|
1254
1312
|
}
|
|
1255
1313
|
}));
|
|
1256
1314
|
const TurnIntoText = createCmdKey();
|
|
1257
1315
|
const id = "paragraph";
|
|
1258
|
-
const paragraph = createNode((utils
|
|
1259
|
-
const style = (
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1316
|
+
const paragraph = createNode((utils) => {
|
|
1317
|
+
const style = utils.getStyle((_, { css }) => {
|
|
1318
|
+
return css`
|
|
1319
|
+
font-size: 1rem;
|
|
1320
|
+
line-height: 1.5;
|
|
1321
|
+
letter-spacing: 0.5px;
|
|
1322
|
+
`;
|
|
1323
|
+
});
|
|
1264
1324
|
return {
|
|
1265
1325
|
id,
|
|
1266
1326
|
schema: () => ({
|
|
@@ -1385,5 +1445,5 @@ const commands = {
|
|
|
1385
1445
|
SinkListItem,
|
|
1386
1446
|
LiftListItem
|
|
1387
1447
|
};
|
|
1388
|
-
export { InsertHardbreak, InsertHr, InsertImage, LiftListItem, ModifyImage, ModifyLink, SinkListItem, SplitListItem, SupportedKeys, ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink, TurnIntoCodeFence, TurnIntoHeading, TurnIntoText, WrapInBlockquote, WrapInBulletList, WrapInOrderedList, backtickInputRegex, blockquote, bulletList, codeFence, codeInline, commands, commonmark, commonmarkNodes, commonmarkPlugins, doc, em, hardbreak, heading, hr, image, link, listItem, marks, nodes, orderedList, paragraph, strong, text, tildeInputRegex };
|
|
1448
|
+
export { InsertHardbreak, InsertHr, InsertImage, LiftListItem, ModifyImage, ModifyLink, SinkListItem, SplitListItem, SupportedKeys, ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink, TurnIntoCodeFence, TurnIntoHeading, TurnIntoText, WrapInBlockquote, WrapInBulletList, WrapInOrderedList, backtickInputRegex, blockquote, bulletList, codeFence, codeInline, commands, commonmark, commonmarkNodes, commonmarkPlugins, doc, em, hardbreak, heading, headingPluginKey, hr, image, link, listItem, marks, nodes, orderedList, paragraph, strong, text, tildeInputRegex };
|
|
1389
1449
|
//# sourceMappingURL=index.es.js.map
|