-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/ops/base/Ops.Dev.Html.ElementCssFont/Ops.Dev.Html.ElementCssFont.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const | ||
inEle = op.inObject("Element"), | ||
inSize = op.inFloat("Text Size", 12), | ||
inFamily = op.inString("Font Family", "sans serif"), | ||
inAlign = op.inSwitch("Text Align", ["Left", "Center", "Right"], "Left"), | ||
inWeight = op.inString("Font Weight", "normal"), | ||
inLineHeight = op.inFloat("Line Height", 0), | ||
// in1 = op.inSwitch("White Space",["Initial","no-wrap"], "Initial"), | ||
outEle = op.outObject("HTML Element"); | ||
|
||
let ele = null; | ||
|
||
inEle.onChange = | ||
inEle.onLinkChanged = | ||
inFamily.onChange = | ||
inSize.onChange = | ||
inWeight.onChange = | ||
inAlign.onChange = | ||
inLineHeight.onChange = | ||
update; | ||
|
||
op.onDelete = remove; | ||
|
||
function remove() | ||
{ | ||
if (!ele) return; | ||
ele.style.removeProperty("font-family"); | ||
ele.style.removeProperty("font-size"); | ||
} | ||
|
||
function update() | ||
{ | ||
remove(); | ||
ele = inEle.get(); | ||
|
||
if (ele && ele.style) | ||
{ | ||
ele.style["font-family"] = inFamily.get(); | ||
ele.style["font-weight"] = inWeight.get(); | ||
ele.style["text-align"] = inAlign.get().toLowerCase(); | ||
|
||
if (inSize.get())ele.style["font-size"] = inSize.get() + "px"; | ||
else ele.style["font-size"] = ""; | ||
|
||
if (inLineHeight.get()) ele.style["line-height"] = inLineHeight.get() + "px"; | ||
else ele.style["line-height"] = ""; | ||
} | ||
else | ||
{ | ||
setTimeout(update, 50); | ||
} | ||
|
||
if (outEle != inEle.get()) | ||
outEle.setRef(inEle.get()); | ||
} |
74 changes: 74 additions & 0 deletions
74
src/ops/base/Ops.Dev.Html.ElementCssFont/Ops.Dev.Html.ElementCssFont.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"id": "8413b842-6b92-487e-b74b-da3c0259bd08", | ||
"created": 1723570981057, | ||
"license": "MIT", | ||
"authorName": "pandur", | ||
"changelog": [ | ||
{ | ||
"message": "op created", | ||
"type": "new op", | ||
"author": "pandur", | ||
"date": 1723570293627 | ||
}, | ||
{ | ||
"message": "Ops.Patch.P14nxll.CssPad2 renamed to Ops.Dev.Html.ElementCssPadding", | ||
"type": "rename", | ||
"author": "pandur", | ||
"date": 1723570447775 | ||
}, | ||
{ | ||
"message": "op created", | ||
"type": "new op", | ||
"author": "pandur", | ||
"date": 1723570981057 | ||
}, | ||
{ | ||
"message": "Ops.Patch.PU99Vll.ElementCssFont renamed to Ops.Dev.Html.ElementCssFont", | ||
"type": "rename", | ||
"author": "pandur", | ||
"date": 1723571628645 | ||
} | ||
], | ||
"layout": { | ||
"portsIn": [ | ||
{ | ||
"type": 2, | ||
"name": "Element" | ||
}, | ||
{ | ||
"type": 0, | ||
"name": "Text Size", | ||
"subType": "number" | ||
}, | ||
{ | ||
"type": 5, | ||
"name": "Font Family" | ||
}, | ||
{ | ||
"type": 0, | ||
"name": "Text Align index", | ||
"values": [ | ||
"Left", | ||
"Center", | ||
"Right" | ||
], | ||
"subType": "integer" | ||
}, | ||
{ | ||
"type": 5, | ||
"name": "Font Weight" | ||
}, | ||
{ | ||
"type": 0, | ||
"name": "Line Height", | ||
"subType": "number" | ||
} | ||
], | ||
"portsOut": [ | ||
{ | ||
"type": 2, | ||
"name": "HTML Element" | ||
} | ||
] | ||
} | ||
} |