-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
400 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x, 16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run test | ||
env: | ||
CI: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import wysiwyg from './wysiwyg'; | ||
import { expect, test } from 'vitest' | ||
|
||
test('defaultNodeRenderers', () => { | ||
|
||
const sampleJSON = { | ||
type: "doc", | ||
content: [ | ||
{ | ||
type: "heading", | ||
attrs: { level: 1 }, | ||
content: [ | ||
{ | ||
type: "text", | ||
text: "ProseMirror JSON Render Example" | ||
} | ||
] | ||
}, | ||
{ | ||
type: "paragraph", | ||
content: [ | ||
{ | ||
type: "text", | ||
text: "This is a paragraph with a line break:" | ||
}, | ||
{ | ||
type: "hardBreak" | ||
}, | ||
{ | ||
type: "text", | ||
text: "After the line break." | ||
} | ||
] | ||
} | ||
// ... additional node types | ||
] | ||
}; | ||
|
||
const html = wysiwyg(sampleJSON, { | ||
// image object with custom class | ||
image: ({ attrs }: { attrs: any }) => `<img src="${attrs.src}" alt="${attrs.alt}" title="${attrs.title}" class="my-super-duper-responsive-class" />`, | ||
// youtube video with custom width and height in order to make it responsive | ||
youtube: ({ attrs }: { attrs: any }) => `<iframe width="560" height="315" src="${attrs.src}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`, | ||
// a custom flyo based node you like to style: | ||
accordion: ({ attrs }: { attrs: any }) => `<details><summary>${attrs.title}</summary>${attrs.text}</details>`, | ||
}) | ||
|
||
expect(html).toBe('<h1>ProseMirror JSON Render Example</h1><p>This is a paragraph with a line break:<br />After the line break.</p>'); | ||
|
||
// Fügen Sie hier weitere Tests für andere Knoten- und Markierungstypen hinzu | ||
}); |
Oops, something went wrong.