mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
exposed text property (#4989)
This commit is contained in:
parent
7bf260b7fb
commit
547a9cd6cc
2 changed files with 19 additions and 3 deletions
|
|
@ -1,7 +1,15 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
export const Text = function Text({ height, properties, styles, darkMode, registerAction, component }) {
|
||||
export const Text = function Text({
|
||||
height,
|
||||
properties,
|
||||
styles,
|
||||
darkMode,
|
||||
registerAction,
|
||||
component,
|
||||
setExposedVariable,
|
||||
}) {
|
||||
let {
|
||||
textSize,
|
||||
textColor,
|
||||
|
|
@ -29,12 +37,18 @@ export const Text = function Text({ height, properties, styles, darkMode, regist
|
|||
}, [styles.visibility]);
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useEffect(() => setText(() => computeText()), [properties.text]);
|
||||
useEffect(() => {
|
||||
const text = computeText();
|
||||
setText(text);
|
||||
setExposedVariable('text', text);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [properties.text]);
|
||||
|
||||
registerAction(
|
||||
'setText',
|
||||
async function (text) {
|
||||
setText(text);
|
||||
setExposedVariable('text', text);
|
||||
},
|
||||
[setText]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1956,7 +1956,9 @@ export const widgets = [
|
|||
},
|
||||
},
|
||||
},
|
||||
exposedVariables: {},
|
||||
exposedVariables: {
|
||||
text: 'Hello, there!',
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
handle: 'setText',
|
||||
|
|
|
|||
Loading…
Reference in a new issue