Skip to content

Commit

Permalink
Merge pull request #6 from tidbcloud/chore/extension-abstract
Browse files Browse the repository at this point in the history
Chore/extension abstract
  • Loading branch information
sanshuiyijing authored Jun 14, 2024
2 parents 0d10c50 + 45c1236 commit f7b9fed
Show file tree
Hide file tree
Showing 18 changed files with 943 additions and 6 deletions.
46 changes: 46 additions & 0 deletions packages/extensions/autocomplete/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@tidbcloud/tisqleditor-extensions-autocomplete",
"version": "1.0.0",
"description": "tisqleditor extensions",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/*.js",
"dist/*.ts",
"package.json",
"README.md"
],
"scripts": {
"tsc:watch": "tsc --watch",
"rollup:watch": "rollup -c --watch",
"dev": "concurrently --kill-others \"pnpm tsc:watch\" \"pnpm rollup:watch\"",
"build": "tsc && rollup -c"
},
"keywords": [
"tidbcloud",
"sql",
"editor",
"extensions",
"autocomplete"
],
"author": "",
"license": "MIT",
"devDependencies": {
"@codemirror/autocomplete": "^6.16.2",
"@codemirror/commands": "6.3.3",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.26.3",
"@rollup/plugin-typescript": "^11.1.6",
"rollup": "^4.18.0",
"tslib": "^2.6.3",
"typescript": "^5.4.5"
},
"peerDependencies": {
"@codemirror/autocomplete": "^6.16.2",
"@codemirror/commands": "6.3.3",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.26.3"
}
}
10 changes: 10 additions & 0 deletions packages/extensions/autocomplete/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import typescript from '@rollup/plugin-typescript'

export default {
input: './src/index.ts',
output: {
dir: './dist',
format: 'es'
},
plugins: [typescript()]
}
53 changes: 53 additions & 0 deletions packages/extensions/autocomplete/src/icons-svg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const Brackets = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.3807 13.3334C13.222 13.3334 13.9047 12.6514 13.9047 11.8094V8.76208L14.6667 8.00008L13.9047 7.23808V4.19075C13.9047 3.34875 13.2227 2.66675 12.3807 2.66675M3.6195 2.66675C2.7775 2.66675 2.0955 3.34875 2.0955 4.19075V7.23808L1.3335 8.00008L2.0955 8.76208V11.8094C2.0955 12.6514 2.7775 13.3334 3.6195 13.3334" stroke="#999999" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Calendar = `<svg width="14" height="16" viewBox="0 0 14 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 6.66671H1M9.66667 1.33337V4.00004M4.33333 1.33337V4.00004M4.2 14.6667H9.8C10.9201 14.6667 11.4802 14.6667 11.908 14.4487C12.2843 14.257 12.5903 13.951 12.782 13.5747C13 13.1469 13 12.5868 13 11.4667V5.86671C13 4.7466 13 4.18655 12.782 3.75873C12.5903 3.3824 12.2843 3.07644 11.908 2.88469C11.4802 2.66671 10.9201 2.66671 9.8 2.66671H4.2C3.0799 2.66671 2.51984 2.66671 2.09202 2.88469C1.71569 3.07644 1.40973 3.3824 1.21799 3.75873C1 4.18655 1 4.7466 1 5.86671V11.4667C1 12.5868 1 13.1469 1.21799 13.5747C1.40973 13.951 1.71569 14.257 2.09202 14.4487C2.51984 14.6667 3.0799 14.6667 4.2 14.6667Z" stroke="#999999" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Functions = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_210_1594)">
<path d="M10.3335 10.0002L12.3335 8.00016L10.3335 6.00016M5.66683 6.00016L3.66683 8.00016L5.66683 10.0002M8.66683 4.66683L7.3335 11.3335M14.6668 8.00016C14.6668 11.6821 11.6821 14.6668 8.00016 14.6668C4.31826 14.6668 1.3335 11.6821 1.3335 8.00016C1.3335 4.31826 4.31826 1.3335 8.00016 1.3335C11.6821 1.3335 14.6668 4.31826 14.6668 8.00016Z" stroke="#52CC7A" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_210_1594">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>`

export const Database = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 3.3335C14 4.43807 11.3137 5.3335 8 5.3335C4.68629 5.3335 2 4.43807 2 3.3335M14 3.3335C14 2.22893 11.3137 1.3335 8 1.3335C4.68629 1.3335 2 2.22893 2 3.3335M14 3.3335V12.6668C14 13.7735 11.3333 14.6668 8 14.6668C4.66667 14.6668 2 13.7735 2 12.6668V3.3335M14 8.00016C14 9.10683 11.3333 10.0002 8 10.0002C4.66667 10.0002 2 9.10683 2 8.00016" stroke="#F2AADA" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Table = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 6H14M2 10H14M8 2V14M5.2 2H10.8C11.9201 2 12.4802 2 12.908 2.21799C13.2843 2.40973 13.5903 2.71569 13.782 3.09202C14 3.51984 14 4.0799 14 5.2V10.8C14 11.9201 14 12.4802 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.4802 14 11.9201 14 10.8 14H5.2C4.07989 14 3.51984 14 3.09202 13.782C2.71569 13.5903 2.40973 13.2843 2.21799 12.908C2 12.4802 2 11.9201 2 10.8V5.2C2 4.07989 2 3.51984 2.21799 3.09202C2.40973 2.71569 2.71569 2.40973 3.09202 2.21799C3.51984 2 4.0799 2 5.2 2Z" stroke="#91B2F2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Keyword = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 6H10.0067M10 10C12.2091 10 14 8.20914 14 6C14 3.79086 12.2091 2 10 2C7.79086 2 6 3.79086 6 6C6 6.18245 6.01222 6.36205 6.03587 6.53802C6.07478 6.82745 6.09424 6.97217 6.08114 7.06373C6.0675 7.1591 6.05013 7.2105 6.00313 7.2946C5.958 7.37533 5.87847 7.45486 5.71942 7.61391L2.31242 11.0209C2.19712 11.1362 2.13947 11.1939 2.09824 11.2611C2.06169 11.3208 2.03475 11.3858 2.01842 11.4538C2 11.5306 2 11.6121 2 11.7752V12.9333C2 13.3067 2 13.4934 2.07266 13.636C2.13658 13.7614 2.23856 13.8634 2.36401 13.9273C2.50661 14 2.6933 14 3.06667 14H4.22484C4.3879 14 4.46943 14 4.54615 13.9816C4.61418 13.9652 4.67921 13.9383 4.73886 13.9018C4.80613 13.8605 4.86378 13.8029 4.97909 13.6876L8.38609 10.2806C8.54514 10.1215 8.62467 10.042 8.7054 9.99687C8.7895 9.94987 8.8409 9.9325 8.93627 9.91886C9.02783 9.90576 9.17255 9.92522 9.46198 9.96413C9.63795 9.98778 9.81755 10 10 10Z" stroke="#F2AA18" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Numberic = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_404_1835)">
<path d="M1.3335 4.97491L14.6668 4.97491M1.3335 10.9924L14.6668 10.9924M5.99023 1.33325L3.67309 14.6666M11.9162 1.33325L9.59901 14.6666" stroke="#999999" stroke-linecap="round"/>
</g>
<defs>
<clipPath id="clip0_404_1835">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>`

export const String = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.66683 10.8421H7.3335M1.3335 14L4.82556 2L8.66683 14M9.3335 6.93609C9.64722 5.59887 10.2747 4.19483 12.157 4.596C14.0394 4.99716 14.0394 7.27038 14.0394 8.27325V9.61044M14.0394 9.61044V12.6191M14.0394 9.61044C13.7257 9.16471 12.8472 8.27326 11.8433 8.27325C10.5884 8.27325 9.64722 9.61043 9.64722 10.9476C9.64722 12.2848 9.96095 13.622 11.5296 13.9563C12.798 14.2266 13.6211 13.1763 14.0394 12.6191M14.0394 12.6191C14.0394 13.0649 14.1649 13.9563 14.6668 13.9563" stroke="#999999" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Types = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.6665 4.6665C2.6665 4.04525 2.6665 3.73462 2.768 3.48959C2.90332 3.16289 3.16289 2.90332 3.48959 2.768C3.73462 2.6665 4.04525 2.6665 4.6665 2.6665H11.3332C11.9544 2.6665 12.2651 2.6665 12.5101 2.768C12.8368 2.90332 13.0964 3.16289 13.2317 3.48959C13.3332 3.73462 13.3332 4.04525 13.3332 4.6665M5.33317 13.3332H10.6665M6.83317 2.6665V13.3332M9.1665 2.6665V13.3332" stroke="#C2AAF2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`

export const Variable = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.2709 14C14.1644 12.1926 14.6668 10.1553 14.6668 8C14.6668 5.84474 14.1644 3.80744 13.2709 2M2.72945 2C1.83592 3.80744 1.3335 5.84474 1.3335 8C1.3335 10.1553 1.83592 12.1926 2.72945 14M11.0326 5.75H10.9728C10.5372 5.75 10.1233 5.94134 9.83986 6.27381L6.25664 10.4762C5.97315 10.8087 5.5593 11 5.1237 11H5.06392M5.81005 5.75H6.73944C7.07256 5.75 7.36531 5.97198 7.45682 6.29396L8.63978 10.456C8.73129 10.778 9.02404 11 9.35716 11H10.2866" stroke="#2E6BE5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`
Loading

0 comments on commit f7b9fed

Please sign in to comment.