Documentation
¶
Index ¶
- func FormatDocumentJSON(docJSON string) (string, error)
- func FormatPageDocumentJSON(docJSON, pageName string) (string, error)
- func MergePageDocumentPSRT(fullDocJSON, pageName, psrtText string) (string, error)
- func ParseStyleMap(raw string) (map[string]string, error)
- type App
- func (a *App) AddConst(name, value string) error
- func (a *App) AddFont(url string) error
- func (a *App) AddMaskBlock(index int, x, y, width, height float64, styleJSON, imageRef string) error
- func (a *App) AddPage(name, imageURL, styleJSON string) error
- func (a *App) AddTextBlock(index int, x, y, width, textSize float64, content, styleJSON, imageRef string) error
- func (a *App) BeginEdit()
- func (a *App) CompileDocumentHTML() (string, error)
- func (a *App) CompilePageHTML(pageName string) (string, error)
- func (a *App) CompilePageHTMLFromDocument(docJSON, pageName string) (string, error)
- func (a *App) CompilePageSVG(pageName string) (CompileSVGResult, error)
- func (a *App) CompilePageSVGFromDocument(docJSON, pageName string) (CompileSVGResult, error)
- func (a *App) EndEdit()
- func (a *App) ExportHTML() (string, error)
- func (a *App) ExportHTMLFromDocument(docJSON, dir, baseName string, morePaths []string, morePSRT []VariantPSRT) (string, error)
- func (a *App) ExportSVG(dir string) (CompileSVGResult, error)
- func (a *App) ExportSVGFromDocument(docJSON, parentDir, baseName string) (CompileSVGResult, error)
- func (a *App) FilePath() string
- func (a *App) FormatDocumentJSON(docJSON string) (string, error)
- func (a *App) FormatPageDocumentJSON(docJSON, pageName string) (string, error)
- func (a *App) GetAssetDataURI(url string) (string, error)
- func (a *App) GetDocumentJSON() (string, error)
- func (a *App) GetDocumentPSRT() (string, error)
- func (a *App) GetState() (UIState, error)
- func (a *App) MergePageDocumentPSRT(fullDocJSON, pageName, psrtText string) (string, error)
- func (a *App) MovePage(name, ref string, before bool) error
- func (a *App) OpenFile(path string) error
- func (a *App) ParseDocumentPSRT(text string) (string, error)
- func (a *App) PatchMask(pageName string, index int, patch MaskPatch) error
- func (a *App) PatchPage(patch PagePatch) error
- func (a *App) PatchText(pageName string, index int, patch TextPatch) error
- func (a *App) Redo() error
- func (a *App) RefreshAssetURL(url string) error
- func (a *App) RefreshPageImage() error
- func (a *App) RemoveConst(name string) error
- func (a *App) RemoveFont(url string) error
- func (a *App) RemoveMask(index int) error
- func (a *App) RemovePage(name string) error
- func (a *App) RemoveText(index int) error
- func (a *App) ReorderText(index, ref int, before bool) error
- func (a *App) Save() error
- func (a *App) SaveAs(path string) error
- func (a *App) SaveDocumentJSON(docJSON string) error
- func (a *App) SaveDocumentJSONTo(docJSON, path string) error
- func (a *App) SelectText(index int)
- func (a *App) SetActivePage(name string) error
- func (a *App) SetAutoCompile(on bool)
- func (a *App) SetDocumentFromPSRT(text string) error
- func (a *App) SetFonts(urls []string) error
- func (a *App) Undo() error
- type CompileSVGResult
- type MaskDetail
- type MaskPatch
- type OpenFileResult
- type PageDetail
- type PagePatch
- type PageSummary
- type TextDetail
- type TextPatch
- type UIState
- type VariantPSRT
- type WebEntryStyleInput
- type WebPreviewStyle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDocumentJSON ¶
FormatDocumentJSON formats document JSON as PSRT text.
func FormatPageDocumentJSON ¶
FormatPageDocumentJSON formats one page plus document fonts and constants as PSRT.
func MergePageDocumentPSRT ¶
MergePageDocumentPSRT applies a page PSRT fragment (page, fonts, consts) into a full document JSON.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App holds editor state for the visual GUI.
func (*App) AddMaskBlock ¶
func (a *App) AddMaskBlock(index int, x, y, width, height float64, styleJSON, imageRef string) error
AddMaskBlock adds a new mask on active page.
func (*App) AddTextBlock ¶
func (a *App) AddTextBlock(index int, x, y, width, textSize float64, content, styleJSON, imageRef string) error
AddTextBlock adds a new text on active page.
func (*App) BeginEdit ¶
func (a *App) BeginEdit()
BeginEdit starts a drag session (single undo snapshot).
func (*App) CompileDocumentHTML ¶
CompileDocumentHTML returns data URI for full HTML (all pages).
func (*App) CompilePageHTML ¶
CompilePageHTML writes an intermediate single-page .psrt under the cache preview/ dir and returns a data URI for HTML compiled from that page only.
func (*App) CompilePageHTMLFromDocument ¶
CompilePageHTMLFromDocument compiles one page HTML from document JSON (editor state).
func (*App) CompilePageSVG ¶
func (a *App) CompilePageSVG(pageName string) (CompileSVGResult, error)
CompilePageSVG returns a data URI for the current page SVG.
func (*App) CompilePageSVGFromDocument ¶
func (a *App) CompilePageSVGFromDocument(docJSON, pageName string) (CompileSVGResult, error)
CompilePageSVGFromDocument compiles one page SVG from document JSON (editor state).
func (*App) ExportHTML ¶
ExportHTML writes HTML next to psrt file.
func (*App) ExportHTMLFromDocument ¶
func (a *App) ExportHTMLFromDocument(docJSON, dir, baseName string, morePaths []string, morePSRT []VariantPSRT) (string, error)
ExportHTMLFromDocument writes a single HTML file into dir as baseName.html. morePaths are additional .psrt files; morePSRT are variants read in the UI when paths are unavailable.
func (*App) ExportSVG ¶
func (a *App) ExportSVG(dir string) (CompileSVGResult, error)
ExportSVG writes all page SVGs to dir.
func (*App) ExportSVGFromDocument ¶
func (a *App) ExportSVGFromDocument(docJSON, parentDir, baseName string) (CompileSVGResult, error)
ExportSVGFromDocument writes one SVG per page into parentDir/baseName/.
func (*App) FormatDocumentJSON ¶
FormatDocumentJSON formats document JSON as PSRT text.
func (*App) FormatPageDocumentJSON ¶
func (*App) GetAssetDataURI ¶
GetAssetDataURI returns a data URI for canvas display.
func (*App) GetDocumentJSON ¶
GetDocumentJSON returns the in-memory document as JSON.
func (*App) GetDocumentPSRT ¶
GetDocumentPSRT returns the current document serialised as PSRT text.
func (*App) MergePageDocumentPSRT ¶
func (*App) ParseDocumentPSRT ¶
ParseDocumentPSRT parses PSRT text and returns document JSON (does not save).
func (*App) RefreshAssetURL ¶
RefreshAssetURL forces online refresh for url.
func (*App) RefreshPageImage ¶
RefreshPageImage refreshes active page background.
func (*App) RemoveConst ¶
RemoveConst removes constant.
func (*App) RemoveMask ¶
RemoveMask removes mask by index.
func (*App) RemovePage ¶
RemovePage removes active or named page.
func (*App) RemoveText ¶
RemoveText removes text by index.
func (*App) ReorderText ¶
ReorderText moves text before/after another index.
func (*App) SaveDocumentJSON ¶
SaveDocumentJSON parses doc JSON, updates memory, and writes the PSRT file.
func (*App) SaveDocumentJSONTo ¶
SaveDocumentJSONTo saves doc JSON to path and updates editor cache.
func (*App) SelectText ¶
SelectText selects a text index (-1 clears).
func (*App) SetActivePage ¶
SetActivePage switches the current page.
func (*App) SetAutoCompile ¶
SetAutoCompile toggles auto compile.
func (*App) SetDocumentFromPSRT ¶
SetDocumentFromPSRT parses PSRT text and replaces the in-memory document.
type CompileSVGResult ¶
CompileSVGResult is returned when compiling page SVG for preview or export.
type MaskDetail ¶
type MaskDetail struct {
Index int `json:"index"`
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
ImageRef string `json:"imageRef"`
Style string `json:"style"`
}
MaskDetail is a static == block for the UI.
type MaskPatch ¶
type MaskPatch struct {
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
Width *float64 `json:"width,omitempty"`
Height *float64 `json:"height,omitempty"`
ImageRef *string `json:"imageRef,omitempty"`
StyleSet map[string]string `json:"styleSet,omitempty"`
StyleRemove []string `json:"styleRemove,omitempty"`
}
MaskPatch updates a mask block from the UI.
type OpenFileResult ¶
OpenFileResult is returned when the user opens a PSRT file.
type PageDetail ¶
type PagePatch ¶
type PagePatch struct {
Name *string `json:"name,omitempty"`
ImageURL *string `json:"imageUrl,omitempty"`
StyleSet map[string]string `json:"styleSet,omitempty"`
StyleRemove []string `json:"styleRemove,omitempty"`
}
PagePatch updates page fields.
type PageSummary ¶
type TextDetail ¶
type TextPatch ¶
type TextPatch struct {
Content *string `json:"content,omitempty"`
Append bool `json:"append"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
Width *float64 `json:"width,omitempty"`
TextSize *float64 `json:"textSize,omitempty"`
ImageRef *string `json:"imageRef,omitempty"`
StyleSet map[string]string `json:"styleSet,omitempty"`
StyleRemove []string `json:"styleRemove,omitempty"`
}
TextPatch updates a text block from the UI.
type UIState ¶
type UIState struct {
FilePath string `json:"filePath"`
ActivePage string `json:"activePage"`
SelectedIndex int `json:"selectedIndex"` // -1 none
Pages []PageSummary `json:"pages"`
Page *PageDetail `json:"page,omitempty"`
Texts []TextDetail `json:"texts,omitempty"`
Masks []MaskDetail `json:"masks,omitempty"`
Text *TextDetail `json:"text,omitempty"`
Mask *MaskDetail `json:"mask,omitempty"`
Fonts []string `json:"fonts"`
Consts map[string]string `json:"consts"`
AutoCompile bool `json:"autoCompile"`
}
UIState is sent to the frontend after changes.
type VariantPSRT ¶
VariantPSRT is extra PSRT text bundled into HTML export (from file picker when paths are unavailable).
type WebEntryStyleInput ¶
type WebEntryStyleInput struct {
Index int `json:"index"`
Style string `json:"style"`
Content string `json:"content"`
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
TextSize float64 `json:"textSize"`
Height float64 `json:"height,omitempty"`
IsMask bool `json:"isMask,omitempty"`
}
WebEntryStyleInput identifies one text or mask block for batch adaptation.
type WebPreviewStyle ¶
type WebPreviewStyle = styleadapter.WebPreviewStyle
WebPreviewStyle is adapted CSS for one text block in the web preview.
func AdaptEntriesForWeb ¶
func AdaptEntriesForWeb(entriesJSON string, canvasW, canvasH int, zoom float64) ([]WebPreviewStyle, error)
AdaptEntriesForWeb adapts all text entries for the web preview in one call.
func AdaptTextStyleForWeb ¶
func AdaptTextStyleForWeb( styleJSON string, content string, x, y, width, textSize float64, canvasW, canvasH int, zoom float64, ) WebPreviewStyle
AdaptTextStyleForWeb adapts a single text style for the web preview.