Help us shape the future of Go! Take the 2026 Go Developer Survey

editkind

package
v0.56.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package editkind is the server's one answer to "how is this file edited": as text (the built-in editor, saved through save-text), in the document server (ONLYOFFICE), or not at all here.

⚠⚠ Why one package (filex #211, audit B2). The question was answered in seven places: two lists in the server (the ONLYOFFICE document types, and save-text's "is this text" rule) and five in the clients (the explorer's two office lists, the preview's editable list, the desktop's "open with" list, the text-mime list). They had already drifted: the preview offered Edit on `.graphql` and `.mmd`, which save-text then refused with a 415, while `.properties`, `.lua` or a `Makefile` - which save-text accepts - got no Edit at all, and `.docm`/`.xlsm`/`.pptm` were not office documents to the explorer. Now the rule lives here, the server publishes it (`/api/files/capabilities` → `edit_kinds`), and the clients read that.

The two rules are consistent by construction: a type the built-in editor saves as text is never also an office document (`.txt`, `.csv`, `.html` and `.xml` are things ONLYOFFICE can open, but filex opens them as text), and a fixed-layout format the document server only displays (`.pdf`, `.xps`, `.epub`) is not an office document either - filex has its own viewers for those.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocumentType

func DocumentType(ext string) string

DocumentType returns "word", "cell", "slide", or "" for an extension (with or without its dot): ONLYOFFICE's own mapping of what it opens. Unknown returns "" so callers can 415.

func Office

func Office(name string) bool

Office reports whether a file opens in the document server, by its name.

func OfficeExt

func OfficeExt(ext string) bool

OfficeExt reports whether files of this extension (with or without its dot) open in the document server as office documents.

func TextEditable

func TextEditable(name string) bool

TextEditable reports whether a file is saved as text by its NAME: its extension, or a name that is text on its own (`Makefile`, `.gitignore`).

func TextualMime

func TextualMime(m string) bool

TextualMime reports whether a media type is text a person edits as text: any text/*, and the structured-text types filed under application/. It answers for a name that says nothing (`LICENSE`, `example.custom`, #56).

Types

type Kinds

type Kinds struct {
	// Office: the extensions the document server opens and edits.
	Office []string `json:"office"`
	// Text: the extensions the built-in editor opens and save-text saves.
	Text []string `json:"text"`
	// TextNames: whole file names (lower case) that are text by name.
	TextNames []string `json:"text_names"`
	// TextMimePrefixes and TextMimes: the media types that make a file whose
	// name says nothing text (`text/` and the structured ones).
	TextMimePrefixes []string `json:"text_mime_prefixes"`
	TextMimes        []string `json:"text_mimes"`
}

Kinds is the rule as `/api/files/capabilities` publishes it (`edit_kinds`): lists the clients look a file up in, instead of lists of their own.

func Published

func Published() Kinds

Published is the rule, sorted, as clients read it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL