Skip to content

Commit 6c1e961

Browse files
committed
fix(gitlab): remove lodash and update append copy button logic
1 parent c816ada commit 6c1e961

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/MdGenerator/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import lodash from 'lodash'
21
import * as MdTools from './MdTools'
32
export { MdTools }
43

@@ -23,6 +22,10 @@ type TableOptions = Partial<LevelOptions>
2322
type HyperlinkOptions = Partial<LevelOptions & { anchorKey: string }>
2423
type ImageOptions = Partial<LevelOptions & { anchorKey: string, alt: string }>
2524

25+
function cloneDeep <T>(value: T): T {
26+
return JSON.parse(JSON.stringify(value)) as T
27+
}
28+
2629
class Template {
2730
protected templateContent: string
2831
protected anchorMap: Record<string, string> = {}
@@ -153,7 +156,7 @@ class Template {
153156
this.templateContent += MdTools.enter()
154157
}
155158
public modify(callback: (content: string) => string) {
156-
this.templateContent = callback(lodash.cloneDeep(this.templateContent))
159+
this.templateContent = callback(cloneDeep(this.templateContent))
157160
return this.contentNextUtils
158161
}
159162
}
@@ -163,7 +166,7 @@ export const genTemplate = (callback: (utils: Template) => any = (() => { })) =>
163166
}
164167

165168
export const readTemplate = (text: string, callback: (utils: Template) => any = (() => { })) => {
166-
const templateInst = new Template(lodash.cloneDeep(text))
169+
const templateInst = new Template(cloneDeep(text))
167170
callback(templateInst)
168171
return templateInst[Symbol.toStringTag]()
169172
}

src/monkey/gitlab-enhance/merge_requests/new.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const appendAsTitleButton = () => {
1414
})
1515
}
1616

17-
1817
if (location.pathname.endsWith('/-/merge_requests/new')) {
1918
setTimeout(() => {
2019
appendTemplateButton()

src/monkey/gitlab-enhance/merge_requests/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ export const appendTemplateButton = () => {
9292
})
9393
})
9494

95-
$('.gl-display-flex:has([for=merge_request_description])').append(btnElement)
95+
$('*:has(>[for=merge_request_description])').append(btnElement)
9696
}

0 commit comments

Comments
 (0)