@milkdown/preset-gfm 6.3.0 → 6.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"strike-through.d.ts","sourceRoot":"","sources":["../src/strike-through.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,mBAAmB,4CAAsC,CAAC;AAGvE,eAAO,MAAM,aAAa,wFAiCxB,CAAC"}
1
+ {"version":3,"file":"strike-through.d.ts","sourceRoot":"","sources":["../src/strike-through.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,4CAAsC,CAAC;AAGvE,eAAO,MAAM,aAAa,wFA8BxB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { PluginKey } from '@milkdown/prose/state';
2
1
  export declare const SupportedKeys: {
3
2
  readonly NextCell: "NextCell";
4
3
  readonly PrevCell: "PrevCell";
@@ -9,6 +8,5 @@ export declare const PrevCell: import("@milkdown/core").CmdKey<undefined>;
9
8
  export declare const NextCell: import("@milkdown/core").CmdKey<undefined>;
10
9
  export declare const BreakTable: import("@milkdown/core").CmdKey<undefined>;
11
10
  export declare const InsertTable: import("@milkdown/core").CmdKey<undefined>;
12
- export declare const TableContentFilterPluginKey: PluginKey<any>;
13
11
  export declare const table: import("@milkdown/utils").WithExtend<"NextCell" | "PrevCell" | "ExitTable", Record<string, unknown>, import("@milkdown/utils").TypeMapping<"table" | "table_row" | "table_cell" | "table_header", string>, import("@milkdown/utils").PluginRest<"table" | "table_row" | "table_cell" | "table_header", string>>;
14
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/nodes/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,SAAS,EAA4B,MAAM,uBAAuB,CAAC;AAYpF,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AACX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC;AAIjD,eAAO,MAAM,QAAQ,4CAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,4CAA2B,CAAC;AACjD,eAAO,MAAM,UAAU,4CAA6B,CAAC;AACrD,eAAO,MAAM,WAAW,4CAA8B,CAAC;AAEvD,eAAO,MAAM,2BAA2B,gBAAiD,CAAC;AAE1F,eAAO,MAAM,KAAK,iTAwKhB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/nodes/index.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AACX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC;AAIjD,eAAO,MAAM,QAAQ,4CAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,4CAA2B,CAAC;AACjD,eAAO,MAAM,UAAU,4CAA6B,CAAC;AACrD,eAAO,MAAM,WAAW,4CAA8B,CAAC;AAEvD,eAAO,MAAM,KAAK,iTA8IhB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Ctx } from '@milkdown/core';
2
2
  import { Plugin } from '@milkdown/prose/state';
3
- import { Utils } from '@milkdown/utils';
3
+ import { ThemeUtils } from '@milkdown/utils';
4
4
  export declare const key = "MILKDOWN_TABLE";
5
- export declare const operatorPlugin: (ctx: Ctx, utils: Utils) => Plugin<any>;
5
+ export declare const operatorPlugin: (ctx: Ctx, utils: ThemeUtils) => Plugin<any>;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/operator-plugin/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAWxC,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,cAAc,QAAS,GAAG,SAAS,KAAK,gBAkFpD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/operator-plugin/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAW7C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,cAAc,QAAS,GAAG,SAAS,UAAU,gBAkFzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/preset-gfm",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "type": "module",
5
5
  "main": "./lib/index.es.js",
6
6
  "types": "./lib/index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "gfm"
18
18
  ],
19
19
  "devDependencies": {
20
- "@milkdown/core": "6.3.0",
21
- "@milkdown/design-system": "6.3.0",
22
- "@milkdown/preset-commonmark": "6.3.0",
23
- "@milkdown/prose": "6.3.0"
20
+ "@milkdown/core": "6.4.0",
21
+ "@milkdown/design-system": "6.4.0",
22
+ "@milkdown/preset-commonmark": "6.4.0",
23
+ "@milkdown/prose": "6.4.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@milkdown/core": "^6.0.1",
@@ -28,8 +28,8 @@
28
28
  "@milkdown/prose": "^6.0.1"
29
29
  },
30
30
  "dependencies": {
31
- "@milkdown/utils": "6.3.0",
32
- "@milkdown/exception": "6.3.0",
31
+ "@milkdown/utils": "6.4.0",
32
+ "@milkdown/exception": "6.4.0",
33
33
  "remark-gfm": "^3.0.0",
34
34
  "tslib": "^2.4.0"
35
35
  },
package/src/index.ts CHANGED
@@ -3,7 +3,6 @@ import { commands as commonmarkCommands, commonmark } from '@milkdown/preset-com
3
3
  import { $remark, AtomList } from '@milkdown/utils';
4
4
  import remarkGFM from 'remark-gfm';
5
5
 
6
- import { urlPlugin } from './auto-link';
7
6
  import { footnoteReference } from './footnote';
8
7
  import { footnoteDefinition } from './footnote/definition';
9
8
  import { strikeThrough, ToggleStrikeThrough } from './strike-through';
@@ -42,7 +41,7 @@ export {
42
41
  // node
43
42
  doc,
44
43
  em,
45
- hardbreak,
44
+ HardbreakFilterPluginKey as hardbreak,
46
45
  heading,
47
46
  hr,
48
47
  image,
@@ -77,7 +76,6 @@ export const gfm = AtomList.create([
77
76
  ...commonmark,
78
77
  $remark(() => remarkGFM),
79
78
  table(),
80
- urlPlugin,
81
79
  strikeThrough(),
82
80
  taskListItem(),
83
81
  footnoteReference(),
@@ -1,6 +1,5 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { createCmd, createCmdKey } from '@milkdown/core';
3
- import { markRule } from '@milkdown/prose';
4
3
  import { toggleMark } from '@milkdown/prose/commands';
5
4
  import { createMark, createShortcut } from '@milkdown/utils';
6
5
 
@@ -15,6 +14,7 @@ export const strikeThrough = createMark<Keys>((utils) => {
15
14
  return {
16
15
  id,
17
16
  schema: () => ({
17
+ inclusive: false,
18
18
  parseDOM: [
19
19
  { tag: 'del' },
20
20
  { style: 'text-decoration', getAttrs: (value) => (value === 'line-through') as false },
@@ -35,10 +35,6 @@ export const strikeThrough = createMark<Keys>((utils) => {
35
35
  },
36
36
  },
37
37
  }),
38
- inputRules: (markType) => [
39
- markRule(/(?:~~)([^~]+)(?:~~)$/, markType),
40
- markRule(/(?:^|[^~])(~([^~]+)~)$/, markType),
41
- ],
42
38
  commands: (markType) => [createCmd(ToggleStrikeThrough, () => toggleMark(markType))],
43
39
  shortcuts: {
44
40
  [SupportedKeys.StrikeThrough]: createShortcut(ToggleStrikeThrough, 'Mod-Alt-x'),
@@ -2,7 +2,7 @@
2
2
  import { createCmd, createCmdKey, MarkdownNode, schemaCtx } from '@milkdown/core';
3
3
  import { InputRule } from '@milkdown/prose/inputrules';
4
4
  import { NodeType } from '@milkdown/prose/model';
5
- import { Plugin, PluginKey, Selection, TextSelection } from '@milkdown/prose/state';
5
+ import { Selection, TextSelection } from '@milkdown/prose/state';
6
6
  import { createPlugin, createShortcut } from '@milkdown/utils';
7
7
 
8
8
  import { exitTable } from '../command';
@@ -28,8 +28,6 @@ export const NextCell = createCmdKey('NextCell');
28
28
  export const BreakTable = createCmdKey('BreakTable');
29
29
  export const InsertTable = createCmdKey('InsertTable');
30
30
 
31
- export const TableContentFilterPluginKey = new PluginKey('MILKDOWN_TABLE_CONTENT_FILTER');
32
-
33
31
  export const table = createPlugin<Keys, Record<string, unknown>, keyof typeof schema>((utils) => {
34
32
  return {
35
33
  schema: () => ({
@@ -169,33 +167,7 @@ export const table = createPlugin<Keys, Record<string, unknown>, keyof typeof sc
169
167
  [SupportedKeys.ExitTable]: createShortcut(BreakTable, 'Mod-Enter'),
170
168
  },
171
169
  prosePlugins: (_, ctx) => {
172
- return [
173
- operatorPlugin(ctx, utils),
174
- autoInsertZeroSpace(),
175
- columnResizing(),
176
- tableEditing(),
177
- new Plugin({
178
- key: TableContentFilterPluginKey,
179
- filterTransaction: (tr, state) => {
180
- const isInsertHr = tr.getMeta('hardbreak');
181
- const [step] = tr.steps;
182
- if (isInsertHr && step) {
183
- const { from } = step as unknown as { from: number };
184
- const $from = state.doc.resolve(from);
185
- let curDepth = $from.depth;
186
- let canApply = true;
187
- while (curDepth > 0) {
188
- if ($from.node(curDepth).type.name === 'table') {
189
- canApply = false;
190
- }
191
- curDepth--;
192
- }
193
- return canApply;
194
- }
195
- return true;
196
- },
197
- }),
198
- ];
170
+ return [operatorPlugin(ctx, utils), autoInsertZeroSpace(), columnResizing(), tableEditing()];
199
171
  },
200
172
  };
201
173
  });
@@ -3,7 +3,7 @@
3
3
  import { Ctx } from '@milkdown/core';
4
4
  import { Plugin, PluginKey } from '@milkdown/prose/state';
5
5
  import { Decoration, DecorationSet } from '@milkdown/prose/view';
6
- import { Utils } from '@milkdown/utils';
6
+ import { ThemeUtils } from '@milkdown/utils';
7
7
 
8
8
  import { CellSelection } from '../plugin';
9
9
  import { CellPos, getCellsInColumn, getCellsInRow } from '../utils';
@@ -16,7 +16,7 @@ import { createWidget } from './widget';
16
16
 
17
17
  export const key = 'MILKDOWN_TABLE';
18
18
 
19
- export const operatorPlugin = (ctx: Ctx, utils: Utils) => {
19
+ export const operatorPlugin = (ctx: Ctx, utils: ThemeUtils) => {
20
20
  return new Plugin({
21
21
  key: new PluginKey('MILKDOWN_TABLE_OP'),
22
22
  props: {
@@ -10,8 +10,8 @@ export const injectStyle = (themeManager: ThemeManager, { css, injectGlobal }: E
10
10
  .milkdown {
11
11
  .tableWrapper {
12
12
  table {
13
- width: calc(100% - 2em) !important;
14
- margin: 1em 0 1em 1em !important;
13
+ width: calc(100% - 32px) !important;
14
+ margin: 16px 0 16px 16px !important;
15
15
 
16
16
  .milkdown-cell-left,
17
17
  .milkdown-cell-point,
@@ -37,24 +37,24 @@ export const injectStyle = (themeManager: ThemeManager, { css, injectGlobal }: E
37
37
  }
38
38
 
39
39
  .milkdown-cell-left {
40
- left: calc(-6px - 0.5em);
40
+ left: -14px;
41
41
  top: 0;
42
42
  bottom: 0;
43
- width: 0.5em;
43
+ width: 8px;
44
44
  }
45
45
 
46
46
  .milkdown-cell-top {
47
47
  left: 0;
48
48
  right: 0;
49
- top: calc(-6px - 0.5em);
50
- height: 0.5em;
49
+ top: -14px;
50
+ height: 8px;
51
51
  }
52
52
 
53
53
  .milkdown-cell-point {
54
- left: calc(-2px - 1em);
55
- top: calc(-2px - 1em);
56
- width: 1em;
57
- height: 1em;
54
+ left: -18px;
55
+ top: -18px;
56
+ width: 16px;
57
+ height: 16px;
58
58
 
59
59
  .icon {
60
60
  position: absolute;
@@ -90,8 +90,8 @@ export const injectStyle = (themeManager: ThemeManager, { css, injectGlobal }: E
90
90
  position: relative;
91
91
  color: ${palette('solid', 0.87)};
92
92
 
93
- width: 2em;
94
- line-height: 2em;
93
+ width: 48px;
94
+ line-height: 48px;
95
95
  text-align: center;
96
96
  transition: all 0.4s ease-in-out;
97
97
 
@@ -1,2 +0,0 @@
1
- export declare const urlPlugin: import("@milkdown/utils").$Prose;
2
- //# sourceMappingURL=auto-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-link.d.ts","sourceRoot":"","sources":["../src/auto-link.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,SAAS,kCAAiC,CAAC"}
package/src/auto-link.ts DELETED
@@ -1,23 +0,0 @@
1
- /* Copyright 2021, Milkdown by Mirone. */
2
- import { InputRule, inputRules } from '@milkdown/prose/inputrules';
3
- import { $prose } from '@milkdown/utils';
4
-
5
- const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/;
6
-
7
- const proseUrlPlugin = () =>
8
- inputRules({
9
- rules: [
10
- new InputRule(urlRegex, (state, match, start, end) => {
11
- const { schema } = state;
12
- const [text] = match;
13
- if (!text) return null;
14
-
15
- const link = schema.marks['link']?.create({ href: text });
16
- if (!link) return null;
17
-
18
- return state.tr.replaceWith(start, end, schema.text(text)).addMark(start, text.length + start, link);
19
- }),
20
- ],
21
- });
22
-
23
- export const urlPlugin = $prose(() => proseUrlPlugin());