Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc8eaba8

Browse files
khiga8keithamus
andcommitted
Remove quote-selection event
This was only used to intercept quote behaviour, and doesn't really addany value as whatever used to listen to this can simply do the samebehaviour after `quote()` has been called.Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
1 parentab12699 commitc8eaba8

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

‎README.md‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,7 @@ The optional `scopeSelector` parameter ensures that even if the user selection b
4444
##Events
4545

4646
-`quote-selection-markdown` (bubbles: true, cancelable: false) - fired on the quote region to optionally inject custom syntax into the`fragment` element in`quoteMarkdown: true` mode
47-
-`quote-selection` (bubbles: true, cancelable: true) - fired on the quote region before text is appended to a textarea
4847

49-
For example, reveal a textarea so it can be found:
50-
51-
```js
52-
region.addEventListener('quote-selection',function (event) {
53-
const {selection,selectionText}=event.detail
54-
console.log('Quoted text', selection, selectionText)
55-
56-
consttextarea=event.target.querySelector('textarea')
57-
textarea.hidden=false
58-
59-
// Cancel the quote behavior.
60-
// event.preventDefault()
61-
})
6248
```
6349
6450
## Development

‎src/index.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,6 @@ export function quote(selectionContext: SelectionContext, options: Partial<Optio
3434
if(!quoted)returnfalse
3535

3636
const{container, selectionText}=quoted
37-
38-
constdispatched=container.dispatchEvent(
39-
newCustomEvent('quote-selection',{
40-
bubbles:true,
41-
cancelable:true,
42-
detail:{range:selectionContext.range, selectionText}
43-
})
44-
)
45-
46-
if(!dispatched){
47-
returntrue
48-
}
49-
5037
constfield=findTextarea(container)
5138
if(!field)returnfalse
5239

‎test/test.js‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,26 @@ describe('quote-selection', function () {
3333
constselection=window.getSelection()
3434
window.getSelection=()=>createSelection(selection,el)
3535

36-
constcontainer=document.querySelector('[data-quote]')
3736
consttextarea=document.querySelector('#not-hidden-textarea')
38-
leteventCount=0
3937
letchangeCount=0
4038

41-
container.addEventListener('quote-selection',function(){
42-
eventCount++
43-
})
44-
4539
textarea.addEventListener('change',function(){
4640
changeCount++
4741
})
4842

4943
quote(getSelectionContext(),{containerSelector:'[data-quote], [data-nested-quote]'})
5044
assert.equal(textarea.value,'Has text\n\n> Test Quotable text, bold.\n\n')
51-
assert.equal(eventCount,1)
5245
assert.equal(changeCount,1)
5346
})
5447

5548
it('nested textarea is updated when event is captured',function(){
5649
constel=document.querySelector('#nested-quotable')
5750
constselection=window.getSelection()
5851
window.getSelection=()=>createSelection(selection,el)
59-
constcontainer=document.querySelector('[data-nested-quote]')
6052
consttextarea=document.querySelector('#nested-textarea')
6153
constouterTextarea=document.querySelector('#not-hidden-textarea')
6254

63-
container.addEventListener('quote-selection',function(){
64-
textarea.hidden=false
65-
})
55+
textarea.hidden=false
6656

6757
quote(getSelectionContext(),{containerSelector:'[data-quote], [data-nested-quote]'})
6858
assert.equal(outerTextarea.value,'Has text')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp