Skip to content

Commit

Permalink
feat(pm): new prosemirror package for dependency resolving
Browse files Browse the repository at this point in the history
* chore:(core): migrate to tsup

* chore: migrate blockquote and bold to tsup

* chore: migrated bubble-menu and bullet-list to tsup

* chore: migrated more packages to tsup

* chore: migrate code and character extensions to tsup

* chore: update package.json to simplify build for all packages

* chore: move all packages to tsup as a build process

* chore: change ci build task

* feat(pm): add prosemirror meta package

* rfix: resolve issues with build paths & export mappings

* docs: update documentation to include notes for @tiptap/pm

* chore(pm): update tsconfig

* chore(packages): update packages

* fix(pm): add package export infos & fix dependencies

* chore(general): start moving to pm package as deps

* chore: move to tiptap pm package internally

* fix(demos): fix demos working with new pm package

* fix(tables): fix tables package

* fix(tables): fix tables package

* chore(demos): pinned typescript version

* chore: remove unnecessary tsconfig

* chore: fix netlify build

* fix(demos): fix package resolving for pm packages

* fix(tests): fix package resolving for pm packages

* fix(tests): fix package resolving for pm packages

* chore(tests): fix tests not running correctly after pm package

* chore(pm): add files to files array

* chore: update build workflow

* chore(tests): increase timeout time back to 12s

* chore(docs): update docs

* chore(docs): update installation guides & pm information to docs

* chore(docs): add link to prosemirror docs

* fix(vue-3): add missing build step

* chore(docs): comment out cdn link

* chore(docs): remove semicolons from docs

* chore(docs): remove unnecessary installation note

* chore(docs): remove unnecessary installation note
  • Loading branch information
bdbch committed Feb 2, 2023
1 parent 0ecb5a8 commit f387ad3
Show file tree
Hide file tree
Showing 271 changed files with 3,933 additions and 3,154 deletions.
243 changes: 124 additions & 119 deletions .github/workflows/build.yml
Expand Up @@ -23,50 +23,49 @@ jobs:
node-version: [16]

steps:

- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Load cached dependencies
uses: actions/cache@v3.0.11
id: cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
id: install-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

# - name: Fix code style linting errors
# id: lint-fix
# run: npm run lint:fix
# continue-on-error: true
#
# - name: Commit fixed linting errors
# id: commit
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: "ci: fix code style linting errors"

- name: Lint code
id: lint
run: npm run lint

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'
- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Load cached dependencies
uses: actions/cache@v3.0.11
id: cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
id: install-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

# - name: Fix code style linting errors
# id: lint-fix
# run: npm run lint:fix
# continue-on-error: true
#
# - name: Commit fixed linting errors
# id: commit
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: "ci: fix code style linting errors"

- name: Lint code
id: lint
run: npm run lint

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'

test:
runs-on: ubuntu-latest
Expand All @@ -79,48 +78,55 @@ jobs:
node-version: [16]

steps:

- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Run tests with Cypress
id: cypress
uses: cypress-io/github-action@v4.2.0
with:
cache-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
start: npm run start
wait-on: 'http://localhost:3000'
project: ./tests
browser: chrome
quiet: true

- name: Export screenshots (on failure only)
uses: actions/upload-artifact@v3.1.0
if: failure()
with:
name: cypress-screenshots
path: tests/cypress/screenshots
retention-days: 7

- name: Export screen recordings (on failure only)
uses: actions/upload-artifact@v3.1.0
if: failure()
with:
name: cypress-videos
path: tests/cypress/videos
retention-days: 7

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'
- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
id: install-dependencies
run: npm install

- name: Try to build the packages
id: build-packages
run: npm run build:pm

- name: Run tests with Cypress
id: cypress
uses: cypress-io/github-action@v4.2.0
with:
cache-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
start: npm run start
wait-on: 'http://localhost:3000'
project: ./tests
browser: chrome
quiet: true

- name: Export screenshots (on failure only)
uses: actions/upload-artifact@v3.1.0
if: failure()
with:
name: cypress-screenshots
path: tests/cypress/screenshots
retention-days: 7

- name: Export screen recordings (on failure only)
uses: actions/upload-artifact@v3.1.0
if: failure()
with:
name: cypress-videos
path: tests/cypress/videos
retention-days: 7

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'

build:
runs-on: ubuntu-latest
Expand All @@ -135,36 +141,35 @@ jobs:
node-version: [16]

steps:

- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Load cached dependencies
uses: actions/cache@v3.0.11
id: cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
id: install-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

- name: Try to build the packages
id: build-packages
run: npm run build:ci

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'
- uses: actions/checkout@v3.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}

- name: Load cached dependencies
uses: actions/cache@v3.0.11
id: cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
id: install-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

