mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Make tasklist checkboxes clickable (#15791)
Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		@@ -384,18 +384,19 @@ func (r *HTMLRenderer) renderTaskCheckBoxListItem(w util.BufWriter, source []byt
 | 
			
		||||
		} else {
 | 
			
		||||
			_, _ = w.WriteString("<li>")
 | 
			
		||||
		}
 | 
			
		||||
		end := ">"
 | 
			
		||||
		if r.XHTML {
 | 
			
		||||
			end = " />"
 | 
			
		||||
		_, _ = w.WriteString(`<input type="checkbox" disabled=""`)
 | 
			
		||||
		segments := node.FirstChild().Lines()
 | 
			
		||||
		if segments.Len() > 0 {
 | 
			
		||||
			segment := segments.At(0)
 | 
			
		||||
			_, _ = w.WriteString(fmt.Sprintf(` data-source-position="%d"`, segment.Start))
 | 
			
		||||
		}
 | 
			
		||||
		var err error
 | 
			
		||||
		if n.IsChecked {
 | 
			
		||||
			_, err = w.WriteString(`<input type="checkbox" disabled="" checked=""` + end)
 | 
			
		||||
		} else {
 | 
			
		||||
			_, err = w.WriteString(`<input type="checkbox" disabled=""` + end)
 | 
			
		||||
			_, _ = w.WriteString(` checked=""`)
 | 
			
		||||
		}
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return ast.WalkStop, err
 | 
			
		||||
		if r.XHTML {
 | 
			
		||||
			_, _ = w.WriteString(` />`)
 | 
			
		||||
		} else {
 | 
			
		||||
			_ = w.WriteByte('>')
 | 
			
		||||
		}
 | 
			
		||||
		fc := n.FirstChild()
 | 
			
		||||
		if fc != nil {
 | 
			
		||||
 
 | 
			
		||||
@@ -166,9 +166,9 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
 | 
			
		||||
<p>(from <a href="https://www.markdownguide.org/extended-syntax/" rel="nofollow">https://www.markdownguide.org/extended-syntax/</a>)</p>
 | 
			
		||||
<h3 id="user-content-checkboxes">Checkboxes</h3>
 | 
			
		||||
<ul>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled=""/>unchecked</li>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled="" checked=""/>checked</li>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled=""/>still unchecked</li>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="434"/>unchecked</li>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="450" checked=""/>checked</li>
 | 
			
		||||
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="464"/>still unchecked</li>
 | 
			
		||||
</ul>
 | 
			
		||||
<h3 id="user-content-definition-list">Definition list</h3>
 | 
			
		||||
<dl>
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ func ReplaceSanitizer() {
 | 
			
		||||
 | 
			
		||||
	// Checkboxes
 | 
			
		||||
	sanitizer.policy.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input")
 | 
			
		||||
	sanitizer.policy.AllowAttrs("checked", "disabled").OnElements("input")
 | 
			
		||||
	sanitizer.policy.AllowAttrs("checked", "disabled", "data-source-position").OnElements("input")
 | 
			
		||||
 | 
			
		||||
	// Custom URL-Schemes
 | 
			
		||||
	if len(setting.Markdown.CustomURLSchemes) > 0 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user