panda-editor 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b5dd5e6612814d60e6112793b8de4673c48d465cbd43c327b2ca5d1b69af42f
4
- data.tar.gz: 5b68f6606d59c3dbcd68395cb40efcd0cb68d1d54f1c52a9b50a9b4ff235e5d5
3
+ metadata.gz: e06bc9641c74fd7f82f7a717d06c27cdd3be74588d90a8c021a4a3e86d328d3f
4
+ data.tar.gz: 057e222ba876c8139017766d85ad2ebfc8fda725cbe4483a2bb430b4c8d3d986
5
5
  SHA512:
6
- metadata.gz: 7d289881c3a87f4ed4094e795a5abc2b62f191b8474ee8d22dacbd89e02ba0bfa799ff76d562d971e7e08e01ef20c3b27a9c99d32cc19868b68e83623f44d0d4
7
- data.tar.gz: eecf90ed4f1a54db8321c35372ebb57e9ac00b1b86952fb2f9ab6567fcdeeb5cee514111fdee5912f093a09930b525df7bf3b1a85b1c856fe4e8268d42222d66
6
+ metadata.gz: 12dd001742255b97b60588f2bf5108c502d2d9b076272a3c323642b1ee7320dd0919cd4fa96d386e17a3e985f6d9a768a3eff5b6a9310eadfab22be1c2818461
7
+ data.tar.gz: 2f2482087b208e2086bf95d8d18fe7e0be85104d5342a0482ef53944a32b25e9ec3fefe8913e9cec62647a8067bd8879117c0e7807410137a50d3d4d44520a49
@@ -17,6 +17,9 @@ if (window.PANDA_CMS_EDITOR_JS_RESOURCES) {
17
17
  export const EDITOR_JS_CSS = `
18
18
  .codex-editor {
19
19
  position: relative;
20
+ border: 1px solid #e5e7eb;
21
+ border-radius: 0.75rem;
22
+ overflow: hidden;
20
23
  }
21
24
  .codex-editor::before {
22
25
  content: '';
@@ -68,7 +71,12 @@ export const EDITOR_JS_CSS = `
68
71
  .ce-header h6 { font-size: 0.67em; }
69
72
 
70
73
  .codex-editor__redactor {
71
- padding-bottom: 150px !important;
74
+ padding-bottom: 10px !important;
75
+ min-height: 50px !important;
76
+ }
77
+ /* Add more padding for empty or short editors to provide clickable space */
78
+ .codex-editor__redactor:has(.ce-block:only-child) {
79
+ padding-bottom: 50px !important;
72
80
  min-height: 100px !important;
73
81
  }
74
82
  /* Base toolbar styles */
@@ -174,7 +182,7 @@ export const EDITOR_JS_CSS = `
174
182
 
175
183
  /* Ensure last block has bottom spacing */
176
184
  .ce-block:last-child {
177
- padding-bottom: 2em;
185
+ padding-bottom: 1em;
178
186
  }
179
187
 
180
188
  /* Reset all block type margins */
@@ -0,0 +1,42 @@
1
+ /**
2
+ * UTF-8 safe Base64 encoding/decoding helpers
3
+ *
4
+ * Standard JavaScript atob/btoa functions don't handle UTF-8 multi-byte
5
+ * characters correctly. They treat each byte as a single Latin-1 character,
6
+ * which causes "mojibake" corruption for characters like em-dash (—),
7
+ * curly quotes, and non-ASCII text.
8
+ *
9
+ * These helpers properly encode strings to UTF-8 bytes before Base64 encoding,
10
+ * and properly decode UTF-8 bytes after Base64 decoding.
11
+ */
12
+
13
+ /**
14
+ * Encode a string to Base64, properly handling UTF-8 multi-byte characters
15
+ * @param {string} str - The string to encode
16
+ * @returns {string} Base64 encoded string
17
+ */
18
+ export function base64EncodeUTF8(str) {
19
+ // First encode to UTF-8 using encodeURIComponent (which produces %XX sequences)
20
+ // Then convert those sequences back to bytes for btoa
21
+ return btoa(
22
+ encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1) =>
23
+ String.fromCharCode(parseInt(p1, 16))
24
+ )
25
+ )
26
+ }
27
+
28
+ /**
29
+ * Decode a Base64 string, properly handling UTF-8 multi-byte characters
30
+ * @param {string} str - The Base64 string to decode
31
+ * @returns {string} Decoded UTF-8 string
32
+ */
33
+ export function base64DecodeUTF8(str) {
34
+ // First decode Base64 to bytes, then convert each byte to a %XX sequence
35
+ // and use decodeURIComponent to properly decode UTF-8
36
+ return decodeURIComponent(
37
+ atob(str)
38
+ .split('')
39
+ .map((c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
40
+ .join('')
41
+ )
42
+ }
data/config/importmap.rb CHANGED
@@ -14,6 +14,7 @@ pin "panda/editor/resource_loader", to: "/panda/editor/resource_loader.js"
14
14
  pin "panda/editor/plain_text_editor", to: "/panda/editor/plain_text_editor.js"
15
15
  pin "panda/editor/css_extractor", to: "/panda/editor/css_extractor.js"
16
16
  pin "panda/editor/rich_text_editor", to: "/panda/editor/rich_text_editor.js"
17
+ pin "panda/editor/encoding", to: "/panda/editor/encoding.js"
17
18
 
18
19
  # EditorJS Core and plugins (from esm.sh - better ES module handling than jsdelivr)
19
20
  pin "@editorjs/editorjs", to: "https://esm.sh/@editorjs/editorjs@2.28.2"
@@ -24,7 +24,7 @@ module Panda
24
24
  when "success" then "bg-green-100 text-green-800"
25
25
  when "danger" then "bg-red-100 text-red-800"
26
26
  when "warning" then "bg-yellow-100 text-yellow-800"
27
- when "info" then "bg-indigo-100 text-indigo-800"
27
+ when "info" then "bg-sky-100 text-sky-800"
28
28
  else "bg-blue-100 text-blue-800"
29
29
  end
30
30
  end
@@ -48,7 +48,7 @@ Panda::Core::ModuleRegistry.register(
48
48
  engine: "Panda::Editor::Engine",
49
49
  paths: {
50
50
  views: "app/views/panda/editor/**/*.erb",
51
- components: "app/components/panda/editor/**/*.rb",
51
+ components: "app/components/panda/editor/**/*.{rb,erb,js}",
52
52
  javascripts: "app/javascript/panda/editor/**/*.js"
53
53
  }
54
54
  )
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Panda
4
4
  module Editor
5
- VERSION = "0.8.2"
5
+ VERSION = "0.8.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Otaina Limited
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-01-01 00:00:00.000000000 Z
12
+ date: 2026-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable
@@ -156,6 +156,7 @@ files:
156
156
  - app/javascript/panda/editor/css_extractor.js
157
157
  - app/javascript/panda/editor/editor_js_config.js
158
158
  - app/javascript/panda/editor/editor_js_initializer.js
159
+ - app/javascript/panda/editor/encoding.js
159
160
  - app/javascript/panda/editor/plain_text_editor.js
160
161
  - app/javascript/panda/editor/plugins/embed.min.js
161
162
  - app/javascript/panda/editor/plugins/header.min.js