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

Commitad0e6d0

Browse files
keithamuskhiga8
andcommitted
SimplifyextractQuote options.
BREAKING CHANGEThis function only ever used the `quoteElement` option, so it issimpler to have this as an optional argument as opposed to having anoptions object passed in.Co-authored-by: Kate Higa <khiga8@github.com>
1 parent42a3444 commitad0e6d0

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

‎src/index.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import{extractFragment,insertMarkdownSyntax}from'./markdown'
22

3-
typeOptions={
4-
quoteMarkdown:boolean
5-
scopeSelector:string
6-
quoteElement:Element
7-
}
8-
93
typeQuote={
104
container:Element
115
range:Range
126
selectionText:string
137
}
148

15-
exportfunctionextractQuote(containerSelector:string,options?:Partial<Options>):Quote|undefined{
9+
exportfunctionextractQuote(containerSelector:string,quoteElement?:Element):Quote|undefined{
1610
constselection=window.getSelection()
1711
if(!selection)return
18-
if(options?.quoteElement){
12+
if(quoteElement){
1913
selection.removeAllRanges()
20-
selection.selectAllChildren(options.quoteElement)
14+
selection.selectAllChildren(quoteElement)
2115
}
2216
letrange
2317
try{

‎test/test.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ describe('quote-selection', function () {
9898
})
9999

100100
it('preserves formatting',function(){
101-
constquote=extractQuote('[data-quote]',{
102-
quoteElement:document.querySelector('.comment-body')
103-
})
101+
constquote=extractQuote('[data-quote]',document.querySelector('.comment-body'))
104102
constmarkdownQuote=asMarkdown(quote,'.comment-body')
105103

106104
consttextarea=document.querySelector('textarea')
@@ -127,9 +125,7 @@ describe('quote-selection', function () {
127125
})
128126

129127
it('provides a callback to mutate markup',function(){
130-
constquote=extractQuote('[data-quote]',{
131-
quoteElement:document.querySelector('.comment-body')
132-
})
128+
constquote=extractQuote('[data-quote]',document.querySelector('.comment-body'))
133129
constmarkdownQuote=asMarkdown(quote,'.comment-body',fragment=>{
134130
fragment.querySelector('a[href]').replaceWith('@links')
135131
fragment.querySelector('img[alt]').replaceWith(':emoji:')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp