This commit is contained in:
Fabio Pliger
2024-02-12 14:47:36 -06:00
parent ae3c36b5dd
commit 83d17a75ba
13 changed files with 74 additions and 22 deletions

View File

@@ -1,8 +1,9 @@
from textwrap import dedent
from pyscript import document, when, window
from pyweb import JSProperty, js_property, pydom
from pyscript import document, when, window
# Global attributes that all elements have (this list is a subset of the official one)
# and tries to capture the most used ones
GLOBAL_ATTRIBUTES = [
@@ -28,19 +29,47 @@ GLOBAL_ATTRIBUTES = [
# class and style are different ones that are handled by pydom.element directly
CUSTOM_ATTRIBUTES = {
'a': ['download', 'href', 'referrerpolicy', 'rel', 'target', 'type'],
'td': ['colspan', 'headers', 'rowspan'],
'template': ['shadowrootmode'],
'textarea': ['autocapitalize', 'autocomplete', 'autofocus', 'cols', 'dirname', 'disabled',
'form', 'maxlength', 'minlength', 'name', 'placeholder', 'readonly',
'required', 'rows', 'spellcheck', 'wrap'],
'tr': ['abbr', 'colspan', 'headers', 'rowspan', 'scope'],
'time': ['datetime'],
'video': ['autoplay', 'controls', 'crossorigin', 'disablepictureinpicture',
'disableremoteplayback', 'height', 'loop', 'muted', 'playsinline',
'poster', 'preload', 'src', 'width'],
"a": ["download", "href", "referrerpolicy", "rel", "target", "type"],
"td": ["colspan", "headers", "rowspan"],
"template": ["shadowrootmode"],
"textarea": [
"autocapitalize",
"autocomplete",
"autofocus",
"cols",
"dirname",
"disabled",
"form",
"maxlength",
"minlength",
"name",
"placeholder",
"readonly",
"required",
"rows",
"spellcheck",
"wrap",
],
"tr": ["abbr", "colspan", "headers", "rowspan", "scope"],
"time": ["datetime"],
"video": [
"autoplay",
"controls",
"crossorigin",
"disablepictureinpicture",
"disableremoteplayback",
"height",
"loop",
"muted",
"playsinline",
"poster",
"preload",
"src",
"width",
],
}
class ElementBase(pydom.Element):
tag = "div"
@@ -491,8 +520,19 @@ class iframe(TextElementBase):
# code tags only have the global attributes ones
_add_js_properties(iframe, "allow", "allowfullscreen", "height", "loading", "name",
"referrerpolicy", "sandbox", "src", "srcdoc", "width")
_add_js_properties(
iframe,
"allow",
"allowfullscreen",
"height",
"loading",
"name",
"referrerpolicy",
"sandbox",
"src",
"srcdoc",
"width",
)
class img(ElementBase):

View File

@@ -1,8 +1,9 @@
"""Markdown module to generate web/HTML components from Markdown code"""
from pyscript import document, window
from pyweb import pydom
from pyweb.ui.elements import TextElementBase, script
from pyscript import document, window
class markdown(TextElementBase):
"""Markdown component to render HTML from Markdown code"""

View File

@@ -1,10 +1,11 @@
import string
from textwrap import dedent
from pyscript import document, when, window
from pyweb import JSProperty, js_property, pydom
from pyweb.ui import elements as el
from pyscript import document, when, window
class ShoeBase(pydom.Element):
tag = "div"