quill-table-up 0.0.1
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/table-creator.css +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 zzxming
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# quill-table-up
|
|
2
|
+
|
|
3
|
+
Enhancement of quill table module
|
|
4
|
+
|
|
5
|
+
[demo](https://zzxming.github.io/quill-table-up/)
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
Quill2.0 supports table related APIs, but unfortunately it did not complete UI operations, so this module is available to solve this problem.
|
|
10
|
+
|
|
11
|
+
This module is only an ui extension of the basic table module, without adding any new APIs.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install quill-table-up
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import Quill from 'quill';
|
|
21
|
+
import TableUp from 'quill-table-up';
|
|
22
|
+
import 'quill-table-up/index.css';
|
|
23
|
+
// import 'quill-table-up/table-creator.css' // If using the default customSelect option. You need to import this css
|
|
24
|
+
|
|
25
|
+
Quill.register({ 'modules/tableUp': TableUp }, true);
|
|
26
|
+
|
|
27
|
+
const quill = new Quill('#editor', {
|
|
28
|
+
// ...
|
|
29
|
+
modules: {
|
|
30
|
+
// ...
|
|
31
|
+
toolbar: [
|
|
32
|
+
// ...
|
|
33
|
+
[{ table: [] }] // use picker to enable the customSelect option
|
|
34
|
+
],
|
|
35
|
+
tableUp: {},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Options
|
|
42
|
+
|
|
43
|
+
| attribute | description | type |
|
|
44
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------- |
|
|
45
|
+
| customSelect | Custom table size selector. You can use the argument to insert any size table. It’s only enable when table is a `picker` | `(tableModule: TableUp) => HTMLElement` |
|
|
46
|
+
| texts | The text used in the module | `TextMap` |
|
|
47
|
+
| isCustom | Use input to input the table size | `boolean` |
|
|
48
|
+
| selection | The options for table select module | `TableSelectionOptions` |
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
interface TextMap {
|
|
52
|
+
customBtnText?: string;
|
|
53
|
+
confirmText?: string; // input confirm button text
|
|
54
|
+
cancelText?: string; // input cancel button text
|
|
55
|
+
rowText?: string; // input row label text
|
|
56
|
+
colText?: string; // input column label text
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface ToolOption {
|
|
60
|
+
name: string; // tool name
|
|
61
|
+
icon: string; // icon string
|
|
62
|
+
tip?: string; // tool tip text
|
|
63
|
+
handle: (tableModule: TableUp) => void;
|
|
64
|
+
};
|
|
65
|
+
interface ToolOptionBreak {
|
|
66
|
+
name: 'break'; // when name is break, tool will insert a separator
|
|
67
|
+
}
|
|
68
|
+
type Tool = ToolOption | ToolOptionBreak;
|
|
69
|
+
interface TableSelectionOptions {
|
|
70
|
+
selectColor: string; // select border color
|
|
71
|
+
tools: Tool[]; // api button
|
|
72
|
+
}
|
|
73
|
+
```
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ql-snow .ql-table.ql-picker{width:28px}.ql-snow .ql-table.ql-picker .ql-picker-label{padding:2px 4px}.ql-snow .ql-table.ql-picker .ql-picker-label svg{position:static;margin-top:0}.ql-snow .ql-table-selection{display:none;position:absolute;z-index:10;border:1px solid;pointer-events:none}.ql-snow .ql-table-selection-tool{z-index:10;display:none;align-items:center;justify-content:center;position:absolute;padding:4px;border-radius:6px;box-shadow:0 0 8px rgba(0,0,0,.5);background-color:#fff;font-size:20px}.ql-snow .ql-table-selection-item{display:inline-flex;align-items:center;justify-content:center;padding:4px;border-radius:4px}.ql-snow .ql-table-selection-item.break{align-self:stretch;padding:0;margin:2px 4px;cursor:default;border-left:1px solid #a3a3a3;border-right:1px solid #a3a3a3}.ql-snow .ql-table-selection-item.icon{flex-shrink:0;cursor:pointer}.ql-snow .ql-table-selection-item.icon:hover{background-color:#eee}.select-box{--select-box-color-border:#e5e7eb;--select-box-border:0.0625rem solid var(--select-box-color-border);--select-box-color-active:#0ea5e9;--select-box-bg-active:#e0f2fe;--select-box-bg-hover:#f5f5f5}.select-box__block{display:flex;width:10rem;flex-wrap:wrap;align-items:center;justify-content:center}.select-box__item{margin:.125rem;height:1rem;width:1rem;border:var(--select-box-border)}.select-box__item.active{border-color:var(--select-box-color-active);background-color:var(--select-box-bg-active)}.select-box__custom{padding:.5rem;color:#000;font-size:1rem;text-align:center;cursor:pointer}.select-box__custom:hover{background-color:var(--select-box-bg-hover)}.tool-tip{position:relative;display:flex}.tool-tip__text{position:absolute;left:50%;top:100%;transform:translate(-50%,.375rem);z-index:20;padding:.25rem .5rem;border-radius:.25rem;background-color:rgba(0,0,0,.8);font-size:.75rem;text-align:center;white-space:nowrap;color:#fff;transition:opacity .15s linear}.tool-tip__text::before{position:absolute;top:-1rem;left:50%;z-index:30;transform:translateX(-50%);content:'';border:.5rem solid transparent;border-bottom-color:rgba(0,0,0,.8)}.tool-tip__text.hidden{opacity:0}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Quill from 'quill';
|
|
2
|
+
|
|
3
|
+
type AnyClass = new (...arg: any[]) => any;
|
|
4
|
+
interface ToolOption {
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
tip?: string;
|
|
8
|
+
handle: (tableModule: TableUp) => void;
|
|
9
|
+
}
|
|
10
|
+
interface ToolOptionBreak {
|
|
11
|
+
name: 'break';
|
|
12
|
+
}
|
|
13
|
+
type Tool = ToolOption | ToolOptionBreak;
|
|
14
|
+
interface TableSelectionOptions {
|
|
15
|
+
selectColor: string;
|
|
16
|
+
tools: Tool[];
|
|
17
|
+
}
|
|
18
|
+
interface TableUpOptions {
|
|
19
|
+
customSelect?: (this: TableUp) => HTMLElement;
|
|
20
|
+
isCustom?: boolean;
|
|
21
|
+
texts?: {
|
|
22
|
+
customBtnText?: string;
|
|
23
|
+
confirmText?: string;
|
|
24
|
+
cancelText?: string;
|
|
25
|
+
rowText?: string;
|
|
26
|
+
colText?: string;
|
|
27
|
+
};
|
|
28
|
+
selection?: TableSelectionOptions;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare const TableModule: AnyClass;
|
|
32
|
+
declare class TableUp extends TableModule {
|
|
33
|
+
constructor(quill: Quill, options: TableUpOptions);
|
|
34
|
+
handleInViewport: () => void;
|
|
35
|
+
resolveOptions: (options: Record<string, any>) => {
|
|
36
|
+
isCustom: boolean;
|
|
37
|
+
texts: {
|
|
38
|
+
customBtn: string;
|
|
39
|
+
confirmText: string;
|
|
40
|
+
cancelText: string;
|
|
41
|
+
rowText: string;
|
|
42
|
+
colText: string;
|
|
43
|
+
} & Record<string, string>;
|
|
44
|
+
} & Record<string, any>;
|
|
45
|
+
resolveTexts: (options: Record<string, string>) => {
|
|
46
|
+
customBtn: string;
|
|
47
|
+
confirmText: string;
|
|
48
|
+
cancelText: string;
|
|
49
|
+
rowText: string;
|
|
50
|
+
colText: string;
|
|
51
|
+
} & Record<string, string>;
|
|
52
|
+
buildCustomSelect: (customSelect: HTMLElement) => Promise<void>;
|
|
53
|
+
createSelect: () => HTMLDivElement;
|
|
54
|
+
insertTable: (rows: number, columns: number) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { TableUp as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"quill";const t=(e,t)=>{t.type||(t.type="text"),t.value||(t.value="");const s=document.createElement("div");if(s.classList.add("input__item"),e){const t=document.createElement("span");t.classList.add("input__label"),t.textContent=e,s.appendChild(t)}const i=document.createElement("div");i.classList.add("input__input");const l=document.createElement("input");for(const e in t)l.setAttribute(e,t[e]);(t.max||t.min)&&l.addEventListener("blur",(()=>{t.max&&t.max<=Number(l.value)&&(l.value=String(t.max)),t.min&&t.min>=Number(l.value)&&(l.value=String(t.min))})),i.appendChild(l),s.appendChild(i),l.addEventListener("focus",(()=>{i.classList.add("focus")})),l.addEventListener("blur",(()=>{i.classList.remove("focus")}));return{item:s,input:l,errorTip:e=>{let t;i.classList.contains("error")?t=i.querySelector(".input__error-tip"):(t=document.createElement("span"),t.classList.add("input__error-tip"),i.appendChild(t)),t.textContent=e,i.classList.add("error");return{removeError:()=>{i.classList.remove("error"),t.remove()}}}}};let s=8e3;const i=async(e={})=>{const i=document.createElement("div");i.classList.add("table-creator");const l=document.createElement("div");l.classList.add("table-creator__input");const{item:o,input:n,errorTip:a}=t(e.rowText||"行数",{type:"number",value:String(e.row||""),max:99}),{item:c,input:r,errorTip:d}=t(e.rowText||"列数",{type:"number",value:String(e.col||""),max:99});l.appendChild(o),l.appendChild(c),i.appendChild(l);const h=document.createElement("div");h.classList.add("table-creator__control");const m=document.createElement("button");m.classList.add("table-creator__btn","confirm"),m.textContent=e.confirmText||"Confirm";const u=document.createElement("button");return u.classList.add("table-creator__btn","cancel"),u.textContent=e.cancelText||"Cancel",h.appendChild(m),h.appendChild(u),i.appendChild(h),new Promise(((e,t)=>{const{close:l}=(({child:e,target:t=document.body,beforeClose:i=()=>{}}={})=>{const l=t,o=document.createElement("div");o.classList.add("dialog"),o.style.zIndex=String(s);const n=document.createElement("div");if(n.classList.add("dialog__overlay"),o.appendChild(n),e){const t=document.createElement("div");t.classList.add("dialog__content"),t.appendChild(e),n.appendChild(t),t.addEventListener("click",(e=>{e.stopPropagation()}))}const a=getComputedStyle(l).overflow;l.style.overflow="hidden",l.appendChild(o);const c=()=>{i(),o.remove(),l.style.overflow=a};return o.addEventListener("click",c),s+=1,{dialog:o,close:c}})({child:i,beforeClose:t});m.addEventListener("click",(async()=>{const t=Number(n.value),s=Number(r.value);return Number.isNaN(t)||t<=0?a("Invalid number"):Number.isNaN(s)||s<=0?d("Invalid number"):(e({row:t,col:s}),void l())})),u.addEventListener("click",(()=>{l()}))}))},l=(e,t={})=>{const{msg:s="",delay:i=0}=t,l=document.createElement("div");if(l.classList.add("tool-tip"),l.appendChild(e),s){const e=document.createElement("div");e.classList.add("tool-tip__text"),e.classList.add("hidden"),e.textContent=s,l.appendChild(e);let t=null;l.addEventListener("mouseenter",(()=>{t&&clearTimeout(t),t=setTimeout((()=>{e.classList.remove("hidden")}),i)})),l.addEventListener("mouseleave",(()=>{t&&clearTimeout(t),t=setTimeout((()=>{e.classList.add("hidden"),t=null}),i)}))}return l},o=e=>"function"==typeof e;const n=e.import("formats/table"),a=[{name:"InsertTop",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm17.94 4.5h-2v4h-2v-4h-2l3-3z"/></svg>',tip:"向上插入一行",handle:e=>{e.insertRow(0)}},{name:"InsertRight",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm15.44 8v-2h-4v-2h4v-2l3 3z"/></svg>',tip:"向右插入一列",handle:e=>{e.insertColumn(1)}},{name:"InsertBottom",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm11.94 5.5h2v-4h2v4h2l-3 3z"/></svg>',tip:"向下插入一行",handle:e=>{e.insertRow(1)}},{name:"InsertLeft",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm14.44 2v2h4v2h-4v2l-3-3z"/></svg>',tip:"向左插入一列",handle:e=>{e.insertColumn(0)}},{name:"break"},{name:"DeleteRow",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41zM22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2zM4 9h4V6H4zm6 0h4V6h-4zm6 0h4V6h-4z"/></svg>',tip:"删除当前行",handle:e=>{e.deleteRow()}},{name:"DeleteColumn",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4zm0 6v4h7v-4zM4 4v4h7V4zm13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59z"/></svg>',tip:"删除当前列",handle:e=>{e.deleteColumn()}},{name:"DeleteTable",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="m15.46 15.88l1.42-1.42L19 16.59l2.12-2.13l1.42 1.42L20.41 18l2.13 2.12l-1.42 1.42L19 19.41l-2.12 2.13l-1.42-1.42L17.59 18zM4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4z"/></svg>',tip:"删除当前表格",handle:e=>{e.deleteTable()}}];class c{tableModule;quill;options;tableBlot=null;selectTd=null;cellSelect;boundary=null;selectTool;constructor(t,s,i={}){this.tableModule=t,this.quill=s,this.options=this.resolveOptions(i),this.cellSelect=this.quill.addContainer("ql-table-selection"),this.selectTool=this.buildTools(),this.quill.root.addEventListener("mousedown",this.destory),this.quill.root.addEventListener("scroll",this.destory),this.quill.on(e.events.EDITOR_CHANGE,((t,s,i,l)=>{if(t===e.events.SELECTION_CHANGE&&s){const[e]=this.quill.scroll.descendant(n,s.index);if(!e)return;this.selectTd=e,this.updateSelectBox()}else this.destory()}))}resolveOptions=e=>Object.assign({selectColor:"#0589f3",tools:a},e);buildTools=()=>{const e=this.quill.addContainer("ql-table-selection-tool");for(const t of this.options.tools){const{name:s,icon:i,handle:n,tip:a=""}=t;let c=document.createElement("span");c.classList.add("ql-table-selection-item"),"break"===s?c.classList.add("break"):(c.classList.add("icon"),c.innerHTML=i,o(n)&&c.addEventListener("click",(()=>{this.quill.focus(),n(this.tableModule)})),a&&(c=l(c,{msg:a,delay:150}))),e.appendChild(c)}return e};remove=()=>{Object.assign(this.cellSelect.style,{display:"none"}),Object.assign(this.selectTool.style,{display:"none"}),this.selectTd=null};destory=()=>{this.remove(),this.tableBlot=null};updateSelectBox=()=>{this.selectTd&&(this.boundary=this.getRelativeRect(this.selectTd.domNode.getBoundingClientRect(),this.quill.container.getBoundingClientRect()),Object.assign(this.cellSelect.style,{"border-color":this.options.selectColor,display:"block",left:this.boundary.x-1+"px",top:this.boundary.y-1+"px",width:`${this.boundary.width+1}px`,height:`${this.boundary.height+1}px`}),Object.assign(this.selectTool.style,{display:"flex",left:this.boundary.x+this.boundary.width/2-1+"px",top:this.boundary.y-1+"px",transform:"translate(-50%, 100%)"}))};getRelativeRect=(e,t)=>({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height})}const r=e.import("ui/icons"),d=e.import("modules/table");class h extends d{constructor(e,t){super(e,t),this.options=this.resolveOptions(t||{});const s=this.quill.getModule("toolbar"),[,i]=(s.controls||[]).find((([e])=>"table"===e))||[];if(i&&"select"===i.tagName.toLocaleLowerCase()){if(this.picker=this.quill.theme.pickers.find((e=>e.select===i)),!this.picker)return;this.picker.label.innerHTML=r.table,this.buildCustomSelect(this.options.customSelect),this.picker.label.addEventListener("mousedown",this.handleInViewport)}this.selection=new c(this,this.quill,this.options.selection)}handleInViewport=()=>{if(this.selector.getBoundingClientRect().right>=window.innerWidth){const e=this.picker.label.getBoundingClientRect();this.picker.options.style.transform=`translateX(calc(-100% + ${e.width}px))`}else this.picker.options.style.transform=void 0};resolveOptions=e=>Object.assign({isCustom:!0,texts:this.resolveTexts(e.texts||{})},e);resolveTexts=e=>Object.assign({customBtn:"自定义行列数",confirmText:"确认",cancelText:"取消",rowText:"行数",colText:"列数"},e);buildCustomSelect=async e=>{const t=document.createElement("div");t.classList.add("ql-custom-select"),this.selector=e&&o(e)?await e(this):this.createSelect(),t.appendChild(this.selector),this.picker.options.appendChild(t)};createSelect=()=>((e={})=>{const t=document.createElement("div");t.classList.add("select-box");const s=document.createElement("div");s.classList.add("select-box__block");for(let t=0;t<(e.row||8);t++)for(let i=0;i<(e.col||8);i++){const e=document.createElement("div");e.classList.add("select-box__item"),e.dataset.row=String(t+1),e.dataset.col=String(i+1),s.appendChild(e)}const l=()=>{const{row:e,col:i}=t.dataset;for(const e of Array.from(s.querySelectorAll(".active")))e.classList.remove("active");if(!e||!i)return;const l=Array.from(s.children);for(let t=0;t<l.length;t++){const{row:s,col:o}=l[t].dataset;if(s>e&&o>i)return;s<=e&&o<=i?l[t].classList.add("active"):l[t].classList.remove("active")}};if(s.addEventListener("mousemove",(e=>{if(!e.target)return;const{row:s,col:i}=e.target.dataset;s&&i&&(t.dataset.row=s,t.dataset.col=i,l())})),s.addEventListener("mouseleave",(()=>{t.removeAttribute("data-row"),t.removeAttribute("data-col"),l()})),s.addEventListener("click",(()=>{const{row:s,col:i}=t.dataset;s&&i&&e.onSelect&&e.onSelect(Number(s),Number(i))})),t.appendChild(s),e.isCustom){const s=document.createElement("div");s.classList.add("select-box__custom"),s.textContent=e.customText||"自定义行列数",s.addEventListener("click",(async()=>{const t=await i({confirmText:e.confirmText,cancelText:e.cancelText,rowText:e.rowText,colText:e.colText});t&&e.onSelect&&e.onSelect(t.row,t.col)})),t.appendChild(s)}return t})({onSelect:(e,t)=>{this.insertTable(e,t),this.picker.close()},isCustom:this.options.isCustom,customText:this.options.texts.customBtn});insertTable=(e,t)=>{this.quill.focus(),super.insertTable(e,t)}}export{h as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/components.ts","../src/utils/utils.ts","../src/modules/selection.ts","../src/index.ts"],"sourcesContent":[";\nexport const createInputItem = (label, options) => {\n options.type || (options.type = 'text');\n options.value || (options.value = '');\n const inputItem = document.createElement('div');\n inputItem.classList.add('input__item');\n if (label) {\n const inputLabel = document.createElement('span');\n inputLabel.classList.add('input__label');\n inputLabel.textContent = label;\n inputItem.appendChild(inputLabel);\n }\n const inputInput = document.createElement('div');\n inputInput.classList.add('input__input');\n const input = document.createElement('input');\n for (const key in options) {\n input.setAttribute(key, options[key]);\n }\n if (options.max || options.min) {\n input.addEventListener('blur', () => {\n if (options.max && options.max <= Number(input.value)) {\n input.value = String(options.max);\n }\n if (options.min && options.min >= Number(input.value)) {\n input.value = String(options.min);\n }\n });\n }\n inputInput.appendChild(input);\n inputItem.appendChild(inputInput);\n input.addEventListener('focus', () => {\n inputInput.classList.add('focus');\n });\n input.addEventListener('blur', () => {\n inputInput.classList.remove('focus');\n });\n const errorTip = (msg) => {\n let errorTip;\n if (inputInput.classList.contains('error')) {\n errorTip = inputInput.querySelector('.input__error-tip');\n }\n else {\n errorTip = document.createElement('span');\n errorTip.classList.add('input__error-tip');\n inputInput.appendChild(errorTip);\n }\n errorTip.textContent = msg;\n inputInput.classList.add('error');\n const removeError = () => {\n inputInput.classList.remove('error');\n errorTip.remove();\n };\n return { removeError };\n };\n return { item: inputItem, input, errorTip };\n};\nlet zindex = 8000;\nexport const createDialog = ({ child, target = document.body, beforeClose = () => { } } = {}) => {\n const appendTo = target;\n const dialog = document.createElement('div');\n dialog.classList.add('dialog');\n dialog.style.zIndex = String(zindex);\n const overlay = document.createElement('div');\n overlay.classList.add('dialog__overlay');\n dialog.appendChild(overlay);\n if (child) {\n const content = document.createElement('div');\n content.classList.add('dialog__content');\n content.appendChild(child);\n overlay.appendChild(content);\n content.addEventListener('click', (e) => {\n e.stopPropagation();\n });\n }\n const originOverflow = getComputedStyle(appendTo).overflow;\n appendTo.style.overflow = 'hidden';\n appendTo.appendChild(dialog);\n const close = () => {\n beforeClose();\n dialog.remove();\n appendTo.style.overflow = originOverflow;\n };\n dialog.addEventListener('click', close);\n zindex += 1;\n return { dialog, close };\n};\nexport const showTableCreator = async (options = {}) => {\n const box = document.createElement('div');\n box.classList.add('table-creator');\n const inputContent = document.createElement('div');\n inputContent.classList.add('table-creator__input');\n const { item: rowItem, input: rowInput, errorTip: rowErrorTip, } = createInputItem(options.rowText || '行数', { type: 'number', value: String(options.row || ''), max: 99 });\n const { item: colItem, input: colInput, errorTip: colErrorTip, } = createInputItem(options.rowText || '列数', { type: 'number', value: String(options.col || ''), max: 99 });\n inputContent.appendChild(rowItem);\n inputContent.appendChild(colItem);\n box.appendChild(inputContent);\n const control = document.createElement('div');\n control.classList.add('table-creator__control');\n const confirmBtn = document.createElement('button');\n confirmBtn.classList.add('table-creator__btn', 'confirm');\n confirmBtn.textContent = options.confirmText || 'Confirm';\n const cancelBtn = document.createElement('button');\n cancelBtn.classList.add('table-creator__btn', 'cancel');\n cancelBtn.textContent = options.cancelText || 'Cancel';\n control.appendChild(confirmBtn);\n control.appendChild(cancelBtn);\n box.appendChild(control);\n return new Promise((resolve, reject) => {\n const { close } = createDialog({ child: box, beforeClose: reject });\n confirmBtn.addEventListener('click', async () => {\n const row = Number(rowInput.value);\n const col = Number(colInput.value);\n if (Number.isNaN(row) || row <= 0) {\n return rowErrorTip('Invalid number');\n }\n if (Number.isNaN(col) || col <= 0) {\n return colErrorTip('Invalid number');\n }\n resolve({ row, col });\n close();\n });\n cancelBtn.addEventListener('click', () => {\n close();\n });\n });\n};\nexport const createSelectBox = (options = {}) => {\n const selectDom = document.createElement('div');\n selectDom.classList.add('select-box');\n const selectBlock = document.createElement('div');\n selectBlock.classList.add('select-box__block');\n for (let r = 0; r < (options.row || 8); r++) {\n for (let c = 0; c < (options.col || 8); c++) {\n const selectItem = document.createElement('div');\n selectItem.classList.add('select-box__item');\n selectItem.dataset.row = String(r + 1);\n selectItem.dataset.col = String(c + 1);\n selectBlock.appendChild(selectItem);\n }\n }\n const updateSelectBlockItems = () => {\n const { row, col } = selectDom.dataset;\n for (const item of Array.from(selectBlock.querySelectorAll('.active'))) {\n item.classList.remove('active');\n }\n if (!row || !col)\n return;\n const childs = Array.from(selectBlock.children);\n for (let i = 0; i < childs.length; i++) {\n const { row: childRow, col: childCol } = childs[i].dataset;\n if (childRow > row && childCol > col) {\n return;\n }\n if (childRow <= row && childCol <= col) {\n childs[i].classList.add('active');\n }\n else {\n childs[i].classList.remove('active');\n }\n }\n };\n selectBlock.addEventListener('mousemove', (e) => {\n if (!e.target)\n return;\n const { row, col } = e.target.dataset;\n if (!row || !col)\n return;\n selectDom.dataset.row = row;\n selectDom.dataset.col = col;\n updateSelectBlockItems();\n });\n selectBlock.addEventListener('mouseleave', () => {\n selectDom.removeAttribute('data-row');\n selectDom.removeAttribute('data-col');\n updateSelectBlockItems();\n });\n selectBlock.addEventListener('click', () => {\n const { row, col } = selectDom.dataset;\n if (!row || !col)\n return;\n options.onSelect && options.onSelect(Number(row), Number(col));\n });\n selectDom.appendChild(selectBlock);\n if (options.isCustom) {\n const selectCustom = document.createElement('div');\n selectCustom.classList.add('select-box__custom');\n selectCustom.textContent = options.customText || '自定义行列数';\n selectCustom.addEventListener('click', async () => {\n const res = await showTableCreator({\n confirmText: options.confirmText,\n cancelText: options.cancelText,\n rowText: options.rowText,\n colText: options.colText,\n });\n if (res) {\n options.onSelect && options.onSelect(res.row, res.col);\n }\n });\n selectDom.appendChild(selectCustom);\n }\n return selectDom;\n};\nexport const createToolTip = (target, options = {}) => {\n const { msg = '', delay = 0 } = options;\n const wrapper = document.createElement('div');\n wrapper.classList.add('tool-tip');\n wrapper.appendChild(target);\n if (msg) {\n const tip = document.createElement('div');\n tip.classList.add('tool-tip__text');\n tip.classList.add('hidden');\n tip.textContent = msg;\n wrapper.appendChild(tip);\n let timer = null;\n wrapper.addEventListener('mouseenter', () => {\n if (timer)\n clearTimeout(timer);\n timer = setTimeout(() => {\n tip.classList.remove('hidden');\n }, delay);\n });\n wrapper.addEventListener('mouseleave', () => {\n if (timer)\n clearTimeout(timer);\n timer = setTimeout(() => {\n tip.classList.add('hidden');\n timer = null;\n }, delay);\n });\n }\n return wrapper;\n};\n","export const isFunction = (val) => typeof val === 'function';\n","import Quill from 'quill';\nimport { createToolTip, isFunction } from '../utils';\nimport InsertLeft from '../svg/insert-left.svg';\nimport InsertRight from '../svg/insert-right.svg';\nimport InsertTop from '../svg/insert-top.svg';\nimport InsertBottom from '../svg/insert-bottom.svg';\nimport RemoveRow from '../svg/remove-row.svg';\nimport RemoveColumn from '../svg/remove-column.svg';\nimport RemoveTable from '../svg/remove-table.svg';\nconst TableFormat = Quill.import('formats/table');\nconst defaultTools = [\n {\n name: 'InsertTop',\n icon: InsertTop,\n tip: '向上插入一行',\n handle: (tableModule) => {\n tableModule.insertRow(0);\n },\n },\n {\n name: 'InsertRight',\n icon: InsertRight,\n tip: '向右插入一列',\n handle: (tableModule) => {\n tableModule.insertColumn(1);\n },\n },\n {\n name: 'InsertBottom',\n icon: InsertBottom,\n tip: '向下插入一行',\n handle: (tableModule) => {\n tableModule.insertRow(1);\n },\n },\n {\n name: 'InsertLeft',\n icon: InsertLeft,\n tip: '向左插入一列',\n handle: (tableModule) => {\n tableModule.insertColumn(0);\n },\n },\n {\n name: 'break',\n },\n {\n name: 'DeleteRow',\n icon: RemoveRow,\n tip: '删除当前行',\n handle: (tableModule) => {\n tableModule.deleteRow();\n },\n },\n {\n name: 'DeleteColumn',\n icon: RemoveColumn,\n tip: '删除当前列',\n handle: (tableModule) => {\n tableModule.deleteColumn();\n },\n },\n {\n name: 'DeleteTable',\n icon: RemoveTable,\n tip: '删除当前表格',\n handle: (tableModule) => {\n tableModule.deleteTable();\n },\n },\n];\nexport class TableSelection {\n tableModule;\n quill;\n options;\n tableBlot = null;\n selectTd = null;\n cellSelect;\n boundary = null;\n selectTool;\n constructor(tableModule, quill, options = {}) {\n this.tableModule = tableModule;\n this.quill = quill;\n this.options = this.resolveOptions(options);\n this.cellSelect = this.quill.addContainer('ql-table-selection');\n this.selectTool = this.buildTools();\n this.quill.root.addEventListener('mousedown', this.destory);\n this.quill.root.addEventListener('scroll', this.destory);\n this.quill.on(Quill.events.EDITOR_CHANGE, (name, range, _oldRange, _source) => {\n if (name === Quill.events.SELECTION_CHANGE && range) {\n const [blot] = this.quill.scroll.descendant(TableFormat, range.index);\n if (!blot)\n return;\n this.selectTd = blot;\n this.updateSelectBox();\n }\n else {\n this.destory();\n }\n });\n }\n resolveOptions = (options) => {\n return Object.assign({\n selectColor: '#0589f3',\n tools: defaultTools,\n }, options);\n };\n buildTools = () => {\n const toolBox = this.quill.addContainer('ql-table-selection-tool');\n for (const tool of this.options.tools) {\n const { name, icon, handle, tip = '' } = tool;\n let item = document.createElement('span');\n item.classList.add('ql-table-selection-item');\n if (name === 'break') {\n item.classList.add('break');\n }\n else {\n item.classList.add('icon');\n item.innerHTML = icon;\n if (isFunction(handle)) {\n item.addEventListener('click', () => {\n this.quill.focus();\n handle(this.tableModule);\n });\n }\n if (tip) {\n item = createToolTip(item, { msg: tip, delay: 150 });\n }\n }\n toolBox.appendChild(item);\n }\n return toolBox;\n };\n remove = () => {\n Object.assign(this.cellSelect.style, {\n display: 'none',\n });\n Object.assign(this.selectTool.style, {\n display: 'none',\n });\n this.selectTd = null;\n };\n destory = () => {\n this.remove();\n this.tableBlot = null;\n };\n updateSelectBox = () => {\n if (!this.selectTd)\n return;\n this.boundary = this.getRelativeRect(this.selectTd.domNode.getBoundingClientRect(), this.quill.container.getBoundingClientRect());\n Object.assign(this.cellSelect.style, {\n 'border-color': this.options.selectColor,\n 'display': 'block',\n 'left': `${this.boundary.x - 1}px`,\n 'top': `${this.boundary.y - 1}px`,\n 'width': `${this.boundary.width + 1}px`,\n 'height': `${this.boundary.height + 1}px`,\n });\n Object.assign(this.selectTool.style, {\n display: 'flex',\n left: `${this.boundary.x + (this.boundary.width / 2) - 1}px`,\n top: `${this.boundary.y - 1}px`,\n transform: `translate(-50%, 100%)`,\n });\n };\n getRelativeRect = (targetRect, containerRect) => ({\n x: targetRect.x - containerRect.x,\n y: targetRect.y - containerRect.y,\n width: targetRect.width,\n height: targetRect.height,\n });\n}\n","import Quill from 'quill';\nimport { createSelectBox, isFunction } from './utils';\nimport { TableSelection } from './modules';\nconst icons = Quill.import('ui/icons');\nconst TableModule = Quill.import('modules/table');\nconst toolName = 'table';\nexport default class TableUp extends TableModule {\n constructor(quill, options) {\n super(quill, options);\n this.options = this.resolveOptions(options || {});\n const toolbar = this.quill.getModule('toolbar');\n const [, select] = (toolbar.controls || []).find(([name]) => name === toolName) || [];\n if (select && select.tagName.toLocaleLowerCase() === 'select') {\n this.picker = this.quill.theme.pickers.find((picker) => picker.select === select);\n if (!this.picker)\n return;\n this.picker.label.innerHTML = icons.table;\n this.buildCustomSelect(this.options.customSelect);\n this.picker.label.addEventListener('mousedown', this.handleInViewport);\n }\n this.selection = new TableSelection(this, this.quill, this.options.selection);\n }\n handleInViewport = () => {\n const selectRect = this.selector.getBoundingClientRect();\n if (selectRect.right >= window.innerWidth) {\n const labelRect = this.picker.label.getBoundingClientRect();\n this.picker.options.style.transform = `translateX(calc(-100% + ${labelRect.width}px))`;\n }\n else {\n this.picker.options.style.transform = undefined;\n }\n };\n resolveOptions = (options) => {\n return Object.assign({\n isCustom: true,\n texts: this.resolveTexts(options.texts || {}),\n }, options);\n };\n resolveTexts = (options) => {\n return Object.assign({\n customBtn: '自定义行列数',\n confirmText: '确认',\n cancelText: '取消',\n rowText: '行数',\n colText: '列数',\n }, options);\n };\n buildCustomSelect = async (customSelect) => {\n const dom = document.createElement('div');\n dom.classList.add('ql-custom-select');\n this.selector = customSelect && isFunction(customSelect) ? await customSelect(this) : this.createSelect();\n dom.appendChild(this.selector);\n this.picker.options.appendChild(dom);\n };\n createSelect = () => {\n return createSelectBox({\n onSelect: (row, col) => {\n this.insertTable(row, col);\n this.picker.close();\n },\n isCustom: this.options.isCustom,\n customText: this.options.texts.customBtn,\n });\n };\n insertTable = (rows, columns) => {\n this.quill.focus();\n super.insertTable(rows, columns);\n };\n}\n"],"names":["createInputItem","label","options","type","value","inputItem","document","createElement","classList","add","inputLabel","textContent","appendChild","inputInput","input","key","setAttribute","max","min","addEventListener","Number","String","remove","item","errorTip","msg","contains","querySelector","removeError","zindex","showTableCreator","async","box","inputContent","rowItem","rowInput","rowErrorTip","rowText","row","colItem","colInput","colErrorTip","col","control","confirmBtn","confirmText","cancelBtn","cancelText","Promise","resolve","reject","close","child","target","body","beforeClose","appendTo","dialog","style","zIndex","overlay","content","e","stopPropagation","originOverflow","getComputedStyle","overflow","createDialog","isNaN","createToolTip","delay","wrapper","tip","timer","clearTimeout","setTimeout","isFunction","val","TableFormat","Quill","import","defaultTools","name","icon","handle","tableModule","insertRow","insertColumn","deleteRow","deleteColumn","deleteTable","TableSelection","quill","tableBlot","selectTd","cellSelect","boundary","selectTool","constructor","this","resolveOptions","addContainer","buildTools","root","destory","on","events","EDITOR_CHANGE","range","_oldRange","_source","SELECTION_CHANGE","blot","scroll","descendant","index","updateSelectBox","Object","assign","selectColor","tools","toolBox","tool","innerHTML","focus","display","getRelativeRect","domNode","getBoundingClientRect","container","left","x","top","y","width","height","transform","targetRect","containerRect","icons","TableModule","TableUp","super","toolbar","getModule","select","controls","find","tagName","toLocaleLowerCase","picker","theme","pickers","table","buildCustomSelect","customSelect","handleInViewport","selection","selector","right","window","innerWidth","labelRect","undefined","isCustom","texts","resolveTexts","customBtn","colText","dom","createSelect","selectDom","selectBlock","r","c","selectItem","dataset","updateSelectBlockItems","Array","from","querySelectorAll","childs","children","i","length","childRow","childCol","removeAttribute","onSelect","selectCustom","customText","res","createSelectBox","insertTable","rows","columns"],"mappings":"qBACO,MAAMA,EAAkB,CAACC,EAAOC,KACnCA,EAAQC,OAASD,EAAQC,KAAO,QAChCD,EAAQE,QAAUF,EAAQE,MAAQ,IAClC,MAAMC,EAAYC,SAASC,cAAc,OAEzC,GADAF,EAAUG,UAAUC,IAAI,eACpBR,EAAO,CACP,MAAMS,EAAaJ,SAASC,cAAc,QAC1CG,EAAWF,UAAUC,IAAI,gBACzBC,EAAWC,YAAcV,EACzBI,EAAUO,YAAYF,EACzB,CACD,MAAMG,EAAaP,SAASC,cAAc,OAC1CM,EAAWL,UAAUC,IAAI,gBACzB,MAAMK,EAAQR,SAASC,cAAc,SACrC,IAAK,MAAMQ,KAAOb,EACdY,EAAME,aAAaD,EAAKb,EAAQa,KAEhCb,EAAQe,KAAOf,EAAQgB,MACvBJ,EAAMK,iBAAiB,QAAQ,KACvBjB,EAAQe,KAAOf,EAAQe,KAAOG,OAAON,EAAMV,SAC3CU,EAAMV,MAAQiB,OAAOnB,EAAQe,MAE7Bf,EAAQgB,KAAOhB,EAAQgB,KAAOE,OAAON,EAAMV,SAC3CU,EAAMV,MAAQiB,OAAOnB,EAAQgB,KAChC,IAGTL,EAAWD,YAAYE,GACvBT,EAAUO,YAAYC,GACtBC,EAAMK,iBAAiB,SAAS,KAC5BN,EAAWL,UAAUC,IAAI,QAAQ,IAErCK,EAAMK,iBAAiB,QAAQ,KAC3BN,EAAWL,UAAUc,OAAO,QAAQ,IAoBxC,MAAO,CAAEC,KAAMlB,EAAWS,QAAOU,SAlBfC,IACd,IAAID,EAC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,EAAUgB,gBAAgB,YAC1BhB,EAAUgB,gBAAgB,YAC1BV,GAAwB,IAE5BL,EAAYzJ,iBAAiB,SAAS,KAClC,MAAMmB,IAAEA,EAAGI,IAAEA,GAAQiI,EAAUK,QAC1B1I,GAAQI,GAEbxC,EAAQ0L,UAAY1L,EAAQ0L,SAASxK,OAAOkB,GAAMlB,OAAOsB,GAAK,IAElEiI,EAAU/J,YAAYgK,GAClB1K,EAAQkK,SAAU,CAClB,MAAMyB,EAAevL,SAASC,cAAc,OAC5CsL,EAAarL,UAAUC,IAAI,sBAC3BoL,EAAalL,YAAcT,EAAQ4L,YAAc,SACjDD,EAAa1K,iBAAiB,SAASY,UACnC,MAAMgK,QAAYjK,EAAiB,CAC/Be,YAAa3C,EAAQ2C,YACrBE,WAAY7C,EAAQ6C,WACpBV,QAASnC,EAAQmC,QACjBmI,QAAStK,EAAQsK,UAEjBuB,GACA7L,EAAQ0L,UAAY1L,EAAQ0L,SAASG,EAAIzJ,IAAKyJ,EAAIrJ,IACrD,IAELiI,EAAU/J,YAAYiL,EACzB,CACD,OAAOlB,CAAS,EGjJLqB,CAAgB,CACnBJ,SAAU,CAACtJ,EAAKI,KACZyD,KAAK8F,YAAY3J,EAAKI,GACtByD,KAAKmD,OAAOnG,OAAO,EAEvBiH,SAAUjE,KAAKjG,QAAQkK,SACvB0B,WAAY3F,KAAKjG,QAAQmK,MAAME,YAGvC0B,YAAc,CAACC,EAAMC,KACjBhG,KAAKP,MAAMgC,QACXkB,MAAMmD,YAAYC,EAAMC,EAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.input__item{--input-height:2rem;--input-inner-height:calc(var(--input-height) - 0.125rem);--input-color-text:#606266;--input-color-boxshaow:#dcdfe6;--input-color-focus:#409eff;--input-color-error:#f56c6c;--input-boxshaow:0 0 0 0.0625rem var(--input-color-boxshaow) inset;--input-boxshaow-focus:0 0 0 0.0625rem var(--input-color-focus) inset;--input-boxshaow-error:0 0 0 0.0625rem var(--input-color-error) inset;display:flex;align-items:center}.input__item+.input__item{margin-top:1.125rem}.input__label{width:5rem;flex-shrink:0}.input__input{box-sizing:border-box;position:relative;display:flex;flex-wrap:wrap;width:100%;height:var(--input-height);line-height:var(--input-height);padding:.0625rem .5rem;border-radius:.25rem;box-shadow:var(--input-boxshaow);transition:box-shadow .2s linear}.input__input.focus{box-shadow:var(--input-boxshaow-focus)}.input__input input{width:100%;height:var(--input-inner-height);line-height:var(--input-inner-height);flex-grow:1;font-size:.875rem;color:var(--input-color-text);outline:0;border:0;padding:0}.input__input.error{box-shadow:var(--input-boxshaow-error)}.input__error-tip{position:absolute;top:100%;left:0;font-size:.75rem;color:var(--input-color-error);line-height:1rem}.dialog{--dialog-bg:rgba(0, 0, 0, 0.5);--dialog-color-border:#ebeef5;--dialog-color-boxshadow:rgba(0, 0, 0, 0.12);--dialog-border:0.0625rem solid var(--dialog-color-border);--dialog-boxshadow:0 0 0.75rem var(--dialog-color-boxshadow);position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;height:100%;background-color:var(--dialog-bg);overflow:auto}.dialog__overlay{position:fixed;top:0;right:0;bottom:0;left:0;padding:1rem;overflow:auto;text-align:center}.dialog__overlay::after{content:'';display:inline-block;height:100%;width:0;vertical-align:middle}.dialog__content{display:inline-block;max-width:50vw;width:100%;vertical-align:middle;background-color:#fff;border-radius:.25rem;border:var(--dialog-border);font-size:1.125rem;box-shadow:var(--dialog-boxshadow);text-align:left;overflow:hidden;box-sizing:border-box}.table-creator{--table-creator-btn-color:#606266;--table-creator-bg-hover:#f3f4f6;--table-creator-btn-color-border:#dcdfe6;--table-creator-btn-border:0.0625rem solid var(--table-creator-btn-color-border);--table-creator-btn-confirm-color-border:#409eff;--table-creator-btn-confirm-bg:#409eff;--table-creator-btn-confirm-hover:#79bbff;--table-creator-btn-confirm-outline-focus-visible:0.125rem solid #a0cfff;padding:1.5rem}.table-creator__input{display:flex;flex-direction:column;width:100%}.table-creator__control{margin-top:1rem;text-align:right}.table-creator__btn{box-sizing:border-box;display:inline-flex;height:2rem;line-height:1;margin:0;padding:.5rem 1rem;border-radius:.25rem;border:var(--table-creator-btn-border);color:var(--table-creator-btn-color);background-color:transparent;font-size:.875rem;cursor:pointer}.table-creator__btn+.table-creator__btn{margin-left:.375rem}.table-creator__btn:hover{background-color:var(--table-creator-bg-hover)}.table-creator__btn.confirm{border-color:var(--table-creator-btn-confirm-color-border);background-color:var(--table-creator-btn-confirm-bg);color:#fff}.table-creator__btn.confirm:hover{border-color:var(--table-creator-btn-confirm-hover);background-color:var(--table-creator-btn-confirm-hover)}.table-creator__btn.confirm:focus-visible{outline:var(--table-creator-btn-confirm-outline-focus-visible);outline-offset:.0625rem}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quill-table-up",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "A table module for quill2.x",
|
|
6
|
+
"author": "zzxming",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/zzxming/quill-table"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"quill",
|
|
14
|
+
"table",
|
|
15
|
+
"module"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./index.css": "./dist/index.css",
|
|
23
|
+
"./table-creator.css": "./dist/table-creator.css"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"lint": "eslint . --cache",
|
|
32
|
+
"lint:fix": "eslint . --fix",
|
|
33
|
+
"build": "gulp --require @esbuild-kit/cjs-loader",
|
|
34
|
+
"dev": "gulp --require @esbuild-kit/cjs-loader dev"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"quill": "^2.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@esbuild-kit/cjs-loader": "^2.4.4",
|
|
41
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
42
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
43
|
+
"@types/node": "^20.14.10",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
45
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
46
|
+
"@zzxming/eslint-config": "^0.0.10",
|
|
47
|
+
"autoprefixer": "^10.4.19",
|
|
48
|
+
"eslint-merge-processors": "^0.1.0",
|
|
49
|
+
"eslint-plugin-jsonc": "^2.16.0",
|
|
50
|
+
"eslint-plugin-markdown": "^5.1.0",
|
|
51
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
52
|
+
"gulp": "^4.0.2",
|
|
53
|
+
"gulp-clean-css": "^4.3.0",
|
|
54
|
+
"gulp-less": "^5.0.0",
|
|
55
|
+
"gulp-postcss": "^10.0.0",
|
|
56
|
+
"jsonc-eslint-parser": "^2.4.0",
|
|
57
|
+
"postcss-pxtorem": "^6.1.0",
|
|
58
|
+
"rollup": "^4.18.1",
|
|
59
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
60
|
+
"rollup-plugin-svg-import": "^3.0.0",
|
|
61
|
+
"typescript": "^5.5.3",
|
|
62
|
+
"yaml-eslint-parser": "^1.2.3"
|
|
63
|
+
}
|
|
64
|
+
}
|