visualapp

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDocumentJSON

func FormatDocumentJSON(docJSON string) (string, error)

FormatDocumentJSON formats document JSON as PSRT text.

func FormatPageDocumentJSON

func FormatPageDocumentJSON(docJSON, pageName string) (string, error)

FormatPageDocumentJSON formats one page plus document fonts and constants as PSRT.

func MergePageDocumentPSRT

func MergePageDocumentPSRT(fullDocJSON, pageName, psrtText string) (string, error)

MergePageDocumentPSRT applies a page PSRT fragment (page, fonts, consts) into a full document JSON.

func ParseStyleMap

func ParseStyleMap(raw string) (map[string]string, error)

ParseStyleMap parses JSON style object to key-value strings for editor.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App holds editor state for the visual GUI.

func New

func New(emit func(string, interface{})) *App

New creates an App with optional event emitter (Wails runtime).

func (*App) AddConst

func (a *App) AddConst(name, value string) error

AddConst adds constant.

func (*App) AddFont

func (a *App) AddFont(url string) error

AddFont appends a font URL.

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) AddPage

func (a *App) AddPage(name, imageURL, styleJSON string) error

AddPage adds a 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

func (a *App) CompileDocumentHTML() (string, error)

CompileDocumentHTML returns data URI for full HTML (all pages).

func (*App) CompilePageHTML

func (a *App) CompilePageHTML(pageName string) (string, error)

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

func (a *App) CompilePageHTMLFromDocument(docJSON, pageName string) (string, error)

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) EndEdit

func (a *App) EndEdit()

EndEdit finishes a drag session.

func (*App) ExportHTML

func (a *App) ExportHTML() (string, error)

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) FilePath

func (a *App) FilePath() string

FilePath returns the path of the currently open document, if any.

func (*App) FormatDocumentJSON

func (a *App) FormatDocumentJSON(docJSON string) (string, error)

FormatDocumentJSON formats document JSON as PSRT text.

func (*App) FormatPageDocumentJSON

func (a *App) FormatPageDocumentJSON(docJSON, pageName string) (string, error)

func (*App) GetAssetDataURI

func (a *App) GetAssetDataURI(url string) (string, error)

GetAssetDataURI returns a data URI for canvas display.

func (*App) GetDocumentJSON

func (a *App) GetDocumentJSON() (string, error)

GetDocumentJSON returns the in-memory document as JSON.

func (*App) GetDocumentPSRT

func (a *App) GetDocumentPSRT() (string, error)

GetDocumentPSRT returns the current document serialised as PSRT text.

func (*App) GetState

func (a *App) GetState() (UIState, error)

GetState returns current UI state.

func (*App) MergePageDocumentPSRT

func (a *App) MergePageDocumentPSRT(fullDocJSON, pageName, psrtText string) (string, error)

func (*App) MovePage

func (a *App) MovePage(name, ref string, before bool) error

MovePage reorders relative to ref page (before=true places before ref).

func (*App) OpenFile

func (a *App) OpenFile(path string) error

OpenFile loads a PSRT document.

func (*App) ParseDocumentPSRT

func (a *App) ParseDocumentPSRT(text string) (string, error)

ParseDocumentPSRT parses PSRT text and returns document JSON (does not save).

func (*App) PatchMask

func (a *App) PatchMask(pageName string, index int, patch MaskPatch) error

PatchMask applies UI patch to a mask block.

func (*App) PatchPage

func (a *App) PatchPage(patch PagePatch) error

PatchPage updates page properties.

func (*App) PatchText

func (a *App) PatchText(pageName string, index int, patch TextPatch) error

PatchText applies UI patch to a text block.

func (*App) Redo

func (a *App) Redo() error

Redo reapplies undone change.

func (*App) RefreshAssetURL

func (a *App) RefreshAssetURL(url string) error

RefreshAssetURL forces online refresh for url.

func (*App) RefreshPageImage

func (a *App) RefreshPageImage() error

RefreshPageImage refreshes active page background.

func (*App) RemoveConst

func (a *App) RemoveConst(name string) error

RemoveConst removes constant.

func (*App) RemoveFont

func (a *App) RemoveFont(url string) error

RemoveFont removes font URL.

func (*App) RemoveMask

func (a *App) RemoveMask(index int) error

RemoveMask removes mask by index.

func (*App) RemovePage

func (a *App) RemovePage(name string) error

RemovePage removes active or named page.

func (*App) RemoveText

func (a *App) RemoveText(index int) error

RemoveText removes text by index.

func (*App) ReorderText

func (a *App) ReorderText(index, ref int, before bool) error

ReorderText moves text before/after another index.

func (*App) Save

func (a *App) Save() error

Save writes the document to filePath.

func (*App) SaveAs

func (a *App) SaveAs(path string) error

SaveAs saves to a new path.

func (*App) SaveDocumentJSON

func (a *App) SaveDocumentJSON(docJSON string) error

SaveDocumentJSON parses doc JSON, updates memory, and writes the PSRT file.

func (*App) SaveDocumentJSONTo

func (a *App) SaveDocumentJSONTo(docJSON, path string) error

SaveDocumentJSONTo saves doc JSON to path and updates editor cache.

func (*App) SelectText

func (a *App) SelectText(index int)

SelectText selects a text index (-1 clears).

func (*App) SetActivePage

func (a *App) SetActivePage(name string) error

SetActivePage switches the current page.

func (*App) SetAutoCompile

func (a *App) SetAutoCompile(on bool)

SetAutoCompile toggles auto compile.

func (*App) SetDocumentFromPSRT

func (a *App) SetDocumentFromPSRT(text string) error

SetDocumentFromPSRT parses PSRT text and replaces the in-memory document.

func (*App) SetFonts

func (a *App) SetFonts(urls []string) error

SetFonts replaces font list.

func (*App) Undo

func (a *App) Undo() error

Undo reverts last change.

type CompileSVGResult

type CompileSVGResult struct {
	URI                string
	UsedGoTextFallback bool
}

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

type OpenFileResult struct {
	FilePath string `json:"filePath"`
	Document string `json:"document"`
}

OpenFileResult is returned when the user opens a PSRT file.

type PageDetail

type PageDetail struct {
	Name     string `json:"name"`
	ImageURL string `json:"imageUrl"`
	Style    string `json:"style"`
}

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 PageSummary struct {
	Name     string `json:"name"`
	ImageURL string `json:"imageUrl,omitempty"`
}

type TextDetail

type TextDetail struct {
	Index    int     `json:"index"`
	X        float64 `json:"x"`
	Y        float64 `json:"y"`
	Width    float64 `json:"width"`
	TextSize float64 `json:"textSize"`
	Content  string  `json:"content"`
	ImageRef string  `json:"imageRef"`
	Style    string  `json:"style"`
}

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

type VariantPSRT struct {
	Label   string `json:"label"`
	Content string `json:"content"`
}

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.

Jump to

Keyboard shortcuts

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