I want to make my string clickable and add hyperlink to string. so wherever display my string is clickable. any suggestions
The Text component in React Native have a onPress as one of its props. You can use it to handle the clicking action.
<Text onPress={()=>{Linking.openURL('https://google.com')}>My Text</Text>
source: https://facebook.github.io/react-native/docs/text#onpress
You can use the react-native-parsed-text library.
Example:
import ParsedText from 'react-native-parsed-text';
class Example extends React.Component {
static displayName = 'Example';
handleUrlPress(url) {
Linking.openURL(url);
}
render() {
return (
<View style={styles.container}>
<ParsedText
style={styles.text}
parse={
[
{type: 'url', style: styles.url, onPress: this.handleUrlPress},
]
}
childrenProps={{allowFontScaling: false}}
>
My text with URL here
</ParsedText>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
url: {
color: 'red',
textDecorationLine: 'underline',
},
});
Here is a link of the library documentation: https://github.com/taskrabbit/react-native-parsed-text
Related
I'm trying to right align text inside a react-navigation v3 sidedrawer.
drawerPosition: "right",
drawerWidth: 280,
contentOptions: {
itemsContainerStyle: {
textAlign: "right", // nope
alignItems: "right" // nope
},
itemStyle: {
textAlign: "right". // nope
},
activeTintColor: "#0ca9dd",
labelStyle: {
fontSize: 18,
alignItems: "right" // nope
textAlign: "right" // nope
},
},
What very simple, basic step am I missing?
how to get pageCount in background object, here is my code.
background: (currentPage, pageCount) => {
if (currentPage === 1) {
return [
{
image: img.coverbg,
height: 521,
width: 756
}
]
}
else if(currentPage == pageCount) {
return [
{
image: img.headbg,
width: 755,
height: 30,
},
]
}
},
i want pageCount in background, but i didnt get that,
i only get currentPage,
so how to get pageCount in background object.
You can use the header and footer functions to access the pageCount parameter.
These functions have three parameters - currentPage, pageCount and pageSize and you can apply any logic and return any valid pdfmake element from these functions.
So essentially, what you're doing in background can be done in either header or footer.
Access current page using currentPage and total page count using pageCount
docDefinition = {
pageMargins: [40, 150, 40, 40],
header: {
margin: 25.5,
columns: [
{
image: logo,
height: 106.4,
width: 540
// alignment: 'center'
}
]
},
footer: function (currentPage, pageCount) {
return [{ text: 'Page ' + currentPage.toString() + ' of ' + pageCount, alignment: 'center' }];
},
content: pdf, //pdf is all the data i use to generate pdf
defaultStyle: {
font: 'Times'
}
}
can't get pageCount in the background object,
we have to find another way for that.
In a custom content type (employees) I have a body field.
In lib\modules\employees\index.js
addFields: [
{
name: 'body',
label: 'Beskrivelse',
type: 'area',
options: {
widgets: {
'apostrophe-rich-text': {
toolbar: ['Bold', 'Italic', 'Link', 'Unlink']
}
}
}
}
]
And in lib\modules\employees-widgets\views\widget.html
{{ apos.singleton(piece, 'body', 'apostrophe-rich-text', {
toolbar: [ 'Bold', 'Italic', 'Link', 'Unlink' ]
})
}}
Editing directly on the page shows the rich text field with toolbar and preview. But in the admin view the toolbar shows, but the preview is not working at all. Look at the images linked bellow:
It looks like this when editing on the page
It looks like this in the admin view
Apostrophe's admin modal CSS is reset, so rich text areas in the modal do not reflect project level styles. This is in an attempt to keep project level styles from interfering with important Apostrophe UI.
You could always add those admin scopes to your project level CSS, just be aware of its reach.
If anyone should have the same question, Stuarts answer is correct (of course). Here is what I added in lib\modules\apostrophe-assets\public\css\site.less to make it work for me. You might want to add more options or adjust to taste :)
.apos-ui {
.apos-rich-text {
h1 {
font-size: 2em;
}
h2 {
font-size: 1.6em;
}
h3 {
font-size: 1.3em;
}
h1,
h2,
h3 {
margin: 1em 0;
font-weight: bold;
}
p {
margin-bottom: 1em;
}
a {
color: darkblue;
}
strong,
b {
font-weight: bold;
}
i,
em {
font-style: italic;
}
}
}
I have a basic Rect shape like this:
var rectShape = new joint.shapes.basic.Rect({
position: { x: 60, y: 10 },
size: { width: 160, height: 35 },
attrs: {
rect: {
fill: '#F5F5F5'
},
text: {
fill: '#FC8A26',
'font-size': 12,
'font-weight': 'bold',
'font-variant': 'small-caps'
}
}
});
I use clone() to create more rectangles like that one:
var rect1 = rectShape.clone().translate(520, 10).attr('text/text','rect1');
I want to have 2 different words inside the rect, one at the size 12 and the other at the size 8. Any idea on how I can do that?
Thank you!
you need to create a custom shape with new SVG markup containing a text element that contains a <tspan> for each word that you want. You could adapt the markup from the standard Rect element. Give each element a different class name, for example replace the <text/> element in the Rect markup with <text><tspan class="word1"/><tspan class="word2"/></text>. The shape definition would look like this:
joint.shapes.my.twoTextRect = joint.shapes.basic.Generic.extend({
markup: '<g class="rotatable"><g class="scalable"><rect/></g><text><tspan class="word1"></tspan> <tspan class="word2"></tspan></text></g>',
defaults: joint.util.deepSupplement({
type: 'my.twoTextRect',
attrs: {
rect: { fill: 'white', stroke: 'black', 'stroke-width': 1, 'follow-scale': true, width: 160, height: 35 },
text: { ref: 'rect' },
'.word1': { 'font-size': 12 },
'.word2': { 'font-size': 8 }
},
size: { width: 160, height: 35 }
}, joint.shapes.basic.Generic.prototype.defaults)
});
Then to create your shape instance:
var rectShape = new joint.shapes.my.twoTextRect();
To set the text of the <tspan> SVG elements you can use
rectShape.attr('.word1/text', 'word 1');
rectShape.attr('.word2/text', 'word 2');
This results in an element that looks like this:
You can clone the element like this:
var clone = rectShape.clone().translate(520, 10).attr({'.word1': {text: 'clone1'}, '.word2': {text: 'clone2' }});
And this makes a new element:
I'm trying to search for a particular field based on what a user searches in a textfield. For instance:
items: [
{ xtype: 'panel', padding: 5, height: 500, width: '35%',
items: [
{ xtype: 'textfield', padding: 5, region: 'west', fieldLabel: 'Criteria 1', itemId: 'criteria_1' }, ...
And here's code from my view class:
store.filter('KBE_ID', '#criteria_1');
I want to return a filtered search that uses the value of my textfield. Could this be done by giving it an itemId?
Get your reference to the field using the itemId, then do the filter using getValue():
var searchField = myPanel.down('#criteria_1');
store.filter('KBE_ID', searchField.getValue());