@prosekit/core 0.9.0 → 0.10.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/dist/{editor-4lgGc3CY.d.ts → editor-BULC1zqX.d.ts} +12 -12
- package/dist/editor-BULC1zqX.d.ts.map +1 -0
- package/dist/{editor-DGNUXn-u.js → editor-g-Rqn-ZE.js} +30 -30
- package/dist/editor-g-Rqn-ZE.js.map +1 -0
- package/dist/prosekit-core-test.d.ts +1 -2
- package/dist/prosekit-core-test.d.ts.map +1 -1
- package/dist/prosekit-core-test.js +1 -1
- package/dist/prosekit-core-test.js.map +1 -1
- package/dist/prosekit-core.d.ts +103 -24
- package/dist/prosekit-core.d.ts.map +1 -1
- package/dist/prosekit-core.js +116 -35
- package/dist/prosekit-core.js.map +1 -1
- package/package.json +6 -7
- package/src/commands/add-mark.ts +1 -4
- package/src/commands/expand-mark.ts +2 -9
- package/src/commands/insert-default-block.spec.ts +1 -5
- package/src/commands/insert-default-block.ts +1 -4
- package/src/commands/insert-node.ts +4 -8
- package/src/commands/remove-mark.ts +1 -4
- package/src/commands/remove-node.ts +2 -2
- package/src/commands/select-block.spec.ts +4 -6
- package/src/commands/select-block.ts +1 -4
- package/src/commands/set-block-type.ts +1 -4
- package/src/commands/set-node-attrs-between.spec.ts +221 -0
- package/src/commands/set-node-attrs-between.ts +77 -0
- package/src/commands/set-node-attrs.spec.ts +129 -0
- package/src/commands/set-node-attrs.ts +25 -26
- package/src/commands/toggle-mark.ts +1 -4
- package/src/commands/toggle-node.ts +2 -5
- package/src/commands/toggle-wrap.spec.ts +1 -5
- package/src/commands/toggle-wrap.ts +1 -4
- package/src/commands/unset-block-type.spec.ts +1 -5
- package/src/commands/unset-block-type.ts +2 -8
- package/src/commands/unset-mark.spec.ts +1 -5
- package/src/commands/wrap.ts +1 -4
- package/src/editor/action.spec.ts +2 -6
- package/src/editor/action.ts +1 -8
- package/src/editor/editor.spec.ts +2 -9
- package/src/editor/editor.ts +11 -45
- package/src/editor/union.spec.ts +1 -5
- package/src/editor/union.ts +1 -4
- package/src/extensions/clipboard-serializer.ts +4 -16
- package/src/extensions/command.ts +16 -48
- package/src/extensions/default-state.spec.ts +1 -5
- package/src/extensions/default-state.ts +2 -8
- package/src/extensions/events/dom-event.spec.ts +1 -6
- package/src/extensions/events/dom-event.ts +4 -16
- package/src/extensions/events/editor-event.ts +4 -16
- package/src/extensions/events/focus.spec.ts +1 -6
- package/src/extensions/events/plugin-view.ts +2 -9
- package/src/extensions/history.ts +2 -9
- package/src/extensions/keymap-base.spec.ts +2 -11
- package/src/extensions/keymap-base.ts +1 -4
- package/src/extensions/keymap.spec.ts +6 -20
- package/src/extensions/keymap.ts +3 -13
- package/src/extensions/mark-spec.spec.ts +5 -20
- package/src/extensions/mark-spec.ts +4 -15
- package/src/extensions/mark-view-effect.ts +3 -9
- package/src/extensions/mark-view.ts +2 -8
- package/src/extensions/node-spec.spec.ts +5 -21
- package/src/extensions/node-spec.ts +4 -15
- package/src/extensions/node-view-effect.ts +3 -9
- package/src/extensions/node-view.ts +2 -8
- package/src/extensions/plugin.spec.ts +3 -16
- package/src/extensions/plugin.ts +3 -12
- package/src/facets/base-extension.ts +1 -4
- package/src/facets/command.ts +2 -8
- package/src/facets/facet-extension.spec.ts +4 -15
- package/src/facets/facet-node.spec.ts +2 -9
- package/src/facets/facet-node.ts +4 -9
- package/src/facets/facet.spec.ts +1 -4
- package/src/facets/schema-spec.ts +2 -9
- package/src/facets/schema.ts +3 -12
- package/src/facets/state.spec.ts +2 -9
- package/src/facets/state.ts +4 -18
- package/src/facets/union-extension.ts +2 -8
- package/src/index.ts +40 -166
- package/src/test/index.ts +1 -4
- package/src/test/test-builder.ts +1 -4
- package/src/test/test-editor.spec.ts +1 -5
- package/src/test/test-editor.ts +5 -24
- package/src/testing/index.ts +18 -14
- package/src/types/extension.spec.ts +1 -4
- package/src/types/extension.ts +3 -13
- package/src/types/simplify-union.ts +1 -4
- package/src/utils/array-grouping.spec.ts +1 -4
- package/src/utils/attrs-match.ts +1 -5
- package/src/utils/clsx.spec.ts +1 -4
- package/src/utils/combine-event-handlers.spec.ts +1 -5
- package/src/utils/default-block-at.ts +1 -4
- package/src/utils/editor-content.spec.ts +1 -4
- package/src/utils/editor-content.ts +4 -16
- package/src/utils/find-node.ts +65 -0
- package/src/utils/find-parent-node-of-type.ts +6 -12
- package/src/utils/find-parent-node.spec.ts +1 -5
- package/src/utils/find-parent-node.ts +1 -4
- package/src/utils/get-custom-selection.ts +1 -5
- package/src/utils/get-mark-type.ts +1 -4
- package/src/utils/get-node-type.ts +1 -4
- package/src/utils/get-node-types.ts +1 -4
- package/src/utils/includes-mark.ts +1 -5
- package/src/utils/is-at-block-start.ts +1 -4
- package/src/utils/is-mark-absent.spec.ts +1 -4
- package/src/utils/is-mark-absent.ts +1 -5
- package/src/utils/is-mark-active.ts +1 -4
- package/src/utils/is-node-active.spec.ts +109 -0
- package/src/utils/is-node-active.ts +17 -8
- package/src/utils/is-subset.spec.ts +1 -4
- package/src/utils/maybe-run.spec.ts +1 -5
- package/src/utils/merge-objects.spec.ts +1 -4
- package/src/utils/merge-objects.ts +2 -1
- package/src/utils/merge-specs.ts +1 -4
- package/src/utils/object-equal.spec.ts +1 -4
- package/src/utils/output-spec.test.ts +1 -5
- package/src/utils/output-spec.ts +2 -10
- package/src/utils/parse.spec.ts +2 -11
- package/src/utils/parse.ts +3 -15
- package/src/utils/remove-undefined-values.spec.ts +1 -4
- package/src/utils/set-selection-around.ts +1 -4
- package/src/utils/type-assertion.ts +2 -21
- package/src/utils/unicode.spec.ts +1 -4
- package/dist/editor-4lgGc3CY.d.ts.map +0 -1
- package/dist/editor-DGNUXn-u.js.map +0 -1
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '@prosekit/pm/model'
|
|
5
|
-
import formatHTML from 'diffable-html'
|
|
6
|
-
import {
|
|
7
|
-
describe,
|
|
8
|
-
expect,
|
|
9
|
-
it,
|
|
10
|
-
} from 'vitest'
|
|
1
|
+
import type { DOMOutputSpec, TagParseRule } from '@prosekit/pm/model'
|
|
2
|
+
import { formatHTML } from 'diffable-html-snapshot'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
11
4
|
|
|
12
5
|
import { union } from '../editor/union'
|
|
13
|
-
import {
|
|
14
|
-
defineDoc,
|
|
15
|
-
defineParagraph,
|
|
16
|
-
defineText,
|
|
17
|
-
setupTestFromExtension,
|
|
18
|
-
} from '../testing'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing'
|
|
19
7
|
|
|
20
|
-
import {
|
|
21
|
-
defineMarkAttr,
|
|
22
|
-
defineMarkSpec,
|
|
23
|
-
} from './mark-spec'
|
|
8
|
+
import { defineMarkAttr, defineMarkSpec } from './mark-spec'
|
|
24
9
|
|
|
25
10
|
describe('defineMarkSpec', () => {
|
|
26
11
|
it('can merge mark specs', () => {
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { mapGroupBy } from '@ocavue/utils'
|
|
2
|
-
import type {
|
|
3
|
-
AttributeSpec,
|
|
4
|
-
MarkSpec,
|
|
5
|
-
SchemaSpec,
|
|
6
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import { isNotNullish, mapGroupBy } from '@ocavue/utils'
|
|
2
|
+
import type { AttributeSpec, MarkSpec, SchemaSpec } from '@prosekit/pm/model'
|
|
7
3
|
import OrderedMap from 'orderedmap'
|
|
8
4
|
|
|
9
5
|
import { defineFacet } from '../facets/facet'
|
|
10
6
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
11
7
|
import { schemaSpecFacet } from '../facets/schema-spec'
|
|
12
|
-
import type {
|
|
13
|
-
AnyAttrs,
|
|
14
|
-
AttrSpec,
|
|
15
|
-
} from '../types/attrs'
|
|
8
|
+
import type { AnyAttrs, AttrSpec } from '../types/attrs'
|
|
16
9
|
import type { Extension } from '../types/extension'
|
|
17
10
|
import { assert } from '../utils/assert'
|
|
18
11
|
import { mergeSpecs } from '../utils/merge-specs'
|
|
19
|
-
import {
|
|
20
|
-
wrapOutputSpecAttrs,
|
|
21
|
-
wrapParseRuleAttrs,
|
|
22
|
-
} from '../utils/output-spec'
|
|
23
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
12
|
+
import { wrapOutputSpecAttrs, wrapParseRuleAttrs } from '../utils/output-spec'
|
|
24
13
|
|
|
25
14
|
/**
|
|
26
15
|
* @public
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
3
|
import type { MarkViewConstructor } from '@prosekit/pm/view'
|
|
6
4
|
|
|
7
5
|
import { defineFacet } from '../facets/facet'
|
|
8
6
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
9
7
|
import type { Extension } from '../types/extension'
|
|
10
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
11
8
|
|
|
12
|
-
import {
|
|
13
|
-
pluginFacet,
|
|
14
|
-
type PluginPayload,
|
|
15
|
-
} from './plugin'
|
|
9
|
+
import { pluginFacet, type PluginPayload } from './plugin'
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* @internal
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginKey,
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
2
|
import type { MarkViewConstructor } from '@prosekit/pm/view'
|
|
6
3
|
|
|
7
4
|
import { defineFacet } from '../facets/facet'
|
|
8
5
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
9
6
|
import type { Extension } from '../types/extension'
|
|
10
7
|
|
|
11
|
-
import {
|
|
12
|
-
pluginFacet,
|
|
13
|
-
type PluginPayload,
|
|
14
|
-
} from './plugin'
|
|
8
|
+
import { pluginFacet, type PluginPayload } from './plugin'
|
|
15
9
|
|
|
16
10
|
export interface MarkViewOptions {
|
|
17
11
|
name: string
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
TagParseRule,
|
|
5
|
-
} from '@prosekit/pm/model'
|
|
6
|
-
import formatHTML from 'diffable-html'
|
|
7
|
-
import {
|
|
8
|
-
describe,
|
|
9
|
-
expect,
|
|
10
|
-
it,
|
|
11
|
-
} from 'vitest'
|
|
1
|
+
import type { DOMOutputSpec, Schema, TagParseRule } from '@prosekit/pm/model'
|
|
2
|
+
import { formatHTML } from 'diffable-html-snapshot'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
12
4
|
|
|
13
5
|
import { union } from '../editor/union'
|
|
14
|
-
import {
|
|
15
|
-
defineDoc,
|
|
16
|
-
defineParagraph,
|
|
17
|
-
defineText,
|
|
18
|
-
setupTestFromExtension,
|
|
19
|
-
} from '../testing'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing'
|
|
20
7
|
|
|
21
8
|
import { defineHistory } from './history'
|
|
22
9
|
import { defineBaseKeymap } from './keymap-base'
|
|
23
|
-
import {
|
|
24
|
-
defineNodeAttr,
|
|
25
|
-
defineNodeSpec,
|
|
26
|
-
} from './node-spec'
|
|
10
|
+
import { defineNodeAttr, defineNodeSpec } from './node-spec'
|
|
27
11
|
|
|
28
12
|
describe('defineNodeSpec', () => {
|
|
29
13
|
it('can merge node specs', () => {
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { mapGroupBy } from '@ocavue/utils'
|
|
2
|
-
import type {
|
|
3
|
-
AttributeSpec,
|
|
4
|
-
NodeSpec,
|
|
5
|
-
SchemaSpec,
|
|
6
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import { isNotNullish, mapGroupBy } from '@ocavue/utils'
|
|
2
|
+
import type { AttributeSpec, NodeSpec, SchemaSpec } from '@prosekit/pm/model'
|
|
7
3
|
import OrderedMap from 'orderedmap'
|
|
8
4
|
|
|
9
5
|
import { defineFacet } from '../facets/facet'
|
|
10
6
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
11
7
|
import { schemaSpecFacet } from '../facets/schema-spec'
|
|
12
|
-
import type {
|
|
13
|
-
AnyAttrs,
|
|
14
|
-
AttrSpec,
|
|
15
|
-
} from '../types/attrs'
|
|
8
|
+
import type { AnyAttrs, AttrSpec } from '../types/attrs'
|
|
16
9
|
import type { Extension } from '../types/extension'
|
|
17
10
|
import { assert } from '../utils/assert'
|
|
18
11
|
import { mergeSpecs } from '../utils/merge-specs'
|
|
19
|
-
import {
|
|
20
|
-
wrapOutputSpecAttrs,
|
|
21
|
-
wrapTagParseRuleAttrs,
|
|
22
|
-
} from '../utils/output-spec'
|
|
23
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
12
|
+
import { wrapOutputSpecAttrs, wrapTagParseRuleAttrs } from '../utils/output-spec'
|
|
24
13
|
|
|
25
14
|
/**
|
|
26
15
|
* @public
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
3
|
import type { NodeViewConstructor } from '@prosekit/pm/view'
|
|
6
4
|
|
|
7
5
|
import { defineFacet } from '../facets/facet'
|
|
8
6
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
9
7
|
import type { Extension } from '../types/extension'
|
|
10
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
11
8
|
|
|
12
|
-
import {
|
|
13
|
-
pluginFacet,
|
|
14
|
-
type PluginPayload,
|
|
15
|
-
} from './plugin'
|
|
9
|
+
import { pluginFacet, type PluginPayload } from './plugin'
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* @internal
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginKey,
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
2
|
import type { NodeViewConstructor } from '@prosekit/pm/view'
|
|
6
3
|
|
|
7
4
|
import { defineFacet } from '../facets/facet'
|
|
8
5
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
9
6
|
import type { Extension } from '../types/extension'
|
|
10
7
|
|
|
11
|
-
import {
|
|
12
|
-
pluginFacet,
|
|
13
|
-
type PluginPayload,
|
|
14
|
-
} from './plugin'
|
|
8
|
+
import { pluginFacet, type PluginPayload } from './plugin'
|
|
15
9
|
|
|
16
10
|
export interface NodeViewOptions {
|
|
17
11
|
name: string
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
PluginKey,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
5
|
-
import {
|
|
6
|
-
describe,
|
|
7
|
-
expect,
|
|
8
|
-
it,
|
|
9
|
-
vi,
|
|
10
|
-
} from 'vitest'
|
|
1
|
+
import { Plugin, PluginKey } from '@prosekit/pm/state'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
11
3
|
|
|
12
4
|
import { union } from '../editor/union'
|
|
13
5
|
import { withPriority } from '../editor/with-priority'
|
|
14
|
-
import {
|
|
15
|
-
defineDoc,
|
|
16
|
-
defineParagraph,
|
|
17
|
-
defineText,
|
|
18
|
-
setupTestFromExtension,
|
|
19
|
-
} from '../testing'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing'
|
|
20
7
|
import { Priority } from '../types/priority'
|
|
21
8
|
|
|
22
9
|
import { definePlugin } from './plugin'
|
package/src/extensions/plugin.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import type { Schema } from '@prosekit/pm/model'
|
|
2
|
-
import {
|
|
3
|
-
Plugin,
|
|
4
|
-
type ProseMirrorPlugin,
|
|
5
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import { Plugin, type ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
6
3
|
|
|
7
4
|
import { ProseKitError } from '../error'
|
|
8
|
-
import {
|
|
9
|
-
defineFacet,
|
|
10
|
-
type Facet,
|
|
11
|
-
} from '../facets/facet'
|
|
5
|
+
import { defineFacet, type Facet } from '../facets/facet'
|
|
12
6
|
import { defineFacetPayload } from '../facets/facet-extension'
|
|
13
|
-
import {
|
|
14
|
-
stateFacet,
|
|
15
|
-
type StatePayload,
|
|
16
|
-
} from '../facets/state'
|
|
7
|
+
import { stateFacet, type StatePayload } from '../facets/state'
|
|
17
8
|
import type { PlainExtension } from '../types/extension'
|
|
18
9
|
|
|
19
10
|
/**
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Schema } from '@prosekit/pm/model'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
Extension,
|
|
5
|
-
ExtensionTyping,
|
|
6
|
-
} from '../types/extension'
|
|
3
|
+
import type { Extension, ExtensionTyping } from '../types/extension'
|
|
7
4
|
import { Priority } from '../types/priority'
|
|
8
5
|
|
|
9
6
|
import type { Facet } from './facet'
|
package/src/facets/command.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { CommandCreators } from '../types/extension-command'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type Facet,
|
|
6
|
-
} from './facet'
|
|
7
|
-
import {
|
|
8
|
-
rootFacet,
|
|
9
|
-
type RootPayload,
|
|
10
|
-
} from './root'
|
|
3
|
+
import { defineFacet, type Facet } from './facet'
|
|
4
|
+
import { rootFacet, type RootPayload } from './root'
|
|
11
5
|
|
|
12
6
|
type CommandPayload = CommandCreators
|
|
13
7
|
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
vi,
|
|
6
|
-
} from 'vitest'
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
7
3
|
|
|
8
4
|
import { Priority } from '../types/priority'
|
|
9
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
10
5
|
|
|
11
|
-
import {
|
|
12
|
-
defineFacet,
|
|
13
|
-
Facet,
|
|
14
|
-
} from './facet'
|
|
6
|
+
import { defineFacet, Facet } from './facet'
|
|
15
7
|
import { FacetExtensionImpl } from './facet-extension'
|
|
16
|
-
import {
|
|
17
|
-
subtractFacetNode,
|
|
18
|
-
unionFacetNode,
|
|
19
|
-
} from './facet-node'
|
|
8
|
+
import { subtractFacetNode, unionFacetNode } from './facet-node'
|
|
20
9
|
import type { FacetReducer } from './facet-types'
|
|
21
10
|
import { UnionExtensionImpl } from './union-extension'
|
|
22
11
|
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
expect,
|
|
3
|
-
test,
|
|
4
|
-
} from 'vitest'
|
|
1
|
+
import { expect, test } from 'vitest'
|
|
5
2
|
|
|
6
3
|
import { Priority } from '../types/priority'
|
|
7
4
|
|
|
8
5
|
import { Facet } from './facet'
|
|
9
|
-
import {
|
|
10
|
-
FacetNode,
|
|
11
|
-
subtractFacetNode,
|
|
12
|
-
unionFacetNode,
|
|
13
|
-
} from './facet-node'
|
|
6
|
+
import { FacetNode, subtractFacetNode, unionFacetNode } from './facet-node'
|
|
14
7
|
|
|
15
8
|
const sum = (input: number[]) => input.reduce((acc, cur) => acc + cur, 0)
|
|
16
9
|
|
package/src/facets/facet-node.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
|
|
1
3
|
import { Priority } from '../types/priority'
|
|
2
|
-
import {
|
|
3
|
-
arraySubtract,
|
|
4
|
-
uniqPush,
|
|
5
|
-
} from '../utils/array'
|
|
4
|
+
import { arraySubtract, uniqPush } from '../utils/array'
|
|
6
5
|
import { assert } from '../utils/assert'
|
|
7
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
8
6
|
|
|
9
7
|
import type { Facet } from './facet'
|
|
10
|
-
import type {
|
|
11
|
-
FacetReducer,
|
|
12
|
-
Tuple5,
|
|
13
|
-
} from './facet-types'
|
|
8
|
+
import type { FacetReducer, Tuple5 } from './facet-types'
|
|
14
9
|
import type { RootOutput } from './root'
|
|
15
10
|
|
|
16
11
|
function zip5<T>(
|
package/src/facets/facet.spec.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MarkSpec,
|
|
3
|
-
NodeSpec,
|
|
4
|
-
SchemaSpec,
|
|
5
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import type { MarkSpec, NodeSpec, SchemaSpec } from '@prosekit/pm/model'
|
|
6
2
|
import OrderedMap from 'orderedmap'
|
|
7
3
|
|
|
8
|
-
import {
|
|
9
|
-
defineFacet,
|
|
10
|
-
type Facet,
|
|
11
|
-
} from './facet'
|
|
4
|
+
import { defineFacet, type Facet } from './facet'
|
|
12
5
|
import { schemaFacet } from './schema'
|
|
13
6
|
|
|
14
7
|
export const schemaSpecFacet: Facet<SchemaSpec, SchemaSpec> = defineFacet({
|
package/src/facets/schema.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Schema,
|
|
3
|
-
type SchemaSpec,
|
|
4
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import { Schema, type SchemaSpec } from '@prosekit/pm/model'
|
|
5
2
|
|
|
6
3
|
import { assert } from '../utils/assert'
|
|
7
4
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
type Facet,
|
|
11
|
-
} from './facet'
|
|
12
|
-
import {
|
|
13
|
-
rootFacet,
|
|
14
|
-
type RootPayload,
|
|
15
|
-
} from './root'
|
|
5
|
+
import { defineFacet, type Facet } from './facet'
|
|
6
|
+
import { rootFacet, type RootPayload } from './root'
|
|
16
7
|
|
|
17
8
|
export const schemaFacet: Facet<SchemaSpec, RootPayload> = defineFacet({
|
|
18
9
|
reducer: (specs) => {
|
package/src/facets/state.spec.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from 'vitest'
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
6
2
|
|
|
7
3
|
import { union } from '../editor/union'
|
|
8
4
|
import { withPriority } from '../editor/with-priority'
|
|
9
5
|
import { defineDefaultState } from '../extensions/default-state'
|
|
10
|
-
import {
|
|
11
|
-
defineTestExtension,
|
|
12
|
-
setupTestFromExtension,
|
|
13
|
-
} from '../testing'
|
|
6
|
+
import { defineTestExtension, setupTestFromExtension } from '../testing'
|
|
14
7
|
import type { NodeJSON } from '../types/model'
|
|
15
8
|
import { Priority } from '../types/priority'
|
|
16
9
|
|
package/src/facets/state.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
ProseMirrorNode,
|
|
4
|
-
Schema,
|
|
5
|
-
} from '@prosekit/pm/model'
|
|
6
|
-
import type { EditorStateConfig } from '@prosekit/pm/state'
|
|
7
|
-
import type {
|
|
8
|
-
Plugin,
|
|
9
|
-
Selection,
|
|
10
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import type { Mark, ProseMirrorNode, Schema } from '@prosekit/pm/model'
|
|
2
|
+
import type { EditorStateConfig, Plugin, Selection } from '@prosekit/pm/state'
|
|
11
3
|
|
|
12
4
|
import { assert } from '../utils/assert'
|
|
13
5
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
type Facet,
|
|
17
|
-
} from './facet'
|
|
18
|
-
import {
|
|
19
|
-
rootFacet,
|
|
20
|
-
type RootPayload,
|
|
21
|
-
} from './root'
|
|
6
|
+
import { defineFacet, type Facet } from './facet'
|
|
7
|
+
import { rootFacet, type RootPayload } from './root'
|
|
22
8
|
|
|
23
9
|
export type StatePayload = (ctx: { schema: Schema }) => EditorStateConfig
|
|
24
10
|
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Extension,
|
|
3
|
-
ExtensionTyping,
|
|
4
|
-
} from '../types/extension'
|
|
1
|
+
import type { Extension, ExtensionTyping } from '../types/extension'
|
|
5
2
|
import type { Priority } from '../types/priority'
|
|
6
3
|
import { assert } from '../utils/assert'
|
|
7
4
|
|
|
8
5
|
import { BaseExtension } from './base-extension'
|
|
9
|
-
import {
|
|
10
|
-
unionFacetNode,
|
|
11
|
-
type FacetNode,
|
|
12
|
-
} from './facet-node'
|
|
6
|
+
import { unionFacetNode, type FacetNode } from './facet-node'
|
|
13
7
|
|
|
14
8
|
export class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
|
|
15
9
|
/**
|