Skip to content

Commit

Permalink
Merge pull request #14 from haruyan-hopemucci/feat/disable-edit-text-…
Browse files Browse the repository at this point in the history
…label

contenteditable廃止
  • Loading branch information
haruyan-hopemucci authored Nov 20, 2023
2 parents 54c72e7 + 778403d commit 3173a39
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/css/style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#paste-area {
position: relative;
border: 1px solid #888888;
border-radius: 0.5rem;
padding: 1em;
padding: 1rem;
}

img#pasted-image {
max-width: 400px;
max-height: 400px;
Expand Down
2 changes: 1 addition & 1 deletion docs/css/style.css.map

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

11 changes: 10 additions & 1 deletion docs/css/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#paste-area {
position: relative;
border: 1px solid #888888;
border-radius: 0.5rem;
padding: 1em;
padding: 1rem;

#paste-area-message {
// position: absolute;
// top: 1em;
// left: 1em;
// z-index: -100;
}

}

img#pasted-image {
Expand Down
7 changes: 3 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
</head>
<body>
<main class="container">
<h1>LGTN Generator <small>v0.1.0</small></h1>

<div id="paste-area" contenteditable="true">
ここをクリックした後画像をペーストしてください。
<h1>LGTN Generator <small>v0.2.0</small></h1>
<div id="paste-area">
<div id="paste-area-message">クリップボードにコピーした画像をペーストしてください。</div>
</div>
<div>
<div class="form-check form-check-inline">
Expand Down
17 changes: 12 additions & 5 deletions docs/js/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
'use strict'

$(function (){
document.querySelector('#paste-area').addEventListener('paste', (event) => {

const setMessage = message => {
const elem = document.querySelector("#paste-area-message")
elem.textContent = message
}

// document.querySelector('#paste-area').addEventListener('paste', (event) => {
document.addEventListener('paste', (event) => {

event.preventDefault()

if (!event.clipboardData
|| !event.clipboardData.types
|| (event.clipboardData.types.length != 1)
|| (event.clipboardData.types[0] != "Files")) {
event.target.innerHTML = 'ペーストされたデータが画像ではありません'
setMessage('ペーストされたデータが画像ではありません')
return true;
}

event.target.innerHTML = 'LGTN画像を生成しています...'
setMessage('LGTN画像を生成しています...')

generateLGTN(event.clipboardData.items[0])

Expand Down Expand Up @@ -51,11 +58,11 @@ $(function (){
const item = new ClipboardItem({ 'image/png': blob})
navigator.clipboard.write([item])
.then( () => {
pasteArea.innerHTML = 'クリップボードにLGTN画像がコピーされました!'
setMessage('クリップボードにLGTN画像がコピーされました!')
})
.catch( ex => {
console.error(ex)
pasteArea.innerHTML = 'クリップボードの書き込み時にエラーが発生しました'
setMessage('クリップボードの書き込み時にエラーが発生しました')
})
});

Expand Down

0 comments on commit 3173a39

Please sign in to comment.