Javascript Undo, Redo 기능 구현하기
Javascript에서 Undo, Redo 기능을 구현해보겠습니다.
제가 처음부터 마지막까지 개발한건 아니고 아래링크의 깃허브소스를 활용하였을 뿐입니다.
기능이 아주 명백하고 간단해서 공유해드립니다.
https://github.com/ArthurClemens/Javascript-Undo-Manager
[code]
var undoManager = new UndoManager(),
people = {},
addPerson,
removePerson,
createPerson;
addPerson = function(id, name) {
people[id] = name;
};
removePerson = function(id) {
delete people[id];
};
createPerson = function (id, name) {
// first creation
addPerson(id, name);
// make undo-able
undoManager.add({
undo: function() {
removePerson(id)
},
redo: function() {
addPerson(id, name);
}
});
}
createPerson(101, "John");
createPerson(102, "Mary");
console.log("people", people); // {101: "John", 102: "Mary"}
undoManager.undo();
console.log("people", people); // {101: "John"}
undoManager.undo();
console.log("people", people); // {}
undoManager.redo();
console.log("people", people); // {101: "John"}
[/code]
http://108.181.203.145/ar
의 3디편집환경에서 저는 이 라이브러리를 사용하여 ctrl+z(undo), ctrl+y(redo)를 구현하였습니다.
3디편집기에서의 Undo, Redo기능을 직접 확인하시려면
ID: user1, PW: 123456789
로그인 하신 다음 구세관안내를 더블클릭하여 3디편집환경에 들어가셔서 아무런 편집도 해보고 ctrl+z(undo), ctrl+y(redo) 에 의 하여 기능이 작동하는지를 확인해보시면 됩니다.
감사합니다.
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4856 | PHP | 7년 전 | 5738 | ||
| 4855 | jQuery | 7년 전 | 3240 | ||
| 4854 | jQuery | 7년 전 | 2229 | ||
| 4853 | jQuery | 7년 전 | 2835 | ||
| 4852 | MySQL | 7년 전 | 2996 | ||
| 4851 | jQuery | 7년 전 | 2343 | ||
| 4850 | jQuery | 7년 전 | 2574 | ||
| 4849 | jQuery | 7년 전 | 4312 | ||
| 4848 | PHP |
|
7년 전 | 4249 | |
| 4847 | jQuery | 7년 전 | 4023 | ||
| 4846 | jQuery | 7년 전 | 2641 | ||
| 4845 | jQuery | 7년 전 | 2158 | ||
| 4844 | jQuery | 8년 전 | 2306 | ||
| 4843 | jQuery | 8년 전 | 3058 | ||
| 4842 | jQuery | 8년 전 | 2902 | ||
| 4841 | jQuery | 8년 전 | 2231 | ||
| 4840 | jQuery | 8년 전 | 1572 | ||
| 4839 | jQuery | 8년 전 | 2469 | ||
| 4838 | jQuery |
이에스씨코리아
|
8년 전 | 2323 | |
| 4837 | jQuery | 8년 전 | 2171 | ||
| 4836 | jQuery | 8년 전 | 2095 | ||
| 4835 | jQuery | 8년 전 | 1829 | ||
| 4834 | jQuery | 8년 전 | 1869 | ||
| 4833 | jQuery | 8년 전 | 1996 | ||
| 4832 | jQuery | 8년 전 | 2187 | ||
| 4831 | jQuery | 8년 전 | 2366 | ||
| 4830 | jQuery | 8년 전 | 2633 | ||
| 4829 | jQuery | 8년 전 | 1805 | ||
| 4828 | jQuery | 8년 전 | 2751 | ||
| 4827 | jQuery | 8년 전 | 2289 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기