- name: Try to build the packages
id: build-packages
run: npm run build:ci

- name: Send Slack notifications
uses: act10ns/slack@v1
if: failure()
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#tiptap-notifications'
2 changes: 1 addition & 1 deletion demos/includeDependencies.txt
Expand Up @@ -10,7 +10,7 @@ prosemirror-keymap
prosemirror-model
prosemirror-schema-list
prosemirror-state
@tiptap/prosemirror-tables
prosemirror-tables
prosemirror-transform
prosemirror-view
react
Expand Down
2 changes: 1 addition & 1 deletion demos/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demos/package.json
Expand Up @@ -34,7 +34,7 @@
"sass": "^1.49.7",
"svelte": "^3.49.0",
"tailwindcss": "^2.2.19",
"typescript": "^4.5.5",
"typescript": "4.7.4",
"uuid": "^8.3.2",
"vite": "^2.9.13",
"vite-plugin-checker": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion demos/src/Examples/Savvy/React/ColorHighlighter.ts
@@ -1,5 +1,5 @@
import { Extension } from '@tiptap/core'
import { Plugin } from 'prosemirror-state'
import { Plugin } from '@tiptap/pm/state'

import findColors from './findColors'

Expand Down
4 changes: 2 additions & 2 deletions demos/src/Examples/Savvy/React/findColors.ts
@@ -1,5 +1,5 @@
import { Node } from 'prosemirror-model'
import { Decoration, DecorationSet } from 'prosemirror-view'
import { Node } from '@tiptap/pm/model'
import { Decoration, DecorationSet } from '@tiptap/pm/view'

export default function (doc: Node): DecorationSet {
const hexColor = /(#[0-9a-f]{3,6})\b/gi
Expand Down
6 changes: 2 additions & 4 deletions demos/src/Examples/Savvy/Vue/ColorHighlighter.ts
@@ -1,5 +1,5 @@
import { Extension } from '@tiptap/core'
import { Plugin } from 'prosemirror-state'
import { Plugin } from '@tiptap/pm/state'

import findColors from './findColors'

Expand All @@ -14,9 +14,7 @@ export const ColorHighlighter = Extension.create({
return findColors(doc)
},
apply(transaction, oldState) {
return transaction.docChanged
? findColors(transaction.doc)
: oldState
return transaction.docChanged ? findColors(transaction.doc) : oldState
},
},
props: {
Expand Down
30 changes: 14 additions & 16 deletions demos/src/Examples/Savvy/Vue/findColors.ts
@@ -1,29 +1,27 @@
import { Node } from 'prosemirror-model'
import { Decoration, DecorationSet } from 'prosemirror-view'
import { Node } from '@tiptap/pm/model'
import { Decoration, DecorationSet } from '@tiptap/pm/view'

export default function (doc: Node): DecorationSet {
const hexColor = /(#[0-9a-f]{3,6})\b/ig
const hexColor = /(#[0-9a-f]{3,6})\b/gi
const decorations: Decoration[] = []

doc.descendants((node, position) => {
if (!node.text) {
return
}

Array
.from(node.text.matchAll(hexColor))
.forEach(match => {
const color = match[0]
const index = match.index || 0
const from = position + index
const to = from + color.length
const decoration = Decoration.inline(from, to, {
class: 'color',
style: `--color: ${color}`,
})

decorations.push(decoration)
Array.from(node.text.matchAll(hexColor)).forEach(match => {
const color = match[0]
const index = match.index || 0
const from = position + index
const to = from + color.length
const decoration = Decoration.inline(from, to, {
class: 'color',
style: `--color: ${color}`,
})

decorations.push(decoration)
})
})

return DecorationSet.create(doc, decorations)
Expand Down
@@ -1,4 +1,4 @@
import { Plugin, PluginKey } from 'prosemirror-state'
import { Plugin, PluginKey } from '@tiptap/pm/state'
import * as Y from 'yjs'

import { AnnotationState } from './AnnotationState'
Expand All @@ -8,10 +8,10 @@ export const AnnotationPluginKey = new PluginKey('annotation')
export interface AnnotationPluginOptions {
HTMLAttributes: {
[key: string]: any
},
onUpdate: (items: [any?]) => {},
map: Y.Map<any>,
instance: string,
}
onUpdate: (items: [any?]) => {}
map: Y.Map<any>
instance: string
}

export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin({
Expand Down Expand Up @@ -39,9 +39,7 @@ export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin
return decorations
}

const annotations = this
.getState(state)
.annotationsAt(selection.from)
const annotations = this.getState(state).annotationsAt(selection.from)

options.onUpdate(annotations)

Expand Down

0 comments on commit f387ad3

Please sign in to comment.