Copy link to clipboard
Copied
I am trying to run the following code in the JavaScript editor in Adobe Acrobat Pro DC.
const
getPathes = ({ value = '', sub }) => sub
? Object
.entries(sub)
.flatMap(([k, v]) => getPathes(v).map(([p, s]) => [k + (p && '.') + p, value + (value && '') + s]))
: [['', value]],
input = [["1", "I can "], ["1.1", "speak "], ["1.1.1", "English."], ["1.1.2", "Chinese "], ["1.1.2.1", "well."], ["1.2", "eat noodles."], ["1.3", "play football."], ["2", "I "], ["2.1", "drink."], ["2.2", "sleep."], ["3", "I am the man."], ["4", "Hire me."]],
tree = input.reduce((t, [path, value]) => {
path.split('.').reduce((o, k) => (o.sub ??= {})[k] ??= {}, t).value = value;
return t;
}, {}),
result = getPathes(tree);
console.log(result);The problem is:
It runs flawlessly in JSFiddle. But shows a "SyntaxError: missing : after property id" message in Acrobat Pro DC.
What is going wrong here? How can I correct the syntax?
Copy link to clipboard
Copied
You seem to be using very modern JavaScript syntax not understood by Acrobat, based on an older JavaScript engine.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more