def newTextSpan(contents, styleMap): styleAttrs = [ Schema.StyleAttr( name=n, value=v ) for n, v in styleMap.items() if v is not None ] m = TextSpanEditor.newTextSpanModel( ParagraphEditor._textToModel( contents ), styleAttrs ) return TextSpanEditor( None, m, contents )
def setStyleAttrs(self, styleMap): spanAttrs = RichTextAttributes.fromValues({n: v for n, v in styleMap.items()}, None) modelAttrs = [ Schema.StyleAttr( name=n, value=v ) for n, v in styleMap.items() ] self._model['styleAttrs'] = modelAttrs self._editorModel.setSpanAttrs( spanAttrs )