Skip to content

Commit 09eafc6

Browse files
author
Dylan Just
committed
dom elements
1 parent 6c7a21e commit 09eafc6

7 files changed

Lines changed: 43 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"homepage": "https://github.com/tinymce/tinymce-code-tutorial#readme",
2121
"dependencies": {
22+
"@ephox/dom-globals": "^3.9.5",
2223
"@ephox/katamari": "^6.1.2",
2324
"@ephox/sugar": "^6.1.3"
2425
},

src/main/ts/Exercise2ArrayFunctions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Arr, Option as Optional } from '@ephox/katamari';
22

3+
// TODO: remove when we upgrade this tutorial to TinyMCE 5
4+
import { console } from '@ephox/dom-globals';
5+
36
/*
47
Katamari is our library for general-purpose functions and FP basics.
58
Its array module "Arr" is very handy, so let's explore it.

src/main/ts/Exercise3Optional.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { Option as Optional } from '@ephox/katamari';
2+
3+
// TODO: remove when we upgrade this tutorial to TinyMCE 5
4+
import { Element, console, ChildNode } from '@ephox/dom-globals';
5+
26
/*
37
Optional
48

src/main/ts/Exercise4FP.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Fun, Option as Optional } from "@ephox/katamari";
22

3+
// TODO: remove when we upgrade this tutorial to TinyMCE 5
4+
import { console } from '@ephox/dom-globals';
5+
36
/*
47
Functional programming is about programming in functions. Functions in the mathematical sense. "Pure" functions.
58

src/main/ts/Exercise5Sugar.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Element as SugarElement } from '@ephox/sugar';
2+
3+
// TODO: remove when we upgrade this tutorial to TinyMCE 5
4+
import { Element, document } from '@ephox/dom-globals';
5+
6+
/*
7+
Sugar
8+
9+
Sugar is our library for DOM manipulation. It's kinda our version of jquery, but with less $.
10+
Sugar smooths over browser differences and gives us useful functions for manipulating the DOM.
11+
12+
When using Sugar, we don't use native DOM elements, we wrap them in the SugarElement data type.
13+
This encourages us to only use Sugar functions to manipulate these elements, rather than the native DOM directly.
14+
15+
NOTE: Like Option=>Optional, Sugar is in the process of renaming. This tutorial is using the old libraries, but we'll
16+
rename imports to use the new names.
17+
18+
Wrapping
19+
20+
The first thing we need to know is how to wrap and unwrap a sugar element.
21+
*/
22+
23+
const e1: Element = document.createElement('span');
24+
25+
const se1 = SugarElement.fromDom(e1);
26+

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"moduleResolution": "node",
44
"target": "es5",
55
"module": "es2015",
6-
"lib": ["es2015", "dom"],
6+
"lib": ["es2015"],
77
"importHelpers": true,
88
"declaration": true,
99
"declarationMap": true,

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
resolved "https://registry.yarnpkg.com/@ephox/dom-globals/-/dom-globals-1.1.2.tgz#cb181a7652c1f097c9920fcf551c1fe202f70041"
7676
integrity sha512-wTcfYP5FH4n5tzVMaE8a7T6XqdTFiGfGAC6LiuCYPBh4mOeIEN5WkiPuAy+trJBl0wRdlwKl+XmhIW06Xf4tpg==
7777

78+
"@ephox/dom-globals@^3.9.5":
79+
version "3.9.5"
80+
resolved "https://registry.yarnpkg.com/@ephox/dom-globals/-/dom-globals-3.9.5.tgz#ae198970b6a5a008a3aa47eb09f9856a2048098c"
81+
integrity sha512-CeRpPjoaZADP/2QUbz+PmxNfbLbb/Cq/d96kW4Auzl9s08R64Re4hkNv01267kp1IyWHgF98agFYhNa1WvwXtg==
82+
7883
"@ephox/katamari@^6.1.2":
7984
version "6.1.2"
8085
resolved "https://registry.yarnpkg.com/@ephox/katamari/-/katamari-6.1.2.tgz#677693a182c58cdd7c1f318fdf8b728a93bb3e7d"

0 commit comments

Comments
 (0)