@licium/editor-plugin-details 1.0.1

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.
@@ -0,0 +1,636 @@
1
+ /*!
2
+ * TOAST UI Editor : Text Align Plugin
3
+ * @version 1.0.0 | Sat Jan 03 2026
4
+ * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
+ * @license MIT
6
+ */
7
+ (function webpackUniversalModuleDefinition(root, factory) {
8
+ if(typeof exports === 'object' && typeof module === 'object')
9
+ module.exports = factory();
10
+ else if(typeof define === 'function' && define.amd)
11
+ define([], factory);
12
+ else if(typeof exports === 'object')
13
+ exports["toastui"] = factory();
14
+ else
15
+ root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = root["toastui"]["Editor"] || {}, root["toastui"]["Editor"]["plugin"] = root["toastui"]["Editor"]["plugin"] || {}, root["toastui"]["Editor"]["plugin"]["details"] = factory();
16
+ })(self, function() {
17
+ return /******/ (function() { // webpackBootstrap
18
+ /******/ "use strict";
19
+ /******/ // The require scope
20
+ /******/ var __webpack_require__ = {};
21
+ /******/
22
+ /************************************************************************/
23
+ /******/ /* webpack/runtime/define property getters */
24
+ /******/ !function() {
25
+ /******/ // define getter functions for harmony exports
26
+ /******/ __webpack_require__.d = function(exports, definition) {
27
+ /******/ for(var key in definition) {
28
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
29
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
30
+ /******/ }
31
+ /******/ }
32
+ /******/ };
33
+ /******/ }();
34
+ /******/
35
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
36
+ /******/ !function() {
37
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
38
+ /******/ }();
39
+ /******/
40
+ /************************************************************************/
41
+ var __webpack_exports__ = {};
42
+
43
+ // EXPORTS
44
+ __webpack_require__.d(__webpack_exports__, {
45
+ "default": function() { return /* binding */ detailsPlugin; }
46
+ });
47
+
48
+ ;// CONCATENATED MODULE: ../../node_modules/tslib/tslib.es6.mjs
49
+ /******************************************************************************
50
+ Copyright (c) Microsoft Corporation.
51
+
52
+ Permission to use, copy, modify, and/or distribute this software for any
53
+ purpose with or without fee is hereby granted.
54
+
55
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
56
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
57
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
58
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
59
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
60
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
61
+ PERFORMANCE OF THIS SOFTWARE.
62
+ ***************************************************************************** */
63
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
64
+
65
+ var extendStatics = function(d, b) {
66
+ extendStatics = Object.setPrototypeOf ||
67
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
68
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
69
+ return extendStatics(d, b);
70
+ };
71
+
72
+ function __extends(d, b) {
73
+ if (typeof b !== "function" && b !== null)
74
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
75
+ extendStatics(d, b);
76
+ function __() { this.constructor = d; }
77
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
78
+ }
79
+
80
+ var __assign = function() {
81
+ __assign = Object.assign || function __assign(t) {
82
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
83
+ s = arguments[i];
84
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
85
+ }
86
+ return t;
87
+ }
88
+ return __assign.apply(this, arguments);
89
+ }
90
+
91
+ function __rest(s, e) {
92
+ var t = {};
93
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
94
+ t[p] = s[p];
95
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
96
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
97
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
98
+ t[p[i]] = s[p[i]];
99
+ }
100
+ return t;
101
+ }
102
+
103
+ function __decorate(decorators, target, key, desc) {
104
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
105
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
106
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
107
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
108
+ }
109
+
110
+ function __param(paramIndex, decorator) {
111
+ return function (target, key) { decorator(target, key, paramIndex); }
112
+ }
113
+
114
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
115
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
116
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
117
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
118
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
119
+ var _, done = false;
120
+ for (var i = decorators.length - 1; i >= 0; i--) {
121
+ var context = {};
122
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
123
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
124
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
125
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
126
+ if (kind === "accessor") {
127
+ if (result === void 0) continue;
128
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
129
+ if (_ = accept(result.get)) descriptor.get = _;
130
+ if (_ = accept(result.set)) descriptor.set = _;
131
+ if (_ = accept(result.init)) initializers.unshift(_);
132
+ }
133
+ else if (_ = accept(result)) {
134
+ if (kind === "field") initializers.unshift(_);
135
+ else descriptor[key] = _;
136
+ }
137
+ }
138
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
139
+ done = true;
140
+ };
141
+
142
+ function __runInitializers(thisArg, initializers, value) {
143
+ var useValue = arguments.length > 2;
144
+ for (var i = 0; i < initializers.length; i++) {
145
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
146
+ }
147
+ return useValue ? value : void 0;
148
+ };
149
+
150
+ function __propKey(x) {
151
+ return typeof x === "symbol" ? x : "".concat(x);
152
+ };
153
+
154
+ function __setFunctionName(f, name, prefix) {
155
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
156
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
157
+ };
158
+
159
+ function __metadata(metadataKey, metadataValue) {
160
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
161
+ }
162
+
163
+ function __awaiter(thisArg, _arguments, P, generator) {
164
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
165
+ return new (P || (P = Promise))(function (resolve, reject) {
166
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
167
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
168
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
169
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
170
+ });
171
+ }
172
+
173
+ function __generator(thisArg, body) {
174
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
175
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
176
+ function verb(n) { return function (v) { return step([n, v]); }; }
177
+ function step(op) {
178
+ if (f) throw new TypeError("Generator is already executing.");
179
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
180
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
181
+ if (y = 0, t) op = [op[0] & 2, t.value];
182
+ switch (op[0]) {
183
+ case 0: case 1: t = op; break;
184
+ case 4: _.label++; return { value: op[1], done: false };
185
+ case 5: _.label++; y = op[1]; op = [0]; continue;
186
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
187
+ default:
188
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
189
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
190
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
191
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
192
+ if (t[2]) _.ops.pop();
193
+ _.trys.pop(); continue;
194
+ }
195
+ op = body.call(thisArg, _);
196
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
197
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
198
+ }
199
+ }
200
+
201
+ var __createBinding = Object.create ? (function(o, m, k, k2) {
202
+ if (k2 === undefined) k2 = k;
203
+ var desc = Object.getOwnPropertyDescriptor(m, k);
204
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
205
+ desc = { enumerable: true, get: function() { return m[k]; } };
206
+ }
207
+ Object.defineProperty(o, k2, desc);
208
+ }) : (function(o, m, k, k2) {
209
+ if (k2 === undefined) k2 = k;
210
+ o[k2] = m[k];
211
+ });
212
+
213
+ function __exportStar(m, o) {
214
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
215
+ }
216
+
217
+ function __values(o) {
218
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
219
+ if (m) return m.call(o);
220
+ if (o && typeof o.length === "number") return {
221
+ next: function () {
222
+ if (o && i >= o.length) o = void 0;
223
+ return { value: o && o[i++], done: !o };
224
+ }
225
+ };
226
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
227
+ }
228
+
229
+ function __read(o, n) {
230
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
231
+ if (!m) return o;
232
+ var i = m.call(o), r, ar = [], e;
233
+ try {
234
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
235
+ }
236
+ catch (error) { e = { error: error }; }
237
+ finally {
238
+ try {
239
+ if (r && !r.done && (m = i["return"])) m.call(i);
240
+ }
241
+ finally { if (e) throw e.error; }
242
+ }
243
+ return ar;
244
+ }
245
+
246
+ /** @deprecated */
247
+ function __spread() {
248
+ for (var ar = [], i = 0; i < arguments.length; i++)
249
+ ar = ar.concat(__read(arguments[i]));
250
+ return ar;
251
+ }
252
+
253
+ /** @deprecated */
254
+ function __spreadArrays() {
255
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
256
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
257
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
258
+ r[k] = a[j];
259
+ return r;
260
+ }
261
+
262
+ function __spreadArray(to, from, pack) {
263
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
264
+ if (ar || !(i in from)) {
265
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
266
+ ar[i] = from[i];
267
+ }
268
+ }
269
+ return to.concat(ar || Array.prototype.slice.call(from));
270
+ }
271
+
272
+ function __await(v) {
273
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
274
+ }
275
+
276
+ function __asyncGenerator(thisArg, _arguments, generator) {
277
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
278
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
279
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
280
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
281
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
282
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
283
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
284
+ function fulfill(value) { resume("next", value); }
285
+ function reject(value) { resume("throw", value); }
286
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
287
+ }
288
+
289
+ function __asyncDelegator(o) {
290
+ var i, p;
291
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
292
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
293
+ }
294
+
295
+ function __asyncValues(o) {
296
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
297
+ var m = o[Symbol.asyncIterator], i;
298
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
299
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
300
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
301
+ }
302
+
303
+ function __makeTemplateObject(cooked, raw) {
304
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
305
+ return cooked;
306
+ };
307
+
308
+ var __setModuleDefault = Object.create ? (function(o, v) {
309
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
310
+ }) : function(o, v) {
311
+ o["default"] = v;
312
+ };
313
+
314
+ var ownKeys = function(o) {
315
+ ownKeys = Object.getOwnPropertyNames || function (o) {
316
+ var ar = [];
317
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
318
+ return ar;
319
+ };
320
+ return ownKeys(o);
321
+ };
322
+
323
+ function __importStar(mod) {
324
+ if (mod && mod.__esModule) return mod;
325
+ var result = {};
326
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
327
+ __setModuleDefault(result, mod);
328
+ return result;
329
+ }
330
+
331
+ function __importDefault(mod) {
332
+ return (mod && mod.__esModule) ? mod : { default: mod };
333
+ }
334
+
335
+ function __classPrivateFieldGet(receiver, state, kind, f) {
336
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
337
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
338
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
339
+ }
340
+
341
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
342
+ if (kind === "m") throw new TypeError("Private method is not writable");
343
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
344
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
345
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
346
+ }
347
+
348
+ function __classPrivateFieldIn(state, receiver) {
349
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
350
+ return typeof state === "function" ? receiver === state : state.has(receiver);
351
+ }
352
+
353
+ function __addDisposableResource(env, value, async) {
354
+ if (value !== null && value !== void 0) {
355
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
356
+ var dispose, inner;
357
+ if (async) {
358
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
359
+ dispose = value[Symbol.asyncDispose];
360
+ }
361
+ if (dispose === void 0) {
362
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
363
+ dispose = value[Symbol.dispose];
364
+ if (async) inner = dispose;
365
+ }
366
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
367
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
368
+ env.stack.push({ value: value, dispose: dispose, async: async });
369
+ }
370
+ else if (async) {
371
+ env.stack.push({ async: true });
372
+ }
373
+ return value;
374
+ }
375
+
376
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
377
+ var e = new Error(message);
378
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
379
+ };
380
+
381
+ function __disposeResources(env) {
382
+ function fail(e) {
383
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
384
+ env.hasError = true;
385
+ }
386
+ var r, s = 0;
387
+ function next() {
388
+ while (r = env.stack.pop()) {
389
+ try {
390
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
391
+ if (r.dispose) {
392
+ var result = r.dispose.call(r.value);
393
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
394
+ }
395
+ else s |= 1;
396
+ }
397
+ catch (e) {
398
+ fail(e);
399
+ }
400
+ }
401
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
402
+ if (env.hasError) throw env.error;
403
+ }
404
+ return next();
405
+ }
406
+
407
+ function __rewriteRelativeImportExtension(path, preserveJsx) {
408
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
409
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
410
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
411
+ });
412
+ }
413
+ return path;
414
+ }
415
+
416
+ /* harmony default export */ var tslib_es6 = ({
417
+ __extends,
418
+ __assign,
419
+ __rest,
420
+ __decorate,
421
+ __param,
422
+ __esDecorate,
423
+ __runInitializers,
424
+ __propKey,
425
+ __setFunctionName,
426
+ __metadata,
427
+ __awaiter,
428
+ __generator,
429
+ __createBinding,
430
+ __exportStar,
431
+ __values,
432
+ __read,
433
+ __spread,
434
+ __spreadArrays,
435
+ __spreadArray,
436
+ __await,
437
+ __asyncGenerator,
438
+ __asyncDelegator,
439
+ __asyncValues,
440
+ __makeTemplateObject,
441
+ __importStar,
442
+ __importDefault,
443
+ __classPrivateFieldGet,
444
+ __classPrivateFieldSet,
445
+ __classPrivateFieldIn,
446
+ __addDisposableResource,
447
+ __disposeResources,
448
+ __rewriteRelativeImportExtension,
449
+ });
450
+
451
+ ;// CONCATENATED MODULE: ./src/i18n/langs.ts
452
+ function addLangs(i18n) {
453
+ i18n.setLanguage(['en', 'en-US'], {
454
+ details: 'Collapsible Block',
455
+ summary: 'Summary header',
456
+ content: 'Hidden content',
457
+ });
458
+ i18n.setLanguage(['de', 'de-DE'], {
459
+ details: 'Aufklappbarer Block',
460
+ summary: 'Klick mich zum Aufklappen',
461
+ content: 'Hier steht der versteckte Inhalt',
462
+ });
463
+ }
464
+
465
+ ;// CONCATENATED MODULE: ./src/index.ts
466
+
467
+
468
+ var PREFIX = 'toastui-editor-';
469
+ function createToolbarItemOption(i18n) {
470
+ return {
471
+ name: 'details',
472
+ tooltip: i18n.get('details'),
473
+ className: PREFIX + "toolbar-icons details",
474
+ command: 'details',
475
+ };
476
+ }
477
+ function detailsPlugin(context, options) {
478
+ if (options === void 0) { options = {}; }
479
+ var i18n = context.i18n, eventEmitter = context.eventEmitter;
480
+ addLangs(i18n);
481
+ var toolbarItem = createToolbarItemOption(i18n);
482
+ return {
483
+ markdownCommands: {
484
+ details: function (payload, _a, dispatch) {
485
+ var tr = _a.tr, selection = _a.selection, schema = _a.schema;
486
+ var from = selection.from, to = selection.to;
487
+ var slice = selection.content();
488
+ var textContent = slice.content.textBetween(0, slice.content.size, '\n') || i18n.get('content');
489
+ var summaryText = i18n.get('summary');
490
+ var openTag = "<details>\n<summary>" + summaryText + "</summary>\n";
491
+ var closeTag = "\n</details>";
492
+ var newText = "" + openTag + textContent + closeTag;
493
+ tr.replaceSelectionWith(schema.text(newText));
494
+ dispatch(tr);
495
+ return true;
496
+ },
497
+ },
498
+ toHTMLRenderers: {
499
+ htmlBlock: {
500
+ details: function (node) { return [
501
+ { type: 'openTag', tagName: 'details', outerNewLine: true },
502
+ { type: 'html', content: node.childrenHTML || '' },
503
+ { type: 'closeTag', tagName: 'details', outerNewLine: true },
504
+ ]; },
505
+ summary: function (node) { return [
506
+ { type: 'openTag', tagName: 'summary', outerNewLine: true },
507
+ { type: 'html', content: node.childrenHTML || '' },
508
+ { type: 'closeTag', tagName: 'summary', outerNewLine: true },
509
+ ]; },
510
+ },
511
+ },
512
+ wysiwygNodeViews: {
513
+ details: function (node, view, getPos) {
514
+ var dom = document.createElement('details');
515
+ var htmlAttrs = node.attrs.htmlAttrs;
516
+ if (htmlAttrs.open) {
517
+ dom.open = true;
518
+ }
519
+ dom.addEventListener('click', function (e) {
520
+ var target = e.target;
521
+ if (target.tagName === 'SUMMARY' || target.closest('summary')) {
522
+ e.preventDefault();
523
+ var pos = getPos();
524
+ if (typeof pos === 'number') {
525
+ var newAttrs = __assign(__assign({}, node.attrs), { htmlAttrs: __assign(__assign({}, htmlAttrs), { open: !htmlAttrs.open }) });
526
+ view.dispatch(view.state.tr.setNodeMarkup(pos, null, newAttrs));
527
+ }
528
+ }
529
+ });
530
+ // Add Keydown listener for exit behavior
531
+ dom.addEventListener('keydown', function (e) {
532
+ var state = view.state;
533
+ var selection = state.selection, tr = state.tr, schema = state.schema;
534
+ var $from = selection.$from;
535
+ var pos = getPos();
536
+ if (typeof pos !== 'number') {
537
+ return;
538
+ }
539
+ // Fetch current node to ensure nodeSize is fresh!
540
+ var currentNode = state.doc.nodeAt(pos);
541
+ if (!currentNode || currentNode.type.name !== 'details') {
542
+ return;
543
+ }
544
+ var nodeSize = currentNode.nodeSize;
545
+ var endOfDetails = pos + nodeSize;
546
+ // Workaround for Dual Package Hazard:
547
+ // Get the TextSelection constructor from the current selection instance
548
+ // assuming the current selection is a TextSelection (which it is while typing).
549
+ var SelectionHeader = state.selection.constructor;
550
+ if (e.key === 'Enter') {
551
+ var parent = $from.parent;
552
+ // Check if we are in an empty paragraph that is the last child of details
553
+ if (parent.type.name === 'paragraph' && parent.content.size === 0) {
554
+ var parentEnd = $from.after();
555
+ if (parentEnd === endOfDetails - 1) {
556
+ // Empty last paragraph -> Exit logic
557
+ e.preventDefault();
558
+ e.stopPropagation();
559
+ var parentPos = $from.before();
560
+ tr.delete(parentPos, parentEnd);
561
+ var p = schema.nodes.paragraph.createAndFill();
562
+ // After deletion, the position shifts back
563
+ var newPos = endOfDetails - (parentEnd - parentPos);
564
+ tr.insert(newPos, p);
565
+ if (SelectionHeader && SelectionHeader.near) {
566
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(newPos + 1)));
567
+ view.dispatch(tr);
568
+ }
569
+ }
570
+ }
571
+ }
572
+ else if (e.key === 'ArrowDown') {
573
+ var parentEnd = $from.after();
574
+ if (parentEnd !== endOfDetails - 1) {
575
+ return;
576
+ }
577
+ // We are in the last child
578
+ var atEnd = $from.parentOffset === $from.parent.content.size;
579
+ if (!atEnd) {
580
+ return;
581
+ }
582
+ e.preventDefault();
583
+ e.stopPropagation();
584
+ if (endOfDetails < state.doc.content.size) {
585
+ // Move cursor out to existing content
586
+ if (SelectionHeader && SelectionHeader.near) {
587
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(endOfDetails)));
588
+ view.dispatch(tr);
589
+ }
590
+ }
591
+ else {
592
+ // Create new paragraph below
593
+ var p = schema.nodes.paragraph.createAndFill();
594
+ tr.insert(endOfDetails, p);
595
+ if (SelectionHeader && SelectionHeader.near) {
596
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(endOfDetails + 1)));
597
+ view.dispatch(tr);
598
+ }
599
+ }
600
+ }
601
+ });
602
+ return { dom: dom, contentDOM: dom };
603
+ },
604
+ },
605
+ wysiwygCommands: {
606
+ details: function (payload, _a, dispatch) {
607
+ var tr = _a.tr, selection = _a.selection, schema = _a.schema;
608
+ var summaryText = i18n.get('summary');
609
+ var contentText = i18n.get('content');
610
+ var _b = schema.nodes, details = _b.details, summary = _b.summary, paragraph = _b.paragraph;
611
+ if (details && summary && paragraph) {
612
+ var summaryNode = summary.create({}, schema.text(summaryText));
613
+ var contentNode = paragraph.create({}, schema.text(contentText));
614
+ var node = details.create({}, [summaryNode, contentNode]);
615
+ tr.replaceSelectionWith(node);
616
+ dispatch(tr);
617
+ return true;
618
+ }
619
+ return false;
620
+ },
621
+ },
622
+ toolbarItems: [
623
+ {
624
+ groupIndex: 0,
625
+ itemIndex: 4,
626
+ item: toolbarItem,
627
+ },
628
+ ],
629
+ };
630
+ }
631
+
632
+ __webpack_exports__ = __webpack_exports__["default"];
633
+ /******/ return __webpack_exports__;
634
+ /******/ })()
635
+ ;
636
+ });
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@licium/editor-plugin-details",
3
+ "version": "1.0.1",
4
+ "description": "Details/Summary plugin for Toast UI Editor",
5
+ "keywords": [
6
+ "nhn",
7
+ "nhn cloud",
8
+ "toast",
9
+ "toastui",
10
+ "toast-ui",
11
+ "editor",
12
+ "plugin",
13
+ "text-align",
14
+ "align"
15
+ ],
16
+ "main": "dist/toastui-editor-plugin-details.js",
17
+ "files": [
18
+ "dist",
19
+ "src",
20
+ "index.d.ts"
21
+ ],
22
+ "types": "index.d.ts",
23
+ "author": "NHN Cloud FE Development Lab <dl_javascript@nhn.com>",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/natorus87/tui.editor.git",
28
+ "directory": "plugins/details"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/natorus87/tui.editor/issues"
32
+ },
33
+ "homepage": "https://ui.toast.com",
34
+ "browserslist": "last 2 versions, not ie <= 10",
35
+ "scripts": {
36
+ "lint": "eslint .",
37
+ "test:types": "tsc",
38
+ "test": "jest --watch",
39
+ "test:ci": "jest",
40
+ "serve": "snowpack dev",
41
+ "serve:ie": "webpack serve",
42
+ "build:cdn": "webpack build --env cdn & webpack build --env cdn minify",
43
+ "build": "webpack build --no-stats"
44
+ },
45
+ "devDependencies": {
46
+ "cross-env": "^6.0.3"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }
@@ -0,0 +1,13 @@
1
+ /* Light Mode */
2
+ .toastui-editor-toolbar-icons.details {
3
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z'/%3E%3Cpath d='M9 10L12 13 15 10' stroke='%23333'/%3E%3C/svg%3E") !important;
4
+ background-size: 24px 24px !important;
5
+ background-repeat: no-repeat !important;
6
+ background-position: center center !important;
7
+ text-indent: -9999px !important;
8
+ }
9
+
10
+ /* Dark Mode */
11
+ .toastui-editor-dark .toastui-editor-toolbar-icons.details {
12
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23eee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z'/%3E%3Cpath d='M9 10L12 13 15 10' stroke='%23eee'/%3E%3C/svg%3E") !important;
13
+ }
@@ -0,0 +1,15 @@
1
+ import type { I18n } from '@licium/editor';
2
+
3
+ export function addLangs(i18n: I18n) {
4
+ i18n.setLanguage(['en', 'en-US'], {
5
+ details: 'Collapsible Block',
6
+ summary: 'Summary header',
7
+ content: 'Hidden content',
8
+ });
9
+
10
+ i18n.setLanguage(['de', 'de-DE'], {
11
+ details: 'Aufklappbarer Block',
12
+ summary: 'Klick mich zum Aufklappen',
13
+ content: 'Hier steht der versteckte Inhalt',
14
+ });
15
+ }
package/src/index.ts ADDED
@@ -0,0 +1,207 @@
1
+ import type { PluginContext, PluginInfo, I18n } from '@licium/editor';
2
+ import { PluginOptions } from '@t/index';
3
+ import { addLangs } from './i18n/langs';
4
+
5
+ const PREFIX = 'toastui-editor-';
6
+
7
+ function createToolbarItemOption(i18n: I18n) {
8
+ return {
9
+ name: 'details',
10
+ tooltip: i18n.get('details'),
11
+ className: `${PREFIX}toolbar-icons details`,
12
+ command: 'details',
13
+ };
14
+ }
15
+
16
+ export default function detailsPlugin(
17
+ context: PluginContext,
18
+ options: PluginOptions = {}
19
+ ): PluginInfo {
20
+ const { i18n, eventEmitter } = context;
21
+
22
+ addLangs(i18n);
23
+
24
+ const toolbarItem = createToolbarItemOption(i18n);
25
+
26
+ return {
27
+ markdownCommands: {
28
+ details: (payload, { tr, selection, schema }, dispatch) => {
29
+ const { from, to } = selection;
30
+ const slice = selection.content();
31
+ const textContent =
32
+ slice.content.textBetween(0, slice.content.size, '\n') || i18n.get('content');
33
+
34
+ const summaryText = i18n.get('summary');
35
+ const openTag = `<details>\n<summary>${summaryText}</summary>\n`;
36
+ const closeTag = `\n</details>`;
37
+ const newText = `${openTag}${textContent}${closeTag}`;
38
+
39
+ tr.replaceSelectionWith(schema.text(newText));
40
+ dispatch!(tr);
41
+ return true;
42
+ },
43
+ },
44
+ toHTMLRenderers: {
45
+ htmlBlock: {
46
+ details: (node) => [
47
+ { type: 'openTag', tagName: 'details', outerNewLine: true },
48
+ { type: 'html', content: node.childrenHTML || '' },
49
+ { type: 'closeTag', tagName: 'details', outerNewLine: true },
50
+ ],
51
+ summary: (node) => [
52
+ { type: 'openTag', tagName: 'summary', outerNewLine: true },
53
+ { type: 'html', content: node.childrenHTML || '' },
54
+ { type: 'closeTag', tagName: 'summary', outerNewLine: true },
55
+ ],
56
+ },
57
+ },
58
+ wysiwygNodeViews: {
59
+ details: (node, view, getPos) => {
60
+ const dom = document.createElement('details');
61
+ const { htmlAttrs } = node.attrs;
62
+
63
+ if (htmlAttrs.open) {
64
+ dom.open = true;
65
+ }
66
+
67
+ dom.addEventListener('click', (e) => {
68
+ const target = e.target as HTMLElement;
69
+
70
+ if (target.tagName === 'SUMMARY' || target.closest('summary')) {
71
+ e.preventDefault();
72
+
73
+ const pos = getPos();
74
+
75
+ if (typeof pos === 'number') {
76
+ const newAttrs = {
77
+ ...node.attrs,
78
+ htmlAttrs: { ...htmlAttrs, open: !htmlAttrs.open },
79
+ };
80
+
81
+ view.dispatch(view.state.tr.setNodeMarkup(pos, null, newAttrs));
82
+ }
83
+ }
84
+ });
85
+
86
+ // Add Keydown listener for exit behavior
87
+ dom.addEventListener('keydown', (e) => {
88
+ const { state } = view;
89
+ const { selection, tr, schema } = state;
90
+ const { $from } = selection;
91
+ const pos = getPos();
92
+
93
+ if (typeof pos !== 'number') {
94
+ return;
95
+ }
96
+
97
+ // Fetch current node to ensure nodeSize is fresh!
98
+ const currentNode = state.doc.nodeAt(pos);
99
+
100
+ if (!currentNode || currentNode.type.name !== 'details') {
101
+ return;
102
+ }
103
+
104
+ const { nodeSize } = currentNode;
105
+ const endOfDetails = pos + nodeSize;
106
+
107
+ // Workaround for Dual Package Hazard:
108
+ // Get the TextSelection constructor from the current selection instance
109
+ // assuming the current selection is a TextSelection (which it is while typing).
110
+ const { constructor: SelectionHeader } = state.selection as any;
111
+
112
+ if (e.key === 'Enter') {
113
+ const { parent } = $from;
114
+
115
+ // Check if we are in an empty paragraph that is the last child of details
116
+ if (parent.type.name === 'paragraph' && parent.content.size === 0) {
117
+ const parentEnd = $from.after();
118
+
119
+ if (parentEnd === endOfDetails - 1) {
120
+ // Empty last paragraph -> Exit logic
121
+ e.preventDefault();
122
+ e.stopPropagation();
123
+
124
+ const parentPos = $from.before();
125
+
126
+ tr.delete(parentPos, parentEnd);
127
+ const p = schema.nodes.paragraph.createAndFill()!;
128
+ // After deletion, the position shifts back
129
+ const newPos = endOfDetails - (parentEnd - parentPos);
130
+
131
+ tr.insert(newPos, p);
132
+
133
+ if (SelectionHeader && SelectionHeader.near) {
134
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(newPos + 1)));
135
+ view.dispatch(tr);
136
+ }
137
+ }
138
+ }
139
+ } else if (e.key === 'ArrowDown') {
140
+ const parentEnd = $from.after();
141
+
142
+ if (parentEnd !== endOfDetails - 1) {
143
+ return;
144
+ }
145
+
146
+ // We are in the last child
147
+ const atEnd = $from.parentOffset === $from.parent.content.size;
148
+
149
+ if (!atEnd) {
150
+ return;
151
+ }
152
+
153
+ e.preventDefault();
154
+ e.stopPropagation();
155
+
156
+ if (endOfDetails < state.doc.content.size) {
157
+ // Move cursor out to existing content
158
+ if (SelectionHeader && SelectionHeader.near) {
159
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(endOfDetails)));
160
+ view.dispatch(tr);
161
+ }
162
+ } else {
163
+ // Create new paragraph below
164
+ const p = schema.nodes.paragraph.createAndFill()!;
165
+
166
+ tr.insert(endOfDetails, p);
167
+
168
+ if (SelectionHeader && SelectionHeader.near) {
169
+ tr.setSelection(SelectionHeader.near(tr.doc.resolve(endOfDetails + 1)));
170
+ view.dispatch(tr);
171
+ }
172
+ }
173
+ }
174
+ });
175
+
176
+ return { dom, contentDOM: dom };
177
+ },
178
+ },
179
+ wysiwygCommands: {
180
+ details: (payload, { tr, selection, schema }, dispatch) => {
181
+ const summaryText = i18n.get('summary');
182
+ const contentText = i18n.get('content');
183
+
184
+ const { details, summary, paragraph } = schema.nodes;
185
+
186
+ if (details && summary && paragraph) {
187
+ const summaryNode = summary.create({}, schema.text(summaryText));
188
+ const contentNode = paragraph.create({}, schema.text(contentText));
189
+ const node = details.create({}, [summaryNode, contentNode]);
190
+
191
+ tr.replaceSelectionWith(node);
192
+ dispatch!(tr);
193
+ return true;
194
+ }
195
+
196
+ return false;
197
+ },
198
+ },
199
+ toolbarItems: [
200
+ {
201
+ groupIndex: 0,
202
+ itemIndex: 4, // Append after CodeBlock
203
+ item: toolbarItem,
204
+ },
205
+ ],
206
+ };
207
+ }