@@ -2,9 +2,12 @@ from __future__ import annotations
|
||||
from pyWebLayout.core.base import Queriable
|
||||
from pyWebLayout.style import Font
|
||||
from pyWebLayout.style.abstract_style import AbstractStyle
|
||||
from typing import Tuple, Union, List, Optional, Dict, Any
|
||||
from typing import Tuple, Union, List, Optional, Dict, Any, Callable
|
||||
import pyphen
|
||||
|
||||
# Import LinkType for type hints (imported at module level to avoid F821 linting error)
|
||||
from pyWebLayout.abstract.functional import LinkType
|
||||
|
||||
|
||||
|
||||
class Word:
|
||||
@@ -279,7 +282,7 @@ class LinkedWord(Word):
|
||||
"""
|
||||
|
||||
def __init__(self, text: str, style: Union[Font, 'AbstractStyle'],
|
||||
location: str, link_type: 'LinkType' = None,
|
||||
location: str, link_type: Optional['LinkType'] = None,
|
||||
callback: Optional[Callable] = None,
|
||||
background=None, previous: Optional[Word] = None,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
@@ -302,7 +305,6 @@ class LinkedWord(Word):
|
||||
super().__init__(text, style, background, previous)
|
||||
|
||||
# Store link properties
|
||||
from pyWebLayout.abstract.functional import LinkType
|
||||
self._location = location
|
||||
self._link_type = link_type or LinkType.EXTERNAL
|
||||
self._callback = callback
|
||||
@@ -344,8 +346,6 @@ class LinkedWord(Word):
|
||||
Returns:
|
||||
The result of the link execution
|
||||
"""
|
||||
from pyWebLayout.abstract.functional import LinkType
|
||||
|
||||
# Add word text to context
|
||||
full_context = {**self._params, 'text': self._text}
|
||||
if context:
|
||||
|
||||
@@ -387,10 +387,10 @@ class Viewport(Box, Layoutable):
|
||||
}
|
||||
|
||||
|
||||
class ScrollablePageContent(Container):
|
||||
class ScrollablePageContent(Box):
|
||||
"""
|
||||
A specialized container for page content that's designed to work with viewports.
|
||||
This extends the regular Page functionality but allows for much larger content areas.
|
||||
This extends the regular Box functionality but allows for much larger content areas.
|
||||
"""
|
||||
|
||||
def __init__(self, content_width: int = 800, initial_height: int = 1000,
|
||||
|
||||
@@ -9,6 +9,7 @@ from pyWebLayout.abstract import Paragraph, Word, Link
|
||||
from pyWebLayout.abstract.block import Image as AbstractImage
|
||||
from pyWebLayout.abstract.inline import LinkedWord
|
||||
from pyWebLayout.style.concrete_style import ConcreteStyleRegistry, RenderingContext, StyleResolver
|
||||
from pyWebLayout.style import Font, Alignment
|
||||
|
||||
def paragraph_layouter(paragraph: Paragraph, page: Page, start_word: int = 0, pretext: Optional[Text] = None, alignment_override: Optional['Alignment'] = None) -> Tuple[bool, Optional[int], Optional[Text]]:
|
||||
"""
|
||||
@@ -40,7 +41,6 @@ def paragraph_layouter(paragraph: Paragraph, page: Page, start_word: int = 0, pr
|
||||
# paragraph.style is already a Font object (concrete), not AbstractStyle
|
||||
# We need to get word spacing constraints from the Font's abstract style if available
|
||||
# For now, use reasonable defaults based on font size
|
||||
from pyWebLayout.style import Font, Alignment
|
||||
|
||||
if isinstance(paragraph.style, Font):
|
||||
# paragraph.style is already a Font (concrete style)
|
||||
@@ -228,8 +228,6 @@ def image_layouter(image: AbstractImage, page: Page, max_width: Optional[int] =
|
||||
Returns:
|
||||
bool: True if image was successfully laid out, False if page ran out of space
|
||||
"""
|
||||
from pyWebLayout.style import Alignment
|
||||
|
||||
# Use page available width if max_width not specified
|
||||
if max_width is None:
|
||||
max_width = page.available_width
|
||||
|
||||
Reference in New Issue
Block a user