Skip to content

Commit daa368a

Browse files
committed
Merge branch 'main' of github.com:ueberdosis/tiptap
2 parents 16eedca + b373090 commit daa368a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+507
-247
lines changed

.github/workflows/add-labels.yml

-23
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ yarn-error.log*
2323

2424
tests/cypress/videos
2525
/tests/cypress/screenshots
26+
# Ignore intellij project files
27+
.idea

demos/package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"name": "tiptap-demos",
33
"version": "0.0.0",
44
"private": true,
5-
"type": "module",
65
"scripts": {
76
"start": "vite --host",
87
"build": "yarn ts && vite build",
98
"ts": "tsc --project tsconfig.base.json --noEmit && tsc --project tsconfig.react.json --noEmit && tsc --project tsconfig.vue-2.json --noEmit && tsc --project tsconfig.vue-3.json --noEmit"
109
},
1110
"dependencies": {
12-
"d3": "^7.0.3",
11+
"d3": "^7.0.4",
12+
"fast-glob": "^3.2.7",
1313
"remixicon": "^2.5.0",
1414
"shiki": "^0.9.11",
1515
"simplify-js": "^1.2.4",
@@ -21,18 +21,17 @@
2121
"devDependencies": {
2222
"@types/uuid": "^8.3.1",
2323
"@vitejs/plugin-react-refresh": "^1.3.6",
24-
"@vitejs/plugin-vue": "^1.9.0",
25-
"autoprefixer": "^10.3.5",
26-
"globby": "^12.0.2",
24+
"@vitejs/plugin-vue": "^1.9.2",
25+
"autoprefixer": "^10.3.6",
2726
"iframe-resizer": "^4.3.2",
28-
"postcss": "^8.3.7",
27+
"postcss": "^8.3.8",
2928
"react": "^17.0.2",
3029
"react-dom": "^17.0.2",
3130
"sass": "^1.42.1",
32-
"tailwindcss": "^2.2.15",
31+
"tailwindcss": "^2.2.16",
3332
"typescript": "^4.4.3",
3433
"uuid": "^8.3.2",
35-
"vite": "^2.5.10",
34+
"vite": "^2.6.2",
3635
"vite-plugin-checker": "^0.3.4",
3736
"vue": "^3.0.5",
3837
"vue-router": "^4.0.11"

demos/postcss.config.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import tailwind from 'tailwindcss'
2-
import autoprefixer from 'autoprefixer'
3-
import tailwindConfig from './tailwind.config.js'
4-
5-
export default {
6-
plugins: [
7-
tailwind(tailwindConfig),
8-
autoprefixer,
9-
],
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
106
}

demos/tailwind.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import defaultTheme from 'tailwindcss/defaultTheme.js'
1+
const defaultTheme = require('tailwindcss/defaultTheme')
22

3-
export default {
3+
module.exports = {
44
mode: 'jit',
55
purge: [
66
'./preview/**/*.{vue,js,ts,jsx,tsx}',

demos/vite.config.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import {
66
} from 'path'
77
import { v4 as uuid } from 'uuid'
88
import fs from 'fs'
9-
import { globbySync } from 'globby'
9+
import fg from 'fast-glob'
1010
import { defineConfig } from 'vite'
1111
import vue from '@vitejs/plugin-vue'
1212
import reactRefresh from '@vitejs/plugin-react-refresh'
13-
import postcss from './postcss.config.js'
1413
// import checker from 'vite-plugin-checker'
1514

1615
const includeDependencies = fs.readFileSync('./includeDependencies.txt')
@@ -24,13 +23,9 @@ export default defineConfig({
2423
include: includeDependencies,
2524
},
2625

27-
css: {
28-
postcss,
29-
},
30-
3126
build: {
3227
rollupOptions: {
33-
input: globbySync('./**/index.html', {
28+
input: fg.sync('./**/index.html', {
3429
ignore: ['dist'],
3530
}),
3631
},
@@ -73,10 +68,10 @@ export default defineConfig({
7368
},
7469
load(id) {
7570
if (id === '@demos') {
76-
const demos = globbySync('./src/*/*', { onlyDirectories: true })
71+
const demos = fg.sync('./src/*/*', { onlyDirectories: true })
7772
.map(demoPath => {
7873
const name = demoPath.replace('./src/', '')
79-
const tabs = globbySync(`./src/${name}/*`, { onlyDirectories: true })
74+
const tabs = fg.sync(`./src/${name}/*`, { onlyDirectories: true })
8075
.map(tabPath => ({
8176
name: basename(tabPath),
8277
}))
@@ -102,7 +97,7 @@ export default defineConfig({
10297
load(id) {
10398
if (id.startsWith('source!')) {
10499
const path = id.split('!!')[0].replace('source!', '')
105-
const files = globbySync(`${path}/**/*`, {
100+
const files = fg.sync(`${path}/**/*`, {
106101
ignore: [
107102
'**/index.html',
108103
'**/*.spec.js',
@@ -167,7 +162,7 @@ export default defineConfig({
167162

168163
resolve: {
169164
alias: [
170-
...globbySync('../packages/*', { onlyDirectories: true })
165+
...fg.sync('../packages/*', { onlyDirectories: true })
171166
.map(name => name.replace('../packages/', ''))
172167
.map(name => {
173168
return { find: `@tiptap/${name}`, replacement: resolve(`../packages/${name}/src/index.ts`) }

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"@rollup/plugin-babel": "^5.3.0",
3737
"@rollup/plugin-commonjs": "^20.0.0",
3838
"@rollup/plugin-node-resolve": "^13.0.5",
39-
"@typescript-eslint/eslint-plugin": "^4.31.2",
40-
"@typescript-eslint/parser": "^4.31.2",
39+
"@typescript-eslint/eslint-plugin": "^4.32.0",
40+
"@typescript-eslint/parser": "^4.32.0",
4141
"babel-loader": "^8.2.2",
42-
"cypress": "^8.4.1",
42+
"cypress": "^8.5.0",
4343
"eslint": "^7.32.0",
4444
"eslint-config-airbnb-base": "^14.2.0",
4545
"eslint-plugin-cypress": "^2.12.1",
@@ -54,6 +54,6 @@
5454
"rollup-plugin-typescript2": "^0.30.0",
5555
"ts-loader": "^9.2.6",
5656
"typescript": "^4.4.3",
57-
"webpack": "^5.53.0"
57+
"webpack": "^5.55.1"
5858
}
5959
}

packages/core/CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.0.0-beta.116](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-30)
7+
8+
9+
### Features
10+
11+
* [#1898](https://github.com/ueberdosis/tiptap/issues/1898) Made the EventEmitter generic to improve the types of the tiptap events ([#1959](https://github.com/ueberdosis/tiptap/issues/1959)) ([54e85fd](https://github.com/ueberdosis/tiptap/commit/54e85fd28491fcf2d5a88fb5abda1f8414ada92b))
12+
13+
14+
15+
16+
17+
# [2.0.0-beta.115](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-29)
18+
19+
**Note:** Version bump only for package @tiptap/core
20+
21+
22+
23+
24+
625
# [2.0.0-beta.114](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-28)
726

827

packages/core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tiptap/core",
33
"description": "headless rich text editor",
4-
"version": "2.0.0-beta.114",
4+
"version": "2.0.0-beta.116",
55
"homepage": "https://tiptap.dev",
66
"keywords": [
77
"tiptap",
@@ -38,7 +38,7 @@
3838
"prosemirror-model": "^1.14.3",
3939
"prosemirror-schema-list": "^1.1.6",
4040
"prosemirror-state": "^1.3.4",
41-
"prosemirror-transform": "^1.3.2",
41+
"prosemirror-transform": "^1.3.3",
4242
"prosemirror-view": "^1.20.1"
4343
},
4444
"repository": {

packages/core/src/Editor.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ChainedCommands,
2525
SingleCommands,
2626
TextSerializer,
27+
EditorEvents,
2728
} from './types'
2829
import * as extensions from './extensions'
2930
import style from './style'
@@ -34,7 +35,7 @@ export interface HTMLElement {
3435
editor?: Editor
3536
}
3637

37-
export class Editor extends EventEmitter {
38+
export class Editor extends EventEmitter<EditorEvents> {
3839

3940
private commandManager!: CommandManager
4041

@@ -195,7 +196,7 @@ export class Editor extends EventEmitter {
195196
/**
196197
* Unregister a ProseMirror plugin.
197198
*
198-
* @param name The plugins name
199+
* @param nameOrPluginKey The plugins name
199200
*/
200201
public unregisterPlugin(nameOrPluginKey: string | PluginKey): void {
201202
if (this.isDestroyed) {

packages/core/src/EventEmitter.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
export default class EventEmitter {
1+
type StringKeyOf<T> = Extract<keyof T, string>
2+
type CallbackType<
3+
T extends Record<string, any>,
4+
EventName extends StringKeyOf<T>,
5+
> = T[EventName] extends any[] ? T[EventName] : [T[EventName]]
6+
type CallbackFunction<
7+
T extends Record<string, any>,
8+
EventName extends StringKeyOf<T>,
9+
> = (...props: CallbackType<T, EventName>) => any
10+
11+
export default class EventEmitter<T extends Record<string, any>> {
212

313
private callbacks: { [key: string]: Function[] } = {}
414

5-
public on(event: string, fn: Function): this {
15+
public on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this {
616
if (!this.callbacks[event]) {
717
this.callbacks[event] = []
818
}
@@ -12,7 +22,7 @@ export default class EventEmitter {
1222
return this
1323
}
1424

15-
protected emit(event: string, ...args: any): this {
25+
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this {
1626
const callbacks = this.callbacks[event]
1727

1828
if (callbacks) {
@@ -22,7 +32,7 @@ export default class EventEmitter {
2232
return this
2333
}
2434

25-
public off(event: string, fn?: Function): this {
35+
public off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this {
2636
const callbacks = this.callbacks[event]
2737

2838
if (callbacks) {

packages/core/src/types.ts

+23-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ export type MaybeReturnType<T> = T extends (...args: any) => any
3939
? ReturnType<T>
4040
: T
4141

42+
export interface EditorEvents {
43+
beforeCreate: { editor: Editor },
44+
create: { editor: Editor },
45+
update: { editor: Editor, transaction: Transaction },
46+
selectionUpdate: { editor: Editor, transaction: Transaction },
47+
transaction: { editor: Editor, transaction: Transaction },
48+
focus: { editor: Editor, event: FocusEvent, transaction: Transaction },
49+
blur: { editor: Editor, event: FocusEvent, transaction: Transaction },
50+
destroy: void,
51+
}
52+
4253
export interface EditorOptions {
4354
element: Element,
4455
content: Content,
@@ -51,14 +62,14 @@ export interface EditorOptions {
5162
enableInputRules: boolean,
5263
enablePasteRules: boolean,
5364
enableCoreExtensions: boolean,
54-
onBeforeCreate: (props: { editor: Editor }) => void,
55-
onCreate: (props: { editor: Editor }) => void,
56-
onUpdate: (props: { editor: Editor, transaction: Transaction }) => void,
57-
onSelectionUpdate: (props: { editor: Editor, transaction: Transaction }) => void,
58-
onTransaction: (props: { editor: Editor, transaction: Transaction }) => void,
59-
onFocus: (props: { editor: Editor, event: FocusEvent, transaction: Transaction }) => void,
60-
onBlur: (props: { editor: Editor, event: FocusEvent, transaction: Transaction }) => void,
61-
onDestroy: () => void,
65+
onBeforeCreate: (props: EditorEvents['beforeCreate']) => void,
66+
onCreate: (props: EditorEvents['create']) => void,
67+
onUpdate: (props: EditorEvents['update']) => void,
68+
onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void,
69+
onTransaction: (props: EditorEvents['transaction']) => void,
70+
onFocus: (props: EditorEvents['focus']) => void,
71+
onBlur: (props: EditorEvents['blur']) => void,
72+
onDestroy: (props: EditorEvents['destroy']) => void,
6273
}
6374

6475
export type HTMLContent = string
@@ -122,18 +133,18 @@ export type GlobalAttributes = {
122133

123134
export type PickValue<T, K extends keyof T> = T[K]
124135

125-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I)=>void)
136+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void)
126137
? I
127138
: never
128139

129140
export type Diff<T extends keyof any, U extends keyof any> =
130141
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
131142

132-
export type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
143+
export type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U
133144

134-
export type ValuesOf<T> = T[keyof T];
145+
export type ValuesOf<T> = T[keyof T]
135146

136-
export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
147+
export type KeysWithTypeOf<T, Type> = ({ [P in keyof T]: T[P] extends Type ? P : never })[keyof T]
137148

138149
export type NodeViewProps = {
139150
editor: Editor,

packages/extension-bubble-menu/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.0.0-beta.38](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-29)
7+
8+
**Note:** Version bump only for package @tiptap/extension-bubble-menu
9+
10+
11+
12+
13+
614
# [2.0.0-beta.37](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-28)
715

816
**Note:** Version bump only for package @tiptap/extension-bubble-menu

packages/extension-bubble-menu/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tiptap/extension-bubble-menu",
33
"description": "bubble-menu extension for tiptap",
4-
"version": "2.0.0-beta.37",
4+
"version": "2.0.0-beta.38",
55
"homepage": "https://tiptap.dev",
66
"keywords": [
77
"tiptap",

packages/extension-code-block-lowlight/CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.0.0-beta.40](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-30)
7+
8+
9+
### Bug Fixes
10+
11+
* compatibility with lowlight v2 ([#1939](https://github.com/ueberdosis/tiptap/issues/1939)) ([f79347e](https://github.com/ueberdosis/tiptap/commit/f79347e128be11860ee54109d8d333b436426b45))
12+
13+
14+
15+
16+
617
# [2.0.0-beta.39](https://github.com/ueberdosis/tiptap/compare/@tiptap/[email protected]...@tiptap/[email protected]) (2021-09-21)
718

819

0 commit comments

Comments
 (0)