embed.go 909 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package richeditor
  2. import (
  3. "bytes"
  4. "embed"
  5. "fmt"
  6. "github.com/qor5/ui/redactor"
  7. "github.com/qor5/web"
  8. )
  9. //go:embed redactor
  10. var box embed.FS
  11. func JSComponentsPack() web.ComponentsPack {
  12. var js [][]byte
  13. js = append(js, []byte(redactor.JSComponentsPack()))
  14. for _, p := range Plugins {
  15. pj, err := box.ReadFile(fmt.Sprintf("redactor/%s.min.js", p))
  16. if err != nil {
  17. continue
  18. }
  19. js = append(js, pj)
  20. }
  21. if len(PluginsJS) > 0 {
  22. js = append(js, PluginsJS...)
  23. }
  24. return web.ComponentsPack(bytes.Join(js, []byte("\n\n")))
  25. }
  26. func CSSComponentsPack() web.ComponentsPack {
  27. var css [][]byte
  28. css = append(css, []byte(redactor.CSSComponentsPack()))
  29. custom, err := box.ReadFile("redactor/redactor.custom.css")
  30. if err != nil {
  31. panic(err)
  32. }
  33. css = append(css, custom)
  34. if len(PluginsCSS) > 0 {
  35. css = append(css, PluginsCSS...)
  36. }
  37. return web.ComponentsPack(bytes.Join(css, []byte("\n\n")))
  38. }