|
| 1 | +const types = ['char', 'word', 'wordws', 'sentence', 'line']; |
| 2 | +const deltas = ['both', 'added', 'removed']; |
| 3 | +const sameText = 'The sun is shining brightly. Birds are singing in the trees.'; |
| 4 | +const beforeText = 'The quick brown fox jumps over the lazy dog. It lands softly and runs away.\n' + sameText; |
| 5 | +const afterText = 'A quick brown fox jumped over a lazy dog. It landed softly, then ran away.\n' + sameText; |
| 6 | + |
| 7 | +export default { |
| 8 | + demo: { |
| 9 | + view: 'text-diff', |
| 10 | + before: 'Hello world!', |
| 11 | + after: 'Hello Discovery.js!' |
| 12 | + }, |
| 13 | + examples: [ |
| 14 | + { |
| 15 | + title: 'Types', |
| 16 | + demoData: types.map(type => ({ type, before: beforeText, after: afterText })), |
| 17 | + demo: { |
| 18 | + view: 'table', |
| 19 | + cols: [ |
| 20 | + { header: 'Type', content: ['text:type', { view: 'text', when: 'type="wordws"', text: ' (default)' }] }, |
| 21 | + { header: 'Preview', content: 'text-diff{ type }' } |
| 22 | + // { header: 'Example', content: { view: 'source', syntax: 'discovery-view', source: '=`{ view: "text-diff", type: "${type}" }`', lineNum: false } } |
| 23 | + ] |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + title: 'Delta kinds', |
| 28 | + demoData: deltas.map(delta => ({ delta, before: beforeText, after: afterText })), |
| 29 | + demo: { |
| 30 | + view: 'table', |
| 31 | + cols: [ |
| 32 | + { header: 'Type', content: ['text:delta', { view: 'text', when: 'delta="both"', text: ' (default)' }] }, |
| 33 | + { header: 'Preview', content: 'text-diff{ delta }' } |
| 34 | + // { header: 'Example', content: { view: 'source', syntax: 'discovery-view', source: '=`{ view: "text-diff", delta: "${delta}" }`', lineNum: false } } |
| 35 | + ] |
| 36 | + } |
| 37 | + } |
| 38 | + ] |
| 39 | +}; |
0 commit comments