Skip to content

Commit

Permalink
[add] Test page
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Apr 25, 2024
1 parent b53084f commit 8bf3c6d
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@parcel/config-default",
"transformers": {
"*.{ts,tsx}": [
"@parcel/transformer-typescript-tsc"
]
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
"web-utility": "^4.3.0"
},
"devDependencies": {
"@parcel/config-default": "~2.12.0",
"@parcel/packager-ts": "~2.12.0",
"@parcel/transformer-less": "~2.12.0",
"@parcel/transformer-typescript-tsc": "~2.12.0",
"@parcel/transformer-typescript-types": "~2.12.0",
"element-internals-polyfill": "^1.3.11",
"husky": "^9.0.11",
Expand Down Expand Up @@ -67,6 +69,8 @@
"scripts": {
"prepare": "husky",
"test": "lint-staged",
"clean": "rm -rf .parcel-cache/ dist/",
"start": "npm run clean && cd test/ && parcel index.html --open",
"pack-docs": "rm -rf docs/ && typedoc source/",
"pack-dist": "rm -rf dist/ && parcel build source/index.tsx",
"build": "npm run pack-docs && npm run pack-dist",
Expand Down
36 changes: 23 additions & 13 deletions pnpm-lock.yaml

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

41 changes: 41 additions & 0 deletions source/Editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { observable } from 'mobx';
import Quill from 'quill';
import { WebCell, attribute, component, observer } from 'web-cell';

export interface QuillCell extends WebCell {}

@component({
tagName: 'quill-cell',
mode: 'open'
})
@observer
export class QuillCell extends HTMLElement implements WebCell {
core: Quill;

@attribute
@observable
accessor theme: 'bubble' | 'snow' = 'snow';

mountedCallback() {
const { theme } = this;

this.core = new Quill(
this.shadowRoot.lastElementChild as HTMLDivElement,
{ theme }
);
}

render() {
const { theme } = this;

return (
<>
<link
rel="stylesheet"
href={`https://unpkg.com/quill@2/dist/quill.${theme}.css`}
/>
<div />
</>
);
}
}
17 changes: 17 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/font/bootstrap-icons.css"
/>
</head>
<body>
<main></main>
<script type="module" src="index.tsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions test/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { configure } from 'mobx';
import { DOMRenderer } from 'dom-renderer';

import { QuillCell } from '../source/Editor';

configure({ enforceActions: 'never' });

new DOMRenderer().render(
// @ts-ignore
<form className="container">
<legend>Quill Cell editor</legend>

<QuillCell />

<button className="btn btn-primary my-2"></button>
</form>,
document.querySelector('main')
);
5 changes: 5 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@easywebapp/quill-cell-editor-demo",
"private": true,
"source": "index.html"
}
4 changes: 4 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["**/*"]
}

0 comments on commit 8bf3c6d

Please sign in to comment.