@prosekit/core 0.8.7 → 0.9.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-M9OimMiI.d.ts → editor-4lgGc3CY.d.ts} +20 -60
- package/dist/editor-4lgGc3CY.d.ts.map +1 -0
- package/dist/{editor-B0L9BgMi.js → editor-DGNUXn-u.js} +98 -115
- package/dist/editor-DGNUXn-u.js.map +1 -0
- package/dist/prosekit-core-test.d.ts +1 -1
- package/dist/prosekit-core-test.js +1 -1
- package/dist/prosekit-core.d.ts +81 -180
- package/dist/prosekit-core.d.ts.map +1 -1
- package/dist/prosekit-core.js +316 -403
- package/dist/prosekit-core.js.map +1 -1
- package/package.json +8 -10
- package/src/commands/select-all.ts +3 -8
- package/src/commands/select-block.spec.ts +83 -0
- package/src/commands/select-block.ts +59 -0
- package/src/commands/wrap.ts +1 -6
- package/src/editor/action.ts +1 -11
- package/src/editor/editor.ts +20 -32
- package/src/extensions/command.ts +4 -0
- package/src/extensions/default-state.spec.ts +0 -4
- package/src/extensions/default-state.ts +4 -24
- package/src/extensions/events/dom-event.ts +1 -4
- package/src/extensions/events/editor-event.ts +1 -1
- package/src/extensions/history.ts +1 -1
- package/src/extensions/keymap-base.spec.ts +98 -0
- package/src/extensions/keymap-base.ts +37 -13
- package/src/extensions/keymap.spec.ts +9 -5
- package/src/extensions/keymap.ts +13 -56
- package/src/extensions/mark-spec.ts +32 -29
- package/src/extensions/node-spec.ts +28 -19
- package/src/extensions/plugin.ts +1 -2
- package/src/facets/command.ts +8 -2
- package/src/facets/state.spec.ts +6 -6
- package/src/facets/state.ts +1 -2
- package/src/index.ts +3 -23
- package/src/types/extension-command.ts +0 -7
- package/src/types/extension.ts +0 -16
- package/src/utils/array-grouping.spec.ts +1 -11
- package/src/utils/array-grouping.ts +1 -14
- package/src/utils/array.ts +0 -4
- package/src/utils/combine-event-handlers.ts +4 -6
- package/src/utils/editor-content.ts +3 -3
- package/src/utils/output-spec.ts +11 -0
- package/src/utils/parse.ts +9 -9
- package/dist/editor-B0L9BgMi.js.map +0 -1
- package/dist/editor-M9OimMiI.d.ts.map +0 -1
- package/src/extensions/doc.ts +0 -31
- package/src/extensions/paragraph.ts +0 -61
- package/src/extensions/text.ts +0 -34
- package/src/types/base-node-view-options.ts +0 -33
- package/src/types/object-entries.ts +0 -13
- package/src/utils/collect-children.ts +0 -21
- package/src/utils/collect-nodes.ts +0 -37
- package/src/utils/deep-equals.spec.ts +0 -26
- package/src/utils/deep-equals.ts +0 -29
- package/src/utils/get-id.spec.ts +0 -14
- package/src/utils/get-id.ts +0 -13
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import OrderedMap from 'orderedmap'
|
|
2
|
-
import {
|
|
3
|
-
expect,
|
|
4
|
-
test,
|
|
5
|
-
} from 'vitest'
|
|
6
|
-
|
|
7
|
-
import { deepEquals } from './deep-equals'
|
|
8
|
-
|
|
9
|
-
test('arrays with equal values are equal', () => {
|
|
10
|
-
expect(deepEquals([1, 2], [1, 2])).toBe(true)
|
|
11
|
-
expect(deepEquals([1, 2], [2, 1])).toBe(false)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('nested objects', () => {
|
|
15
|
-
const a = { a: 1, b: { c: 3 } }
|
|
16
|
-
const b = { a: 1, b: { c: 3 } }
|
|
17
|
-
const c = { a: 1, b: { c: 4 } }
|
|
18
|
-
expect(deepEquals(a, b)).toBe(true)
|
|
19
|
-
expect(deepEquals(a, c)).toBe(false)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('ordered maps', () => {
|
|
23
|
-
const map1 = OrderedMap.from({ a: 1, b: 2 })
|
|
24
|
-
const map2 = OrderedMap.from({ a: 1, b: 2 })
|
|
25
|
-
expect(deepEquals(map1, map2)).toBe(true)
|
|
26
|
-
})
|
package/src/utils/deep-equals.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import OrderedMap from 'orderedmap'
|
|
2
|
-
|
|
3
|
-
export function deepEquals<T>(a: T, b: T): boolean {
|
|
4
|
-
if (a === b) {
|
|
5
|
-
return true
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (!a || !b) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
13
|
-
return a.length === b.length && a.every((x, i) => deepEquals(x, b[i]))
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (a instanceof OrderedMap && b instanceof OrderedMap) {
|
|
17
|
-
return a.size === b.size && deepEquals(a.toObject(), b.toObject())
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (typeof a === 'object' && typeof b === 'object') {
|
|
21
|
-
const aKeys = Object.keys(a)
|
|
22
|
-
const bKeys = Object.keys(b)
|
|
23
|
-
return (
|
|
24
|
-
aKeys.length === bKeys.length
|
|
25
|
-
&& aKeys.every((key) => deepEquals(a[key as keyof T], b[key as keyof T]))
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
return false
|
|
29
|
-
}
|
package/src/utils/get-id.spec.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
expect,
|
|
3
|
-
test,
|
|
4
|
-
} from 'vitest'
|
|
5
|
-
|
|
6
|
-
import { getId } from './get-id'
|
|
7
|
-
|
|
8
|
-
test('generates sequential ids', () => {
|
|
9
|
-
const first = getId()
|
|
10
|
-
const second = getId()
|
|
11
|
-
const firstNum = Number(first.split(':')[1])
|
|
12
|
-
const secondNum = Number(second.split(':')[1])
|
|
13
|
-
expect(secondNum).toBe((firstNum + 1) % Number.MAX_SAFE_INTEGER)
|
|
14
|
-
})
|
package/src/utils/get-id.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
let id = 0
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns a unique id in the current process that can be used in various places.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Import `getId` from `@ocavue/utils` package instead. Remove it in a future version.
|
|
9
|
-
*/
|
|
10
|
-
export function getId(): string {
|
|
11
|
-
id = (id + 1) % Number.MAX_SAFE_INTEGER
|
|
12
|
-
return `id:${id}`
|
|
13
|
-
}
|