nodebb-plugin-composer-default 10.3.4 → 10.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/static/lib/composer/drafts.js +38 -40
- package/static/lib/composer.js +1 -0
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
|
|
|
27
27
|
postContainer.on('click', '[component="category/list"] [data-cid]', utils.debounce(doSaveDraft, draftSaveDelay));
|
|
28
28
|
postContainer.on('itemAdded', '.tags', utils.debounce(doSaveDraft, draftSaveDelay));
|
|
29
29
|
postContainer.on('thumb.uploaded', doSaveDraft);
|
|
30
|
+
postContainer.on('composer.minimize', doSaveDraft);
|
|
30
31
|
|
|
31
32
|
draftIconEl.on('animationend', function () {
|
|
32
33
|
$(this).toggleClass('active', false);
|
|
@@ -84,48 +85,45 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
|
|
|
84
85
|
const raw = postContainer.find('textarea').val();
|
|
85
86
|
const storage = getStorage(app.user.uid);
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
88
|
+
const draftData = {
|
|
89
|
+
save_id: postData.save_id,
|
|
90
|
+
action: postData.action,
|
|
91
|
+
text: raw,
|
|
92
|
+
uuid: postContainer.attr('data-uuid'),
|
|
93
|
+
timestamp: Date.now(),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if (postData.action === 'topics.post') {
|
|
97
|
+
// New topic only
|
|
98
|
+
const tags = postContainer.find('input.tags').val();
|
|
99
|
+
draftData.tags = tags;
|
|
100
|
+
draftData.title = title;
|
|
101
|
+
draftData.cid = postData.cid;
|
|
102
|
+
draftData.thumbs = postData.thumbs || [];
|
|
103
|
+
} else if (postData.action === 'posts.reply') {
|
|
104
|
+
// new reply only
|
|
105
|
+
draftData.title = postData.title;
|
|
106
|
+
draftData.tid = postData.tid;
|
|
107
|
+
draftData.toPid = postData.toPid;
|
|
108
|
+
} else if (postData.action === 'posts.edit') {
|
|
109
|
+
draftData.pid = postData.pid;
|
|
110
|
+
draftData.title = title || postData.title;
|
|
111
|
+
draftData.thumbs = postData.thumbs || [];
|
|
112
|
+
}
|
|
113
|
+
if (!app.user.uid) {
|
|
114
|
+
draftData.handle = postContainer.find('input.handle').val();
|
|
115
|
+
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
// save all draft data into single item as json
|
|
118
|
+
storage.setItem(postData.save_id, JSON.stringify(draftData));
|
|
119
|
+
|
|
120
|
+
$(window).trigger('action:composer.drafts.save', {
|
|
121
|
+
storage: storage,
|
|
122
|
+
postData: postData,
|
|
123
|
+
postContainer: postContainer,
|
|
124
|
+
});
|
|
125
|
+
draftIconEl.toggleClass('active', true);
|
|
119
126
|
|
|
120
|
-
$(window).trigger('action:composer.drafts.save', {
|
|
121
|
-
storage: storage,
|
|
122
|
-
postData: postData,
|
|
123
|
-
postContainer: postContainer,
|
|
124
|
-
});
|
|
125
|
-
draftIconEl.toggleClass('active', true);
|
|
126
|
-
} else {
|
|
127
|
-
drafts.removeDraft(postData.save_id);
|
|
128
|
-
}
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
|