mirror of
https://github.com/docusealco/docuseal
synced 2026-11-10 15:42:32 -05:00
fix text align
This commit is contained in:
1 parent
d2373c1578
commit
033ce3a169
1 file changed
+5
-3
@@ -40,6 +40,8 @@ module Submissions
|
|||||||
|
|
||||||
RTL_REGEXP = TextUtils::RTL_REGEXP
|
RTL_REGEXP = TextUtils::RTL_REGEXP
|
||||||
|
|
||||||
|
TEXT_ALIGNS = %w[left center right justify].freeze
|
||||||
|
TEXT_VALIGNS = %w[top center bottom].freeze
|
||||||
TEXT_LEFT_MARGIN = 1
|
TEXT_LEFT_MARGIN = 1
|
||||||
TEXT_TOP_MARGIN = 1
|
TEXT_TOP_MARGIN = 1
|
||||||
MAX_PAGE_ROTATE = 50
|
MAX_PAGE_ROTATE = 50
|
||||||
@@ -280,10 +282,10 @@ module Submissions
|
|||||||
value = field['default_value'] if field['type'] == 'heading'
|
value = field['default_value'] if field['type'] == 'heading'
|
||||||
value = field['default_value'] if field['type'] == 'strikethrough' && value.nil? && field['conditions'].blank?
|
value = field['default_value'] if field['type'] == 'strikethrough' && value.nil? && field['conditions'].blank?
|
||||||
|
|
||||||
text_align = field.dig('preferences', 'align').to_s.to_sym.presence ||
|
text_align = field.dig('preferences', 'align').to_s.presence_in(TEXT_ALIGNS)&.to_sym ||
|
||||||
(value.to_s.match?(RTL_REGEXP) ? :right : :left)
|
(value.to_s.match?(RTL_REGEXP) ? :right : :left)
|
||||||
|
|
||||||
text_valign = (field.dig('preferences', 'valign').to_s.presence || 'center').to_sym
|
text_valign = (field.dig('preferences', 'valign').to_s.presence_in(TEXT_VALIGNS) || 'center').to_sym
|
||||||
|
|
||||||
layouter = HexaPDF::Layout::TextLayouter.new(text_valign:, text_align:, font:, font_size:)
|
layouter = HexaPDF::Layout::TextLayouter.new(text_valign:, text_align:, font:, font_size:)
|
||||||
|
|
||||||
@@ -597,7 +599,7 @@ module Submissions
|
|||||||
)
|
)
|
||||||
when ->(type) { type == 'cells' && !area['cell_w'].to_f.zero? }
|
when ->(type) { type == 'cells' && !area['cell_w'].to_f.zero? }
|
||||||
cell_width = area['cell_w'] * width
|
cell_width = area['cell_w'] * width
|
||||||
cell_valign = field.dig('preferences', 'valign').to_s.presence || 'center'
|
cell_valign = field.dig('preferences', 'valign').to_s.presence_in(TEXT_VALIGNS) || 'center'
|
||||||
cell_layouter = cell_layouters[cell_valign]
|
cell_layouter = cell_layouters[cell_valign]
|
||||||
|
|
||||||
if (mask = field.dig('preferences', 'mask').presence)
|
if (mask = field.dig('preferences', 'mask').presence)
|
||||||
|
|||||||
Reference in new issue
Block a user