diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index fbb956a..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react-hooks/recommended", - ], - ignorePatterns: ["dist", "docs", ".eslintrc.cjs"], - parser: "@typescript-eslint/parser", - plugins: ["react-refresh"], - rules: { - "react-refresh/only-export-components": [ - "warn", - { allowConstantExport: true }, - ], - }, -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index cfd47fb..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - NODE_VERSION: "22" - -jobs: - full-code-check: - runs-on: ubuntu-latest - steps: - - name: Full-check repository - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - check-latest: true - - name: Install dependecies - run: | - yarn install - - name: Lint code - run: | - yarn lint - - name: Build React - env: - CI: false - run: | - yarn build diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 08cd93e..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Docs build and deploy -on: push - -env: - NODE_VERSION: "22" - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Node.js 📦 - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - check-latest: true - - name: Install and Build 🔧 - run: | # Install packages and build the demo project - yarn install - yarn build-docs - - name: Get commit info - shell: bash - run: | - echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV" - - name: Deploy 🚀 - uses: crazy-max/ghaction-github-pages@v4 - with: - target_branch: docs - build_dir: docs - commit_message: "Deploying to docs from ${{ env.sha_short }}" - keep_history: false - jekyll: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cb33b0d..0000000 --- a/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -docs -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c0c1f00..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Cristiano Raimondi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 9d93542..0000000 --- a/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# React Basic Contenteditable - - - -A React component that allows you to create an editable area in your application. It's perfect for situations where you need to provide a user-friendly, in-place editing functionality. - -## Installation - -Install via npm - -```sh -npm install --save react-basic-contenteditable -``` - -or yarn - -```sh -yarn add react-basic-contenteditable -``` - -## Usage - -Live **demo** at [https://chrisuser.github.io/react-basic-contenteditable/](https://chrisuser.github.io/react-basic-contenteditable/) - -### Example - -```javascript -import ContentEditable from "react-basic-contenteditable" - -const App = () => { - const [content, setContent] = useState("") - - return ( -
"]})]}),D.jsxs("section",{className:"demo-card",children:[D.jsxs("div",{className:"card-header",children:[D.jsx("h2",{children:"Disabled state"}),D.jsx("span",{className:"badge",children:"disabled prop"})]}),D.jsx(wa,{placeholder:"Cannot type here",containerClassName:"disabled-container",contentEditableClassName:`disabled-input ${W?"disabled-input--off":""}`,placeholderClassName:"disabled-placeholder",disabled:W}),D.jsx("button",{className:"btn btn--outline toggle-btn",onClick:()=>q(x=>!x),children:W?"Enable editing":"Disable editing"})]}),D.jsxs("section",{className:"demo-card",children:[D.jsxs("div",{className:"card-header",children:[D.jsx("h2",{children:"Sanitize callback"}),D.jsx("span",{className:"badge",children:"sanitize prop"})]}),D.jsx(wa,{placeholder:"Try typing numbers...",containerClassName:"sanitize-container",contentEditableClassName:"sanitize-input",placeholderClassName:"sanitize-placeholder",sanitize:x=>x.replace(/[0-9]/g,""),onChange:x=>xl(x)}),D.jsxs("p",{className:"demo-hint",children:["Numbers are stripped in real time via"," ",D.jsxs("code",{children:["sanitize=","{(t) => t.replace(/[0-9]/g, '')}"]})]}),nl&&D.jsxs("div",{className:"output-preview",children:[D.jsx("span",{className:"output-label",children:"Output:"})," ",nl]})]}),D.jsxs("section",{className:"demo-card",children:[D.jsxs("div",{className:"card-header",children:[D.jsx("h2",{children:"Inline style override"}),D.jsx("span",{className:"badge",children:"style prop"})]}),D.jsx(wa,{placeholder:"Styled via props...",containerClassName:"styled-container",placeholderClassName:"styled-placeholder",style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",borderRadius:"1rem",padding:"1rem 1.25rem",fontSize:"1.05rem",minHeight:"3rem"}}),D.jsxs("p",{className:"demo-hint",children:["Internal defaults are merged with your ",D.jsx("code",{children:"style"})," object. Your values take precedence."]})]}),D.jsxs("section",{className:"demo-card",children:[D.jsxs("div",{className:"card-header",children:[D.jsx("h2",{children:"Event log"}),D.jsx("span",{className:"badge",children:"onFocus / onBlur / onPaste"})]}),D.jsxs("div",{className:"event-log",children:[Il.length===0&&D.jsx("span",{className:"event-log__empty",children:"Interact with the chat input above..."}),Il.map((x,El)=>D.jsx("div",{className:"event-log__entry",children:x},El))]})]})]}),D.jsx("footer",{className:"demo-footer",children:D.jsxs("span",{children:["Undo ",D.jsx("kbd",{children:"Ctrl/Cmd+Z"})," · Redo"," ",D.jsx("kbd",{children:"Ctrl/Cmd+Shift+Z"})]})})]})};fv.createRoot(document.getElementById("root")).render(D.jsx(Py.StrictMode,{children:D.jsx(ov,{})})); diff --git a/assets/index-CKjui8St.css b/assets/index-CKjui8St.css new file mode 100644 index 0000000..44e2d4f --- /dev/null +++ b/assets/index-CKjui8St.css @@ -0,0 +1 @@ +:root{--color-bg: #f8f9fb;--color-surface: #ffffff;--color-border: #e2e4e9;--color-text: #1a1a2e;--color-muted: #71717a;--color-primary: #6366f1;--color-primary-hover: #4f46e5;--radius: .5rem;--shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);--shadow-md: 0 2px 8px rgba(0, 0, 0, .08);font-family:Inter,system-ui,-apple-system,sans-serif;font-weight:400;color:var(--color-text);font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*{box-sizing:border-box}body{margin:0;background:var(--color-bg);min-height:100vh}#root{width:100%}.demo-root{max-width:960px;margin:0 auto;padding:2rem 1.5rem 3rem}.demo-header{text-align:center;margin-bottom:2rem}.demo-header h1{font-size:1.75rem;font-weight:700;margin:0 0 .25rem;letter-spacing:-.02em}.demo-subtitle{color:var(--color-muted);font-size:.95rem;margin:0}.demo-grid{display:grid;grid-template-columns:1fr 1fr;gap:1.25rem}@media(max-width:680px){.demo-grid{grid-template-columns:1fr}}.demo-card{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius);padding:1.25rem;display:flex;flex-direction:column;gap:.75rem;box-shadow:var(--shadow-sm)}.demo-card--wide{grid-column:1 / -1}.card-header{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.card-header h2{font-size:1rem;font-weight:600;margin:0}.badge{font-size:.7rem;font-family:SF Mono,Fira Code,monospace;background:#eef2ff;color:var(--color-primary);padding:.15rem .5rem;border-radius:999px;white-space:nowrap}.demo-hint{color:var(--color-muted);font-size:.8rem;margin:0;line-height:1.4}.demo-hint code{background:#f4f4f5;padding:.1rem .3rem;border-radius:.2rem;font-size:.75rem}.output-preview{font-size:.8rem;font-family:SF Mono,Fira Code,monospace;background:#f9fafb;border:1px dashed var(--color-border);border-radius:var(--radius);padding:.5rem .75rem;word-break:break-word}.output-label{color:var(--color-muted)}.btn{cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;font-size:.82rem;font-weight:500;padding:.45rem .9rem;border-radius:var(--radius);transition:background .15s,color .15s,box-shadow .15s;line-height:1.4}.btn--primary{background:var(--color-primary);color:#fff}.btn--primary:hover{background:var(--color-primary-hover)}.btn--ghost{background:transparent;color:var(--color-muted)}.btn--ghost:hover{background:#f4f4f5;color:var(--color-text)}.btn--outline{background:transparent;border:1px solid var(--color-border);color:var(--color-text)}.btn--outline:hover{border-color:var(--color-primary);color:var(--color-primary)}.btn--emoji{background:transparent;font-size:1.15rem;padding:.25rem .35rem;border-radius:.35rem;line-height:1}.btn--emoji:hover{background:#f4f4f5;transform:scale(1.15)}.toggle-btn{align-self:flex-start}.chat-messages{display:flex;flex-direction:column;gap:.5rem;max-height:200px;overflow-y:auto;padding-right:.25rem}.chat-bubble{align-self:flex-start;background:#f4f4f5;border:1px solid var(--color-border);padding:.55rem .85rem;border-radius:var(--radius);font-size:.88rem;line-height:1.4;white-space:pre-wrap;word-break:break-word;max-width:85%}.chat-input-row{position:relative}.chat-input-container{width:100%;position:relative}.chat-input{width:100%;border:1px solid var(--color-border);border-radius:var(--radius);line-height:1.4;min-height:2.6rem;max-height:8rem;font-size:.88rem;transition:border-color .15s,box-shadow .15s}.chat-input:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #6366f11f}.chat-placeholder{color:var(--color-muted);font-size:.88rem;margin-left:.85rem}.chat-counter{font-size:.72rem;color:var(--color-muted);font-family:SF Mono,Fira Code,monospace;flex-shrink:0}.chat-toolbar{display:flex;align-items:center;justify-content:space-between;gap:.5rem;flex-wrap:wrap}.emoji-row{display:flex;gap:.15rem}.chat-actions{display:flex;gap:.35rem}.single-container{width:100%;position:relative}.single-input{width:100%;border:1px solid var(--color-border);border-radius:var(--radius);font-size:1.1rem;font-weight:600;line-height:1.4;min-height:2.4rem;transition:border-color .15s,box-shadow .15s}.single-input:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #6366f11f}.single-placeholder{color:var(--color-muted);font-size:1.1rem;font-weight:600;margin-left:.85rem}.quote-container{width:100%;position:relative}.quote-input{width:100%;min-height:2.4rem;line-height:1.5;font-size:.92rem}.quote-input:focus{outline:none;box-shadow:0 0 0 3px #6366f11a}.quote-placeholder{color:#8b8bc7;font-style:italic;margin-left:1rem}.disabled-container{width:100%;position:relative}.disabled-input{width:100%;border:1px solid var(--color-border);border-radius:var(--radius);font-size:.88rem;min-height:2.4rem;line-height:1.4;transition:background .2s,opacity .2s}.disabled-input--off{background:#f9fafb;opacity:.6;cursor:not-allowed}.disabled-input:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #6366f11f}.disabled-placeholder{color:var(--color-muted);font-size:.88rem;margin-left:.85rem}.sanitize-container{width:100%;position:relative}.sanitize-input{width:100%;border:1px solid var(--color-border);border-radius:var(--radius);font-size:.88rem;min-height:2.4rem;line-height:1.4;transition:border-color .15s,box-shadow .15s}.sanitize-input:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #6366f11f}.sanitize-placeholder{color:var(--color-muted);font-size:.88rem;margin-left:.85rem}.styled-container{width:100%;position:relative}.styled-placeholder{color:#ffffffa6;margin-left:1.25rem}.event-log{display:flex;flex-direction:column;gap:.3rem;font-family:SF Mono,Fira Code,monospace;font-size:.78rem;min-height:5rem}.event-log__empty{color:var(--color-muted);font-style:italic}.event-log__entry{background:#f9fafb;padding:.3rem .6rem;border-radius:.25rem;color:var(--color-text);animation:fadeIn .15s ease-out}@keyframes fadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.demo-footer{text-align:center;margin-top:2rem;color:var(--color-muted);font-size:.82rem}kbd{background:#f4f4f5;border:1px solid var(--color-border);border-radius:.25rem;padding:.1rem .35rem;font-family:SF Mono,Fira Code,monospace;font-size:.75rem} diff --git a/index.html b/index.html index 1aa17ac..2570b45 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,10 @@react-basic-contenteditable + + -