@zipify/wysiwyg 3.1.2 → 3.1.3-0

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/dist/wysiwyg.mjs CHANGED
@@ -15313,340 +15313,32 @@ const History = Extension.create({
15313
15313
  };
15314
15314
  }
15315
15315
  });
15316
- const NodeProcessor = Extension.create({
15317
- name: "node_processor",
15318
- addCommands() {
15319
- return {
15320
- setBlockAttributes: createCommand(({ commands: commands2, state }, name, attrs, defaults2 = {}) => {
15321
- const current = unref(commands2.getBlockAttributes(name)) ?? {};
15322
- const { doc: doc2, tr } = state;
15323
- const { from: from2, to } = tr.selection;
15324
- doc2.nodesBetween(from2, to, (node, position) => {
15325
- if (!NodeTypes.blocks.includes(node.type.name))
15326
- return;
15327
- tr.setNodeAttribute(position, name, { ...defaults2, ...current, ...attrs });
15328
- });
15329
- }),
15330
- getBlockAttributes: createCommand(({ editor }, name, defaults2) => computed(() => {
15331
- var _a;
15332
- let attrs = Object.assign({}, defaults2 || {});
15333
- for (const type of NodeTypes.blocks) {
15334
- Object.assign(attrs, ((_a = editor.getAttributes(type)) == null ? void 0 : _a[name]) || {});
15335
- }
15336
- return Object.keys(attrs).length ? attrs : null;
15337
- })),
15338
- removeBlockAttributes: createCommand(({ commands: commands2 }, names) => {
15339
- for (const type of NodeTypes.blocks) {
15340
- commands2.resetAttributes(type, names);
15341
- }
15342
- }),
15343
- applyMark: createCommand(({ state, commands: commands2 }, name, value, customizer = {}) => {
15344
- const { tr, doc: doc2, schema } = state;
15345
- const { $from, $to } = tr.selection;
15346
- const linkMarkType = getMarkType(TextSettings.LINK, schema);
15347
- const markType = getMarkType(name, schema);
15348
- const markGroup = markType.spec.group || "";
15349
- if (!markGroup.includes(MarkGroups.SETTINGS)) {
15350
- return commands2.setMark(name, value);
15351
- }
15352
- if ($from.pos === $to.pos)
15353
- return;
15354
- const onAppliedToParent = (context) => {
15355
- if (!customizer.onAppliedToParent || customizer.onAppliedToParent(context) === false) {
15356
- const { tr: tr2, node, position, mark } = context;
15357
- commands2._removeNodeMark({ tr: tr2, node, position, mark: mark.type });
15358
- }
15359
- };
15360
- doc2.nodesBetween($from.pos, $to.pos, (node, position) => {
15361
- if (node.type.name === NodeTypes.LIST)
15362
- return;
15363
- const initialMark = findMarkByType(node.marks, name);
15364
- const applyingMark = markType.create({ ...(initialMark == null ? void 0 : initialMark.attrs) || {}, ...value });
15365
- const textPosition = resolveTextPosition($from, $to, node, position);
15366
- const isAppliedToParent = !linkMarkType.isInSet(node.marks) && isMarkAppliedToParent(tr.doc, position, applyingMark, customizer.isAppliedToParent);
15367
- if (isAppliedToParent) {
15368
- return onAppliedToParent({ tr, node, position, mark: applyingMark });
15369
- }
15370
- if (node.isText) {
15371
- tr.addMark(textPosition.from, textPosition.to, applyingMark);
15372
- return;
15373
- }
15374
- if (isNodeFullySelected(tr.doc, tr.selection, node, position)) {
15375
- tr.addNodeMark(position, applyingMark);
15376
- }
15377
- });
15378
- }),
15379
- getMarks: createCommand(({ editor }, name) => {
15380
- const stateRef = toRef(editor, "state");
15381
- return computed(() => {
15382
- const { selection, doc: doc2 } = unref(stateRef);
15383
- const { from: from2, to } = unref(selection);
15384
- const marks = [];
15385
- doc2.nodesBetween(from2, to, (node) => {
15386
- for (const mark of node.marks) {
15387
- if (mark.type.name === name)
15388
- marks.unshift(mark.attrs);
15389
- }
15390
- });
15391
- return marks;
15392
- });
15393
- }),
15394
- getMark: createCommand(({ commands: commands2 }, name) => {
15395
- const marksRef = commands2.getMarks(name);
15396
- return computed(() => unref(marksRef)[0] ?? null);
15397
- }),
15398
- hasMark: createCommand(({ commands: commands2 }, name) => {
15399
- const mark = commands2.getMark(name);
15400
- return computed(() => !!unref(mark));
15401
- }),
15402
- getCommonSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
15403
- const selectionRef = commands2.getMark(name);
15404
- return computed(() => {
15405
- var _a;
15406
- return ((_a = unref(selectionRef)) == null ? void 0 : _a.value) ?? unref(defaultRef);
15407
- });
15408
- }),
15409
- getDeviceSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
15410
- const selectionRef = commands2.getMarks(name);
15411
- const deviceRef = commands2.getDevice();
15412
- return computed(() => {
15413
- for (const attrs of unref(selectionRef)) {
15414
- const value = attrs[unref(deviceRef)];
15415
- if (value)
15416
- return value;
15417
- }
15418
- return unref(defaultRef);
15419
- });
15420
- }),
15421
- removeAllMarks: createCommand(({ state, commands: commands2 }) => {
15422
- const { tr, doc: doc2 } = state;
15423
- const { from: from2, to } = tr.selection;
15424
- doc2.nodesBetween(from2, to, (node, position) => {
15425
- for (const mark of node.marks) {
15426
- commands2._removeNodeMark({ tr, node, position, mark });
15427
- }
15428
- });
15429
- }),
15430
- removeMarks: createCommand(({ state, commands: commands2 }, marks) => {
15431
- const { tr, doc: doc2 } = state;
15432
- const { from: from2, to } = tr.selection;
15433
- doc2.nodesBetween(from2, to, (node, position) => {
15434
- const removingMarks = node.marks.filter((mark) => marks.includes(mark.type.name));
15435
- for (const mark of removingMarks) {
15436
- commands2._removeNodeMark({ tr, node, position, mark });
15437
- }
15438
- });
15439
- }),
15440
- _removeNodeMark: createCommand((context, { tr, node, position, mark }) => {
15441
- return node.isText ? tr.removeMark(position, position + node.nodeSize, mark) : tr.removeNodeMark(position, mark);
15442
- })
15443
- };
15316
+ class ProseMirrorPlugin {
15317
+ static create(editor, options) {
15318
+ const plugin = new this(editor, options || {});
15319
+ return new Plugin({
15320
+ key: new PluginKey(this.name),
15321
+ props: plugin._buildProps()
15322
+ });
15444
15323
  }
15445
- });
15446
- const TextProcessor = Extension.create({
15447
- name: "text_processor",
15448
- addCommands() {
15449
- return {
15450
- getSelectedText: createCommand(({ state }) => {
15451
- const { from: from2, to } = state.selection;
15452
- return state.doc.textBetween(from2, to, " ");
15453
- }),
15454
- transformText: createCommand(({ state }, transform) => {
15455
- const { $from, $to } = state.tr.selection;
15456
- if ($from.pos === $to.pos)
15457
- return;
15458
- state.doc.nodesBetween($from.pos, $to.pos, (node, position) => {
15459
- if (!node.isText)
15460
- return;
15461
- const textPosition = resolveTextPosition($from, $to, node, position);
15462
- const substringFrom = Math.max(0, $from.pos - position);
15463
- const substringTo = Math.max(0, $to.pos - position);
15464
- const updatedText = transform({
15465
- text: node.textContent.substring(substringFrom, substringTo)
15466
- });
15467
- const updatedNode = state.schema.text(updatedText, node.marks);
15468
- state.tr.replaceWith(textPosition.from, textPosition.to, updatedNode);
15469
- });
15470
- })
15471
- };
15324
+ constructor(editor, options) {
15325
+ this.options = options;
15326
+ this.editor = editor;
15472
15327
  }
15473
- });
15474
- const SelectionProcessor = Extension.create({
15475
- name: "selection_processor",
15476
- addStorage: () => ({
15477
- selection: null
15478
- }),
15479
- addCommands() {
15480
- return {
15481
- storeSelection: createCommand(({ state }) => {
15482
- this.storage.selection = state.selection;
15483
- }),
15484
- restoreSelection: createCommand(({ commands: commands2 }) => {
15485
- this.storage.selection && commands2.setTextSelection(this.storage.selection);
15486
- }),
15487
- expandSelection: createCommand(({ tr, commands: commands2 }, predicate) => {
15488
- let from2 = tr.selection.from;
15489
- let to = tr.selection.to;
15490
- tr.doc.nodesBetween(from2, to, (node, position, parent) => {
15491
- if (predicate({ node, parent })) {
15492
- const offset2 = node.isText ? 0 : resolvePositionOffset(tr.doc, position);
15493
- from2 = Math.min(from2, position + offset2);
15494
- to = Math.max(to, position + node.nodeSize - offset2);
15495
- }
15496
- });
15497
- commands2.setTextSelection({ from: from2, to });
15498
- }),
15499
- expandSelectionToBlock: createCommand(({ commands: commands2 }) => {
15500
- commands2.expandSelection(({ parent }) => parent.type.name === NodeTypes.DOCUMENT);
15501
- })
15502
- };
15328
+ _buildProps() {
15329
+ const props = Object.entries(this.addProps());
15330
+ const bound = props.map(([name, handler]) => [name, handler.bind(this)]);
15331
+ return Object.fromEntries(bound);
15503
15332
  }
15504
- });
15505
- const Document$1 = Node2.create({
15506
- name: "doc",
15507
- topNode: true,
15508
- content: "block+"
15509
- });
15510
- const Document = Document$1.extend({
15511
- marks: MarkGroups.SETTINGS,
15512
- onCreate() {
15513
- this.editor.view.dom.addEventListener("click", (event) => {
15514
- if (event.target.closest("a"))
15515
- event.preventDefault();
15516
- });
15333
+ addProps() {
15334
+ return {};
15517
15335
  }
15518
- });
15519
- const Paragraph$1 = Node2.create({
15520
- name: "paragraph",
15521
- priority: 1e3,
15522
- addOptions() {
15523
- return {
15524
- HTMLAttributes: {}
15525
- };
15526
- },
15527
- group: "block",
15528
- content: "inline*",
15529
- parseHTML() {
15530
- return [
15531
- { tag: "p" }
15532
- ];
15533
- },
15534
- renderHTML({ HTMLAttributes }) {
15535
- return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
15536
- },
15537
- addCommands() {
15538
- return {
15539
- setParagraph: () => ({ commands: commands2 }) => {
15540
- return commands2.setNode(this.name);
15541
- }
15542
- };
15543
- },
15544
- addKeyboardShortcuts() {
15336
+ }
15337
+ class PastePlugin extends ProseMirrorPlugin {
15338
+ addProps() {
15545
15339
  return {
15546
- "Mod-Alt-0": () => this.editor.commands.setParagraph()
15547
- };
15548
- }
15549
- });
15550
- const Paragraph = Paragraph$1.extend({
15551
- marks: MarkGroups.ALL,
15552
- addOptions: () => ({
15553
- HTMLAttributes: { class: "zw-style" }
15554
- })
15555
- });
15556
- const Heading$1 = Node2.create({
15557
- name: "heading",
15558
- addOptions() {
15559
- return {
15560
- levels: [1, 2, 3, 4, 5, 6],
15561
- HTMLAttributes: {}
15562
- };
15563
- },
15564
- content: "inline*",
15565
- group: "block",
15566
- defining: true,
15567
- addAttributes() {
15568
- return {
15569
- level: {
15570
- default: 1,
15571
- rendered: false
15572
- }
15573
- };
15574
- },
15575
- parseHTML() {
15576
- return this.options.levels.map((level) => ({
15577
- tag: `h${level}`,
15578
- attrs: { level }
15579
- }));
15580
- },
15581
- renderHTML({ node, HTMLAttributes }) {
15582
- const hasLevel = this.options.levels.includes(node.attrs.level);
15583
- const level = hasLevel ? node.attrs.level : this.options.levels[0];
15584
- return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
15585
- },
15586
- addCommands() {
15587
- return {
15588
- setHeading: (attributes) => ({ commands: commands2 }) => {
15589
- if (!this.options.levels.includes(attributes.level)) {
15590
- return false;
15591
- }
15592
- return commands2.setNode(this.name, attributes);
15593
- },
15594
- toggleHeading: (attributes) => ({ commands: commands2 }) => {
15595
- if (!this.options.levels.includes(attributes.level)) {
15596
- return false;
15597
- }
15598
- return commands2.toggleNode(this.name, "paragraph", attributes);
15599
- }
15600
- };
15601
- },
15602
- addKeyboardShortcuts() {
15603
- return this.options.levels.reduce((items, level) => ({
15604
- ...items,
15605
- ...{
15606
- [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
15607
- }
15608
- }), {});
15609
- },
15610
- addInputRules() {
15611
- return this.options.levels.map((level) => {
15612
- return textblockTypeInputRule({
15613
- find: new RegExp(`^(#{1,${level}})\\s$`),
15614
- type: this.type,
15615
- getAttributes: {
15616
- level
15617
- }
15618
- });
15619
- });
15620
- }
15621
- });
15622
- const Heading = Heading$1.extend({
15623
- marks: MarkGroups.ALL,
15624
- addOptions: () => ({
15625
- levels: [1, 2, 3, 4],
15626
- HTMLAttributes: { class: "zw-style" }
15627
- })
15628
- });
15629
- class ProseMirrorPlugin {
15630
- static create(editor, options) {
15631
- const plugin = new this(editor, options || {});
15632
- return new Plugin({
15633
- key: new PluginKey(this.name),
15634
- props: plugin.buildProps()
15635
- });
15636
- }
15637
- constructor(editor, options) {
15638
- this.options = options;
15639
- this.editor = editor;
15640
- }
15641
- buildProps() {
15642
- return {};
15643
- }
15644
- }
15645
- class PastePlugin extends ProseMirrorPlugin {
15646
- buildProps() {
15647
- return {
15648
- transformPastedHTML: this._transformPastedHTML.bind(this),
15649
- handlePaste: this._handlePaste.bind(this)
15340
+ transformPastedHTML: this._transformPastedHTML,
15341
+ handlePaste: this._handlePaste
15650
15342
  };
15651
15343
  }
15652
15344
  _transformPastedHTML(html2) {
@@ -15701,8 +15393,8 @@ class PastePlugin extends ProseMirrorPlugin {
15701
15393
  }
15702
15394
  }
15703
15395
  class PlaceholderPlugin extends ProseMirrorPlugin {
15704
- buildProps() {
15705
- return { decorations: this._buildDecorations.bind(this) };
15396
+ addProps() {
15397
+ return { decorations: this._buildDecorations };
15706
15398
  }
15707
15399
  _buildDecorations({ doc: doc2 }) {
15708
15400
  const decorations = [];
@@ -15723,1809 +15415,2142 @@ class PlaceholderPlugin extends ProseMirrorPlugin {
15723
15415
  return DecorationSet.create(doc2, decorations);
15724
15416
  }
15725
15417
  }
15726
- const ProseMirrorPlugins = Extension.create({
15727
- name: "prose_mirror_plugins",
15728
- addProseMirrorPlugins() {
15729
- return [
15730
- PastePlugin.create(this.editor),
15731
- PlaceholderPlugin.create(this.editor)
15732
- ];
15733
- }
15734
- });
15735
- const buildCoreExtensions = () => [
15736
- Document,
15737
- Paragraph,
15738
- Heading,
15739
- Text$1,
15740
- History,
15741
- NodeProcessor,
15742
- TextProcessor,
15743
- SelectionProcessor,
15744
- ProseMirrorPlugins
15745
- ];
15746
- const FontFamily = Mark2.create({
15747
- name: TextSettings.FONT_FAMILY,
15748
- group: MarkGroups.SETTINGS,
15749
- addOptions: () => ({
15750
- fonts: []
15751
- }),
15752
- addAttributes: () => ({
15753
- value: { required: true }
15754
- }),
15755
- addCommands() {
15756
- return {
15757
- applyFontFamily: createCommand(({ commands: commands2 }, value) => {
15758
- commands2.applyMark(this.name, { value });
15759
- const font = commands2.findFontByName(value);
15760
- let fontWeight = unref(commands2.getFontWeight());
15761
- if (!font.isWeightSupported(fontWeight)) {
15762
- fontWeight = font.findClosestWeight(fontWeight);
15763
- commands2.applyFontWeight(fontWeight);
15764
- }
15765
- if (!font.isItalicSupported(fontWeight)) {
15766
- commands2.removeItalic();
15767
- }
15768
- }),
15769
- getFont: createCommand(({ commands: commands2 }) => {
15770
- const defaultPreset = unref(this.options.defaultPreset);
15771
- const defaultFont = commands2.findFontByName(defaultPreset.common.font_family);
15772
- const fontFamily = commands2.getFontFamily();
15773
- return computed(() => commands2.findFontByName(unref(fontFamily)) || defaultFont);
15774
- }),
15775
- findFontByName: createCommand((_, name) => {
15776
- return this.options.fonts.find((font) => font.name === name);
15777
- }),
15778
- getFontFamily: createCommand(({ commands: commands2 }) => {
15779
- return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontFamily());
15780
- }),
15781
- getDefaultFontFamily: createCommand(({ commands: commands2 }) => {
15782
- const preset = commands2.getPreset();
15783
- return computed(() => unref(preset).common.font_family);
15784
- })
15785
- };
15786
- },
15787
- parseHTML() {
15788
- const getAttrs = (input) => ({ value: input.replace(/["']/g, "") });
15789
- return [
15790
- {
15791
- style: "--zw-font-family",
15792
- getAttrs
15793
- },
15794
- {
15795
- style: "font-family",
15796
- getAttrs
15797
- }
15798
- ];
15799
- },
15800
- renderHTML({ HTMLAttributes: attrs }) {
15801
- const font_family = attrs.value ? `"${attrs.value}"` : null;
15802
- return renderMark({ font_family });
15803
- }
15804
- });
15805
- const StylePreset = Extension.create({
15806
- name: TextSettings.STYLE_PRESET,
15807
- addGlobalAttributes() {
15808
- return [
15809
- {
15810
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
15811
- attributes: {
15812
- preset: {
15813
- isRequired: false,
15814
- default: { id: this.options.defaultId },
15815
- parseHTML: (element) => {
15816
- const presets = unref(this.options.presets);
15817
- if (element.parentElement.tagName === "LI")
15818
- return null;
15819
- for (const { id: id2, node, fallbackClass } of presets) {
15820
- if (fallbackClass && element.classList.contains(fallbackClass)) {
15821
- return { id: id2 };
15822
- }
15823
- const presetSelector = this.options.styleRenderer.makePresetCssClass({ id: id2 });
15824
- if (element.matches(presetSelector))
15825
- return { id: id2 };
15826
- if (element.tagName === `H${node == null ? void 0 : node.level}`)
15827
- return { id: id2 };
15828
- }
15829
- return element.tagName === "P" ? { id: this.options.defaultId } : null;
15830
- },
15831
- renderHTML: (attrs) => {
15832
- if (!attrs.preset)
15833
- return null;
15834
- return { class: this.options.styleRenderer.makePresetHtmlClass(attrs.preset) };
15835
- }
15836
- }
15837
- }
15838
- }
15839
- ];
15418
+ function State(token) {
15419
+ this.j = {};
15420
+ this.jr = [];
15421
+ this.jd = null;
15422
+ this.t = token;
15423
+ }
15424
+ State.prototype = {
15425
+ accepts: function accepts() {
15426
+ return !!this.t;
15840
15427
  },
15841
- addCommands() {
15842
- function findPresetById(presets, id2) {
15843
- return presets.find((preset) => id2 === preset.id);
15428
+ tt: function tt(input, tokenOrState) {
15429
+ if (tokenOrState && tokenOrState.j) {
15430
+ this.j[input] = tokenOrState;
15431
+ return tokenOrState;
15844
15432
  }
15845
- function mergeSettings(source, target) {
15846
- const settings = {};
15847
- for (const name of Object.keys(source)) {
15848
- const sourceValue = source[name];
15849
- const targetValue = target[name];
15850
- const isInherit = !targetValue || targetValue.toLowerCase() === "inherit";
15851
- settings[name] = isInherit ? sourceValue : targetValue;
15433
+ var token = tokenOrState;
15434
+ var nextState = this.j[input];
15435
+ if (nextState) {
15436
+ if (token) {
15437
+ nextState.t = token;
15852
15438
  }
15853
- return settings;
15439
+ return nextState;
15854
15440
  }
15855
- return {
15856
- getPresetList: createCommand(() => computed(() => {
15857
- return this.options.presets.filter((preset) => !preset.hidden);
15858
- })),
15859
- getPreset: createCommand(({ commands: commands2 }) => {
15860
- const selectionRef = commands2.getBlockAttributes("preset", { id: this.options.defaultId });
15861
- const presetsRef = commands2.getPresetList();
15862
- const isLinkRef = commands2.isLink();
15863
- const linkPresetRef = commands2.getLinkPreset();
15864
- return computed(() => {
15865
- const preset = findPresetById(unref(presetsRef), unref(selectionRef).id);
15866
- if (!unref(isLinkRef))
15867
- return preset;
15868
- const linkPreset = unref(linkPresetRef);
15869
- return {
15870
- id: preset.id,
15871
- common: mergeSettings(preset.common, linkPreset.common),
15872
- mobile: mergeSettings(preset.mobile, linkPreset.mobile),
15873
- tablet: mergeSettings(preset.tablet, linkPreset.tablet),
15874
- desktop: mergeSettings(preset.desktop, linkPreset.desktop)
15875
- };
15876
- });
15877
- }),
15878
- applyPreset: createCommand(({ commands: commands2, chain }, presetId) => {
15879
- var _a;
15880
- const presets = unref(commands2.getPresetList());
15881
- const preset = findPresetById(presets, presetId);
15882
- const nodeType = ((_a = preset.node) == null ? void 0 : _a.type) ?? NodeTypes.PARAGRAPH;
15883
- const attrs = {
15884
- preset: { id: presetId }
15885
- };
15886
- if (preset.node) {
15887
- attrs.level = preset.node.level;
15888
- }
15889
- for (const textAttribute of TextSettings.attributes) {
15890
- attrs[textAttribute] = unref(commands2.getBlockAttributes(textAttribute));
15891
- }
15892
- chain().removeList().setNode(nodeType, attrs).run();
15893
- }),
15894
- applyDefaultPreset: createCommand(({ commands: commands2 }) => {
15895
- commands2.applyPreset(this.options.defaultId);
15896
- }),
15897
- removePreset: createCommand(({ commands: commands2 }) => {
15898
- commands2.setNode(NodeTypes.PARAGRAPH, { preset: null });
15899
- }),
15900
- getPresetCustomization: createCommand(({ editor, commands: commands2 }) => {
15901
- const state = toRef(editor, "state");
15902
- return computed(() => {
15903
- const { selection, doc: doc2 } = unref(state);
15904
- const { from: from2, to } = selection;
15905
- return commands2._getSettingCustomization(doc2, from2, to);
15906
- });
15907
- }),
15908
- isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
15909
- const customization = commands2.getPresetCustomization();
15910
- const group = TextSettings.attributes.includes(name) ? "attributes" : "marks";
15911
- return computed(() => {
15912
- var _a;
15913
- return ((_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) ?? false;
15914
- });
15915
- }),
15916
- getContentCustomization: createCommand(({ editor, commands: commands2 }) => {
15917
- const state = toRef(editor, "state");
15918
- return computed(() => {
15919
- const { doc: doc2 } = unref(state);
15920
- return commands2._getSettingCustomization(doc2, 0, doc2.content.size);
15921
- });
15922
- }),
15923
- _getSettingCustomization: createCommand((_, doc2, from2, to) => {
15924
- const marks = /* @__PURE__ */ new Set();
15925
- const attributes = /* @__PURE__ */ new Set();
15926
- doc2.nodesBetween(from2, to, (node) => {
15927
- for (const [name, value] of Object.entries(node.attrs)) {
15928
- const isSetting = TextSettings.attributes.includes(name);
15929
- if (isSetting && value)
15930
- attributes.add(name);
15931
- }
15932
- for (const { type } of node.marks) {
15933
- if (TextSettings.marks.includes(type.name)) {
15934
- marks.add(type.name);
15935
- }
15936
- }
15937
- });
15938
- return {
15939
- attributes: Array.from(attributes),
15940
- marks: Array.from(marks)
15941
- };
15942
- }),
15943
- removePresetCustomization: createCommand(({ chain }) => {
15944
- chain().storeSelection().expandSelectionToBlock().removeMarks(TextSettings.marks).resetAttributes(NodeTypes.PARAGRAPH, TextSettings.attributes).resetAttributes(NodeTypes.HEADING, TextSettings.attributes).restoreSelection().run();
15945
- }),
15946
- removeFormat: createCommand(({ chain }) => {
15947
- chain().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run();
15948
- })
15441
+ nextState = makeState();
15442
+ var templateState = takeT(this, input);
15443
+ if (templateState) {
15444
+ Object.assign(nextState.j, templateState.j);
15445
+ nextState.jr.append(templateState.jr);
15446
+ nextState.jr = templateState.jd;
15447
+ nextState.t = token || templateState.t;
15448
+ } else {
15449
+ nextState.t = token;
15450
+ }
15451
+ this.j[input] = nextState;
15452
+ return nextState;
15453
+ }
15454
+ };
15455
+ var makeState = function makeState2() {
15456
+ return new State();
15457
+ };
15458
+ var makeAcceptingState = function makeAcceptingState2(token) {
15459
+ return new State(token);
15460
+ };
15461
+ var makeT = function makeT2(startState, input, nextState) {
15462
+ if (!startState.j[input]) {
15463
+ startState.j[input] = nextState;
15464
+ }
15465
+ };
15466
+ var makeRegexT = function makeRegexT2(startState, regex, nextState) {
15467
+ startState.jr.push([regex, nextState]);
15468
+ };
15469
+ var takeT = function takeT2(state, input) {
15470
+ var nextState = state.j[input];
15471
+ if (nextState) {
15472
+ return nextState;
15473
+ }
15474
+ for (var i = 0; i < state.jr.length; i++) {
15475
+ var regex = state.jr[i][0];
15476
+ var _nextState = state.jr[i][1];
15477
+ if (regex.test(input)) {
15478
+ return _nextState;
15479
+ }
15480
+ }
15481
+ return state.jd;
15482
+ };
15483
+ var makeMultiT = function makeMultiT2(startState, chars, nextState) {
15484
+ for (var i = 0; i < chars.length; i++) {
15485
+ makeT(startState, chars[i], nextState);
15486
+ }
15487
+ };
15488
+ var makeBatchT = function makeBatchT2(startState, transitions) {
15489
+ for (var i = 0; i < transitions.length; i++) {
15490
+ var input = transitions[i][0];
15491
+ var nextState = transitions[i][1];
15492
+ makeT(startState, input, nextState);
15493
+ }
15494
+ };
15495
+ var makeChainT = function makeChainT2(state, str, endState, defaultStateFactory) {
15496
+ var i = 0, len = str.length, nextState;
15497
+ while (i < len && (nextState = state.j[str[i]])) {
15498
+ state = nextState;
15499
+ i++;
15500
+ }
15501
+ if (i >= len) {
15502
+ return [];
15503
+ }
15504
+ while (i < len - 1) {
15505
+ nextState = defaultStateFactory();
15506
+ makeT(state, str[i], nextState);
15507
+ state = nextState;
15508
+ i++;
15509
+ }
15510
+ makeT(state, str[len - 1], endState);
15511
+ };
15512
+ var DOMAIN = "DOMAIN";
15513
+ var LOCALHOST = "LOCALHOST";
15514
+ var TLD = "TLD";
15515
+ var NUM = "NUM";
15516
+ var PROTOCOL = "PROTOCOL";
15517
+ var MAILTO = "MAILTO";
15518
+ var WS = "WS";
15519
+ var NL = "NL";
15520
+ var OPENBRACE = "OPENBRACE";
15521
+ var OPENBRACKET = "OPENBRACKET";
15522
+ var OPENANGLEBRACKET = "OPENANGLEBRACKET";
15523
+ var OPENPAREN = "OPENPAREN";
15524
+ var CLOSEBRACE = "CLOSEBRACE";
15525
+ var CLOSEBRACKET = "CLOSEBRACKET";
15526
+ var CLOSEANGLEBRACKET = "CLOSEANGLEBRACKET";
15527
+ var CLOSEPAREN = "CLOSEPAREN";
15528
+ var AMPERSAND = "AMPERSAND";
15529
+ var APOSTROPHE = "APOSTROPHE";
15530
+ var ASTERISK = "ASTERISK";
15531
+ var AT = "AT";
15532
+ var BACKSLASH = "BACKSLASH";
15533
+ var BACKTICK = "BACKTICK";
15534
+ var CARET = "CARET";
15535
+ var COLON = "COLON";
15536
+ var COMMA = "COMMA";
15537
+ var DOLLAR = "DOLLAR";
15538
+ var DOT = "DOT";
15539
+ var EQUALS = "EQUALS";
15540
+ var EXCLAMATION = "EXCLAMATION";
15541
+ var HYPHEN = "HYPHEN";
15542
+ var PERCENT = "PERCENT";
15543
+ var PIPE = "PIPE";
15544
+ var PLUS = "PLUS";
15545
+ var POUND = "POUND";
15546
+ var QUERY = "QUERY";
15547
+ var QUOTE = "QUOTE";
15548
+ var SEMI = "SEMI";
15549
+ var SLASH = "SLASH";
15550
+ var TILDE = "TILDE";
15551
+ var UNDERSCORE = "UNDERSCORE";
15552
+ var SYM = "SYM";
15553
+ var text = /* @__PURE__ */ Object.freeze({
15554
+ __proto__: null,
15555
+ DOMAIN,
15556
+ LOCALHOST,
15557
+ TLD,
15558
+ NUM,
15559
+ PROTOCOL,
15560
+ MAILTO,
15561
+ WS,
15562
+ NL,
15563
+ OPENBRACE,
15564
+ OPENBRACKET,
15565
+ OPENANGLEBRACKET,
15566
+ OPENPAREN,
15567
+ CLOSEBRACE,
15568
+ CLOSEBRACKET,
15569
+ CLOSEANGLEBRACKET,
15570
+ CLOSEPAREN,
15571
+ AMPERSAND,
15572
+ APOSTROPHE,
15573
+ ASTERISK,
15574
+ AT,
15575
+ BACKSLASH,
15576
+ BACKTICK,
15577
+ CARET,
15578
+ COLON,
15579
+ COMMA,
15580
+ DOLLAR,
15581
+ DOT,
15582
+ EQUALS,
15583
+ EXCLAMATION,
15584
+ HYPHEN,
15585
+ PERCENT,
15586
+ PIPE,
15587
+ PLUS,
15588
+ POUND,
15589
+ QUERY,
15590
+ QUOTE,
15591
+ SEMI,
15592
+ SLASH,
15593
+ TILDE,
15594
+ UNDERSCORE,
15595
+ SYM
15596
+ });
15597
+ var tlds = "aaa aarp abarth abb abbott abbvie abc able abogado abudhabi ac academy accenture accountant accountants aco actor ad adac ads adult ae aeg aero aetna af afamilycompany afl africa ag agakhan agency ai aig airbus airforce airtel akdn al alfaromeo alibaba alipay allfinanz allstate ally alsace alstom am amazon americanexpress americanfamily amex amfam amica amsterdam analytics android anquan anz ao aol apartments app apple aq aquarelle ar arab aramco archi army arpa art arte as asda asia associates at athleta attorney au auction audi audible audio auspost author auto autos avianca aw aws ax axa az azure ba baby baidu banamex bananarepublic band bank bar barcelona barclaycard barclays barefoot bargains baseball basketball bauhaus bayern bb bbc bbt bbva bcg bcn bd be beats beauty beer bentley berlin best bestbuy bet bf bg bh bharti bi bible bid bike bing bingo bio biz bj black blackfriday blockbuster blog bloomberg blue bm bms bmw bn bnpparibas bo boats boehringer bofa bom bond boo book booking bosch bostik boston bot boutique box br bradesco bridgestone broadway broker brother brussels bs bt budapest bugatti build builders business buy buzz bv bw by bz bzh ca cab cafe cal call calvinklein cam camera camp cancerresearch canon capetown capital capitalone car caravan cards care career careers cars casa case cash casino cat catering catholic cba cbn cbre cbs cc cd center ceo cern cf cfa cfd cg ch chanel channel charity chase chat cheap chintai christmas chrome church ci cipriani circle cisco citadel citi citic city cityeats ck cl claims cleaning click clinic clinique clothing cloud club clubmed cm cn co coach codes coffee college cologne com comcast commbank community company compare computer comsec condos construction consulting contact contractors cooking cookingchannel cool coop corsica country coupon coupons courses cpa cr credit creditcard creditunion cricket crown crs cruise cruises csc cu cuisinella cv cw cx cy cymru cyou cz dabur dad dance data date dating datsun day dclk dds de deal dealer deals degree delivery dell deloitte delta democrat dental dentist desi design dev dhl diamonds diet digital direct directory discount discover dish diy dj dk dm dnp do docs doctor dog domains dot download drive dtv dubai duck dunlop dupont durban dvag dvr dz earth eat ec eco edeka edu education ee eg email emerck energy engineer engineering enterprises epson equipment er ericsson erni es esq estate et etisalat eu eurovision eus events exchange expert exposed express extraspace fage fail fairwinds faith family fan fans farm farmers fashion fast fedex feedback ferrari ferrero fi fiat fidelity fido film final finance financial fire firestone firmdale fish fishing fit fitness fj fk flickr flights flir florist flowers fly fm fo foo food foodnetwork football ford forex forsale forum foundation fox fr free fresenius frl frogans frontdoor frontier ftr fujitsu fujixerox fun fund furniture futbol fyi ga gal gallery gallo gallup game games gap garden gay gb gbiz gd gdn ge gea gent genting george gf gg ggee gh gi gift gifts gives giving gl glade glass gle global globo gm gmail gmbh gmo gmx gn godaddy gold goldpoint golf goo goodyear goog google gop got gov gp gq gr grainger graphics gratis green gripe grocery group gs gt gu guardian gucci guge guide guitars guru gw gy hair hamburg hangout haus hbo hdfc hdfcbank health healthcare help helsinki here hermes hgtv hiphop hisamitsu hitachi hiv hk hkt hm hn hockey holdings holiday homedepot homegoods homes homesense honda horse hospital host hosting hot hoteles hotels hotmail house how hr hsbc ht hu hughes hyatt hyundai ibm icbc ice icu id ie ieee ifm ikano il im imamat imdb immo immobilien in inc industries infiniti info ing ink institute insurance insure int international intuit investments io ipiranga iq ir irish is ismaili ist istanbul it itau itv iveco jaguar java jcb je jeep jetzt jewelry jio jll jm jmp jnj jo jobs joburg jot joy jp jpmorgan jprs juegos juniper kaufen kddi ke kerryhotels kerrylogistics kerryproperties kfh kg kh ki kia kim kinder kindle kitchen kiwi km kn koeln komatsu kosher kp kpmg kpn kr krd kred kuokgroup kw ky kyoto kz la lacaixa lamborghini lamer lancaster lancia land landrover lanxess lasalle lat latino latrobe law lawyer lb lc lds lease leclerc lefrak legal lego lexus lgbt li lidl life lifeinsurance lifestyle lighting like lilly limited limo lincoln linde link lipsy live living lixil lk llc llp loan loans locker locus loft lol london lotte lotto love lpl lplfinancial lr ls lt ltd ltda lu lundbeck luxe luxury lv ly ma macys madrid maif maison makeup man management mango map market marketing markets marriott marshalls maserati mattel mba mc mckinsey md me med media meet melbourne meme memorial men menu merckmsd mg mh miami microsoft mil mini mint mit mitsubishi mk ml mlb mls mm mma mn mo mobi mobile moda moe moi mom monash money monster mormon mortgage moscow moto motorcycles mov movie mp mq mr ms msd mt mtn mtr mu museum mutual mv mw mx my mz na nab nagoya name nationwide natura navy nba nc ne nec net netbank netflix network neustar new news next nextdirect nexus nf nfl ng ngo nhk ni nico nike nikon ninja nissan nissay nl no nokia northwesternmutual norton now nowruz nowtv np nr nra nrw ntt nu nyc nz obi observer off office okinawa olayan olayangroup oldnavy ollo om omega one ong onl online onyourside ooo open oracle orange org organic origins osaka otsuka ott ovh pa page panasonic paris pars partners parts party passagens pay pccw pe pet pf pfizer pg ph pharmacy phd philips phone photo photography photos physio pics pictet pictures pid pin ping pink pioneer pizza pk pl place play playstation plumbing plus pm pn pnc pohl poker politie porn post pr pramerica praxi press prime pro prod productions prof progressive promo properties property protection pru prudential ps pt pub pw pwc py qa qpon quebec quest qvc racing radio raid re read realestate realtor realty recipes red redstone redumbrella rehab reise reisen reit reliance ren rent rentals repair report republican rest restaurant review reviews rexroth rich richardli ricoh ril rio rip rmit ro rocher rocks rodeo rogers room rs rsvp ru rugby ruhr run rw rwe ryukyu sa saarland safe safety sakura sale salon samsclub samsung sandvik sandvikcoromant sanofi sap sarl sas save saxo sb sbi sbs sc sca scb schaeffler schmidt scholarships school schule schwarz science scjohnson scot sd se search seat secure security seek select sener services ses seven sew sex sexy sfr sg sh shangrila sharp shaw shell shia shiksha shoes shop shopping shouji show showtime si silk sina singles site sj sk ski skin sky skype sl sling sm smart smile sn sncf so soccer social softbank software sohu solar solutions song sony soy spa space sport spot spreadbetting sr srl ss st stada staples star statebank statefarm stc stcgroup stockholm storage store stream studio study style su sucks supplies supply support surf surgery suzuki sv swatch swiftcover swiss sx sy sydney systems sz tab taipei talk taobao target tatamotors tatar tattoo tax taxi tc tci td tdk team tech technology tel temasek tennis teva tf tg th thd theater theatre tiaa tickets tienda tiffany tips tires tirol tj tjmaxx tjx tk tkmaxx tl tm tmall tn to today tokyo tools top toray toshiba total tours town toyota toys tr trade trading training travel travelchannel travelers travelersinsurance trust trv tt tube tui tunes tushu tv tvs tw tz ua ubank ubs ug uk unicom university uno uol ups us uy uz va vacations vana vanguard vc ve vegas ventures verisign versicherung vet vg vi viajes video vig viking villas vin vip virgin visa vision viva vivo vlaanderen vn vodka volkswagen volvo vote voting voto voyage vu vuelos wales walmart walter wang wanggou watch watches weather weatherchannel webcam weber website wed wedding weibo weir wf whoswho wien wiki williamhill win windows wine winners wme wolterskluwer woodside work works world wow ws wtc wtf xbox xerox xfinity xihuan xin xxx xyz yachts yahoo yamaxun yandex ye yodobashi yoga yokohama you youtube yt yun za zappos zara zero zip zm zone zuerich zw vermögensberater-ctb vermögensberatung-pwb ελ ευ бг бел дети ею католик ком қаз мкд мон москва онлайн орг рус рф сайт срб укр გე հայ ישראל קום ابوظبي اتصالات ارامكو الاردن البحرين الجزائر السعودية العليان المغرب امارات ایران بارت بازار بھارت بيتك پاکستان ڀارت تونس سودان سورية شبكة عراق عرب عمان فلسطين قطر كاثوليك كوم مصر مليسيا موريتانيا موقع همراه कॉम नेट भारत भारतम् भारोत संगठन বাংলা ভারত ভাৰত ਭਾਰਤ ભારત ଭାରତ இந்தியா இலங்கை சிங்கப்பூர் భారత్ ಭಾರತ ഭാരതം ලංකා คอม ไทย ລາວ 닷넷 닷컴 삼성 한국 アマゾン グーグル クラウド コム ストア セール ファッション ポイント みんな 世界 中信 中国 中國 中文网 亚马逊 企业 佛山 信息 健康 八卦 公司 公益 台湾 台灣 商城 商店 商标 嘉里 嘉里大酒店 在线 大众汽车 大拿 天主教 娱乐 家電 广东 微博 慈善 我爱你 手机 招聘 政务 政府 新加坡 新闻 时尚 書籍 机构 淡马锡 游戏 澳門 点看 移动 组织机构 网址 网店 网站 网络 联通 诺基亚 谷歌 购物 通販 集团 電訊盈科 飞利浦 食品 餐厅 香格里拉 香港".split(" ");
15598
+ var LETTER = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/;
15599
+ var EMOJI = /(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEDD-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE74\uDE78-\uDE7C\uDE80-\uDE86\uDE90-\uDEAC\uDEB0-\uDEBA\uDEC0-\uDEC5\uDED0-\uDED9\uDEE0-\uDEE7\uDEF0-\uDEF6])/;
15600
+ var EMOJI_VARIATION = /\uFE0F/;
15601
+ var DIGIT = /\d/;
15602
+ var SPACE = /\s/;
15603
+ function init$2() {
15604
+ var customProtocols = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
15605
+ var S_START = makeState();
15606
+ var S_NUM = makeAcceptingState(NUM);
15607
+ var S_DOMAIN = makeAcceptingState(DOMAIN);
15608
+ var S_DOMAIN_HYPHEN = makeState();
15609
+ var S_WS = makeAcceptingState(WS);
15610
+ var DOMAIN_REGEX_TRANSITIONS = [[DIGIT, S_DOMAIN], [LETTER, S_DOMAIN], [EMOJI, S_DOMAIN], [EMOJI_VARIATION, S_DOMAIN]];
15611
+ var makeDomainState = function makeDomainState2() {
15612
+ var state = makeAcceptingState(DOMAIN);
15613
+ state.j = {
15614
+ "-": S_DOMAIN_HYPHEN
15949
15615
  };
15616
+ state.jr = [].concat(DOMAIN_REGEX_TRANSITIONS);
15617
+ return state;
15618
+ };
15619
+ var makeNearDomainState = function makeNearDomainState2(token) {
15620
+ var state = makeDomainState();
15621
+ state.t = token;
15622
+ return state;
15623
+ };
15624
+ makeBatchT(S_START, [["'", makeAcceptingState(APOSTROPHE)], ["{", makeAcceptingState(OPENBRACE)], ["[", makeAcceptingState(OPENBRACKET)], ["<", makeAcceptingState(OPENANGLEBRACKET)], ["(", makeAcceptingState(OPENPAREN)], ["}", makeAcceptingState(CLOSEBRACE)], ["]", makeAcceptingState(CLOSEBRACKET)], [">", makeAcceptingState(CLOSEANGLEBRACKET)], [")", makeAcceptingState(CLOSEPAREN)], ["&", makeAcceptingState(AMPERSAND)], ["*", makeAcceptingState(ASTERISK)], ["@", makeAcceptingState(AT)], ["`", makeAcceptingState(BACKTICK)], ["^", makeAcceptingState(CARET)], [":", makeAcceptingState(COLON)], [",", makeAcceptingState(COMMA)], ["$", makeAcceptingState(DOLLAR)], [".", makeAcceptingState(DOT)], ["=", makeAcceptingState(EQUALS)], ["!", makeAcceptingState(EXCLAMATION)], ["-", makeAcceptingState(HYPHEN)], ["%", makeAcceptingState(PERCENT)], ["|", makeAcceptingState(PIPE)], ["+", makeAcceptingState(PLUS)], ["#", makeAcceptingState(POUND)], ["?", makeAcceptingState(QUERY)], ['"', makeAcceptingState(QUOTE)], ["/", makeAcceptingState(SLASH)], [";", makeAcceptingState(SEMI)], ["~", makeAcceptingState(TILDE)], ["_", makeAcceptingState(UNDERSCORE)], ["\\", makeAcceptingState(BACKSLASH)]]);
15625
+ makeT(S_START, "\n", makeAcceptingState(NL));
15626
+ makeRegexT(S_START, SPACE, S_WS);
15627
+ makeT(S_WS, "\n", makeState());
15628
+ makeRegexT(S_WS, SPACE, S_WS);
15629
+ for (var i = 0; i < tlds.length; i++) {
15630
+ makeChainT(S_START, tlds[i], makeNearDomainState(TLD), makeDomainState);
15631
+ }
15632
+ var S_PROTOCOL_FILE = makeDomainState();
15633
+ var S_PROTOCOL_FTP = makeDomainState();
15634
+ var S_PROTOCOL_HTTP = makeDomainState();
15635
+ var S_MAILTO = makeDomainState();
15636
+ makeChainT(S_START, "file", S_PROTOCOL_FILE, makeDomainState);
15637
+ makeChainT(S_START, "ftp", S_PROTOCOL_FTP, makeDomainState);
15638
+ makeChainT(S_START, "http", S_PROTOCOL_HTTP, makeDomainState);
15639
+ makeChainT(S_START, "mailto", S_MAILTO, makeDomainState);
15640
+ var S_PROTOCOL_SECURE = makeDomainState();
15641
+ var S_FULL_PROTOCOL = makeAcceptingState(PROTOCOL);
15642
+ var S_FULL_MAILTO = makeAcceptingState(MAILTO);
15643
+ makeT(S_PROTOCOL_FTP, "s", S_PROTOCOL_SECURE);
15644
+ makeT(S_PROTOCOL_FTP, ":", S_FULL_PROTOCOL);
15645
+ makeT(S_PROTOCOL_HTTP, "s", S_PROTOCOL_SECURE);
15646
+ makeT(S_PROTOCOL_HTTP, ":", S_FULL_PROTOCOL);
15647
+ makeT(S_PROTOCOL_FILE, ":", S_FULL_PROTOCOL);
15648
+ makeT(S_PROTOCOL_SECURE, ":", S_FULL_PROTOCOL);
15649
+ makeT(S_MAILTO, ":", S_FULL_MAILTO);
15650
+ var S_CUSTOM_PROTOCOL = makeDomainState();
15651
+ for (var _i = 0; _i < customProtocols.length; _i++) {
15652
+ makeChainT(S_START, customProtocols[_i], S_CUSTOM_PROTOCOL, makeDomainState);
15653
+ }
15654
+ makeT(S_CUSTOM_PROTOCOL, ":", S_FULL_PROTOCOL);
15655
+ makeChainT(S_START, "localhost", makeNearDomainState(LOCALHOST), makeDomainState);
15656
+ makeRegexT(S_START, DIGIT, S_NUM);
15657
+ makeRegexT(S_START, LETTER, S_DOMAIN);
15658
+ makeRegexT(S_START, EMOJI, S_DOMAIN);
15659
+ makeRegexT(S_START, EMOJI_VARIATION, S_DOMAIN);
15660
+ makeRegexT(S_NUM, DIGIT, S_NUM);
15661
+ makeRegexT(S_NUM, LETTER, S_DOMAIN);
15662
+ makeRegexT(S_NUM, EMOJI, S_DOMAIN);
15663
+ makeRegexT(S_NUM, EMOJI_VARIATION, S_DOMAIN);
15664
+ makeT(S_NUM, "-", S_DOMAIN_HYPHEN);
15665
+ makeT(S_DOMAIN, "-", S_DOMAIN_HYPHEN);
15666
+ makeT(S_DOMAIN_HYPHEN, "-", S_DOMAIN_HYPHEN);
15667
+ makeRegexT(S_DOMAIN, DIGIT, S_DOMAIN);
15668
+ makeRegexT(S_DOMAIN, LETTER, S_DOMAIN);
15669
+ makeRegexT(S_DOMAIN, EMOJI, S_DOMAIN);
15670
+ makeRegexT(S_DOMAIN, EMOJI_VARIATION, S_DOMAIN);
15671
+ makeRegexT(S_DOMAIN_HYPHEN, DIGIT, S_DOMAIN);
15672
+ makeRegexT(S_DOMAIN_HYPHEN, LETTER, S_DOMAIN);
15673
+ makeRegexT(S_DOMAIN_HYPHEN, EMOJI, S_DOMAIN);
15674
+ makeRegexT(S_DOMAIN_HYPHEN, EMOJI_VARIATION, S_DOMAIN);
15675
+ S_START.jd = makeAcceptingState(SYM);
15676
+ return S_START;
15677
+ }
15678
+ function run$1(start2, str) {
15679
+ var iterable = stringToArray(str.replace(/[A-Z]/g, function(c) {
15680
+ return c.toLowerCase();
15681
+ }));
15682
+ var charCount = iterable.length;
15683
+ var tokens = [];
15684
+ var cursor = 0;
15685
+ var charCursor = 0;
15686
+ while (charCursor < charCount) {
15687
+ var state = start2;
15688
+ var nextState = null;
15689
+ var tokenLength = 0;
15690
+ var latestAccepting = null;
15691
+ var sinceAccepts = -1;
15692
+ var charsSinceAccepts = -1;
15693
+ while (charCursor < charCount && (nextState = takeT(state, iterable[charCursor]))) {
15694
+ state = nextState;
15695
+ if (state.accepts()) {
15696
+ sinceAccepts = 0;
15697
+ charsSinceAccepts = 0;
15698
+ latestAccepting = state;
15699
+ } else if (sinceAccepts >= 0) {
15700
+ sinceAccepts += iterable[charCursor].length;
15701
+ charsSinceAccepts++;
15702
+ }
15703
+ tokenLength += iterable[charCursor].length;
15704
+ cursor += iterable[charCursor].length;
15705
+ charCursor++;
15706
+ }
15707
+ cursor -= sinceAccepts;
15708
+ charCursor -= charsSinceAccepts;
15709
+ tokenLength -= sinceAccepts;
15710
+ tokens.push({
15711
+ t: latestAccepting.t,
15712
+ v: str.substr(cursor - tokenLength, tokenLength),
15713
+ s: cursor - tokenLength,
15714
+ e: cursor
15715
+ });
15716
+ }
15717
+ return tokens;
15718
+ }
15719
+ function stringToArray(str) {
15720
+ var result = [];
15721
+ var len = str.length;
15722
+ var index = 0;
15723
+ while (index < len) {
15724
+ var first2 = str.charCodeAt(index);
15725
+ var second = void 0;
15726
+ var char = first2 < 55296 || first2 > 56319 || index + 1 === len || (second = str.charCodeAt(index + 1)) < 56320 || second > 57343 ? str[index] : str.slice(index, index + 2);
15727
+ result.push(char);
15728
+ index += char.length;
15729
+ }
15730
+ return result;
15731
+ }
15732
+ function _typeof(obj) {
15733
+ "@babel/helpers - typeof";
15734
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
15735
+ _typeof = function(obj2) {
15736
+ return typeof obj2;
15737
+ };
15738
+ } else {
15739
+ _typeof = function(obj2) {
15740
+ return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
15741
+ };
15742
+ }
15743
+ return _typeof(obj);
15744
+ }
15745
+ var defaults = {
15746
+ defaultProtocol: "http",
15747
+ events: null,
15748
+ format: noop$1,
15749
+ formatHref: noop$1,
15750
+ nl2br: false,
15751
+ tagName: "a",
15752
+ target: null,
15753
+ rel: null,
15754
+ validate: true,
15755
+ truncate: 0,
15756
+ className: null,
15757
+ attributes: null,
15758
+ ignoreTags: []
15759
+ };
15760
+ function Options(opts) {
15761
+ opts = opts || {};
15762
+ this.defaultProtocol = "defaultProtocol" in opts ? opts.defaultProtocol : defaults.defaultProtocol;
15763
+ this.events = "events" in opts ? opts.events : defaults.events;
15764
+ this.format = "format" in opts ? opts.format : defaults.format;
15765
+ this.formatHref = "formatHref" in opts ? opts.formatHref : defaults.formatHref;
15766
+ this.nl2br = "nl2br" in opts ? opts.nl2br : defaults.nl2br;
15767
+ this.tagName = "tagName" in opts ? opts.tagName : defaults.tagName;
15768
+ this.target = "target" in opts ? opts.target : defaults.target;
15769
+ this.rel = "rel" in opts ? opts.rel : defaults.rel;
15770
+ this.validate = "validate" in opts ? opts.validate : defaults.validate;
15771
+ this.truncate = "truncate" in opts ? opts.truncate : defaults.truncate;
15772
+ this.className = "className" in opts ? opts.className : defaults.className;
15773
+ this.attributes = opts.attributes || defaults.attributes;
15774
+ this.ignoreTags = [];
15775
+ var ignoredTags = "ignoreTags" in opts ? opts.ignoreTags : defaults.ignoreTags;
15776
+ for (var i = 0; i < ignoredTags.length; i++) {
15777
+ this.ignoreTags.push(ignoredTags[i].toUpperCase());
15778
+ }
15779
+ }
15780
+ Options.prototype = {
15781
+ resolve: function resolve(token) {
15782
+ var href = token.toHref(this.defaultProtocol);
15783
+ return {
15784
+ formatted: this.get("format", token.toString(), token),
15785
+ formattedHref: this.get("formatHref", href, token),
15786
+ tagName: this.get("tagName", href, token),
15787
+ className: this.get("className", href, token),
15788
+ target: this.get("target", href, token),
15789
+ rel: this.get("rel", href, token),
15790
+ events: this.getObject("events", href, token),
15791
+ attributes: this.getObject("attributes", href, token),
15792
+ truncate: this.get("truncate", href, token)
15793
+ };
15794
+ },
15795
+ check: function check(token) {
15796
+ return this.get("validate", token.toString(), token);
15797
+ },
15798
+ get: function get2(key, operator, token) {
15799
+ var option = this[key];
15800
+ if (!option) {
15801
+ return option;
15802
+ }
15803
+ var optionValue;
15804
+ switch (_typeof(option)) {
15805
+ case "function":
15806
+ return option(operator, token.t);
15807
+ case "object":
15808
+ optionValue = token.t in option ? option[token.t] : defaults[key];
15809
+ return typeof optionValue === "function" ? optionValue(operator, token.t) : optionValue;
15810
+ }
15811
+ return option;
15812
+ },
15813
+ getObject: function getObject(key, operator, token) {
15814
+ var option = this[key];
15815
+ return typeof option === "function" ? option(operator, token.t) : option;
15816
+ }
15817
+ };
15818
+ function noop$1(val) {
15819
+ return val;
15820
+ }
15821
+ function inherits(parent, child) {
15822
+ var props = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
15823
+ var extended = Object.create(parent.prototype);
15824
+ for (var p in props) {
15825
+ extended[p] = props[p];
15826
+ }
15827
+ extended.constructor = child;
15828
+ child.prototype = extended;
15829
+ return child;
15830
+ }
15831
+ function MultiToken() {
15832
+ }
15833
+ MultiToken.prototype = {
15834
+ t: "token",
15835
+ isLink: false,
15836
+ toString: function toString() {
15837
+ return this.v;
15950
15838
  },
15951
- onCreate() {
15952
- this.options.styleRenderer.inject(ContextWindow.head, this.options.presets);
15953
- }
15954
- });
15955
- const FontWeight = Mark2.create({
15956
- name: TextSettings.FONT_WEIGHT,
15957
- group: MarkGroups.SETTINGS,
15958
- addAttributes: () => ({
15959
- value: { required: true }
15960
- }),
15961
- addCommands() {
15839
+ toHref: function toHref() {
15840
+ return this.toString();
15841
+ },
15842
+ startIndex: function startIndex() {
15843
+ return this.tk[0].s;
15844
+ },
15845
+ endIndex: function endIndex() {
15846
+ return this.tk[this.tk.length - 1].e;
15847
+ },
15848
+ toObject: function toObject() {
15849
+ var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults.defaultProtocol;
15962
15850
  return {
15963
- applyFontWeight: createCommand(({ commands: commands2 }, value) => {
15964
- commands2.applyMark(this.name, { value });
15965
- const font = unref(commands2.getFont());
15966
- if (!font.isItalicSupported(value)) {
15967
- commands2.removeItalic();
15968
- }
15969
- }),
15970
- toggleBold: createCommand(({ commands: commands2 }) => {
15971
- const currentWeight = unref(commands2.getFontWeight());
15972
- const currentFont = unref(commands2.getFont());
15973
- const isBold = Number(currentWeight) >= 600;
15974
- const wantedWeight = isBold ? "400" : "700";
15975
- const nextWeight = currentFont.findClosestWeight(wantedWeight);
15976
- commands2.applyFontWeight(nextWeight);
15977
- }),
15978
- getFontWeight: createCommand(({ commands: commands2 }) => {
15979
- const selectionRef = commands2.getCommonSettingMark(this.name, commands2.getDefaultFontWeight());
15980
- const fontRef = commands2.getFont();
15981
- return computed(() => {
15982
- const weight = unref(selectionRef);
15983
- const font = unref(fontRef);
15984
- return font.isWeightSupported(weight) ? weight : font.findClosestWeight(weight);
15985
- });
15986
- }),
15987
- getDefaultFontWeight: createCommand(({ commands: commands2 }) => {
15988
- const preset = commands2.getPreset();
15989
- return computed(() => unref(preset).common.font_weight);
15990
- })
15851
+ type: this.t,
15852
+ value: this.v,
15853
+ isLink: this.isLink,
15854
+ href: this.toHref(protocol),
15855
+ start: this.startIndex(),
15856
+ end: this.endIndex()
15991
15857
  };
15858
+ }
15859
+ };
15860
+ function createTokenClass(type, props) {
15861
+ function Token(value, tokens) {
15862
+ this.t = type;
15863
+ this.v = value;
15864
+ this.tk = tokens;
15865
+ }
15866
+ inherits(MultiToken, Token, props);
15867
+ return Token;
15868
+ }
15869
+ var MailtoEmail = createTokenClass("email", {
15870
+ isLink: true
15871
+ });
15872
+ var Email = createTokenClass("email", {
15873
+ isLink: true,
15874
+ toHref: function toHref2() {
15875
+ return "mailto:" + this.toString();
15876
+ }
15877
+ });
15878
+ var Text = createTokenClass("text");
15879
+ var Nl = createTokenClass("nl");
15880
+ var Url = createTokenClass("url", {
15881
+ isLink: true,
15882
+ toHref: function toHref3() {
15883
+ var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults.defaultProtocol;
15884
+ var tokens = this.tk;
15885
+ var hasProtocol2 = false;
15886
+ var hasSlashSlash = false;
15887
+ var result = [];
15888
+ var i = 0;
15889
+ while (tokens[i].t === PROTOCOL) {
15890
+ hasProtocol2 = true;
15891
+ result.push(tokens[i].v);
15892
+ i++;
15893
+ }
15894
+ while (tokens[i].t === SLASH) {
15895
+ hasSlashSlash = true;
15896
+ result.push(tokens[i].v);
15897
+ i++;
15898
+ }
15899
+ for (; i < tokens.length; i++) {
15900
+ result.push(tokens[i].v);
15901
+ }
15902
+ result = result.join("");
15903
+ if (!(hasProtocol2 || hasSlashSlash)) {
15904
+ result = "".concat(protocol, "://").concat(result);
15905
+ }
15906
+ return result;
15992
15907
  },
15993
- addKeyboardShortcuts: () => ({
15994
- "Mod-b": createKeyboardShortcut("toggleBold"),
15995
- "Mod-B": createKeyboardShortcut("toggleBold")
15996
- }),
15997
- parseHTML() {
15998
- const getAttrs = (value) => {
15999
- if (value === "bold")
16000
- return { value: "700" };
16001
- return Number(value) ? { value } : false;
16002
- };
16003
- return [
16004
- {
16005
- style: "--zw-font-weight",
16006
- getAttrs
16007
- },
16008
- {
16009
- style: "font-weight",
16010
- getAttrs
16011
- },
16012
- {
16013
- tag: "b",
16014
- attrs: { value: "700" }
16015
- },
16016
- {
16017
- tag: "strong",
16018
- attrs: { value: "700" }
15908
+ hasProtocol: function hasProtocol() {
15909
+ return this.tk[0].t === PROTOCOL;
15910
+ }
15911
+ });
15912
+ var multi = /* @__PURE__ */ Object.freeze({
15913
+ __proto__: null,
15914
+ MultiToken,
15915
+ Base: MultiToken,
15916
+ createTokenClass,
15917
+ MailtoEmail,
15918
+ Email,
15919
+ Text,
15920
+ Nl,
15921
+ Url
15922
+ });
15923
+ function init$1() {
15924
+ var S_START = makeState();
15925
+ var S_PROTOCOL = makeState();
15926
+ var S_MAILTO = makeState();
15927
+ var S_PROTOCOL_SLASH = makeState();
15928
+ var S_PROTOCOL_SLASH_SLASH = makeState();
15929
+ var S_DOMAIN = makeState();
15930
+ var S_DOMAIN_DOT = makeState();
15931
+ var S_TLD = makeAcceptingState(Url);
15932
+ var S_TLD_COLON = makeState();
15933
+ var S_TLD_PORT = makeAcceptingState(Url);
15934
+ var S_URL = makeAcceptingState(Url);
15935
+ var S_URL_NON_ACCEPTING = makeState();
15936
+ var S_URL_OPENBRACE = makeState();
15937
+ var S_URL_OPENBRACKET = makeState();
15938
+ var S_URL_OPENANGLEBRACKET = makeState();
15939
+ var S_URL_OPENPAREN = makeState();
15940
+ var S_URL_OPENBRACE_Q = makeAcceptingState(Url);
15941
+ var S_URL_OPENBRACKET_Q = makeAcceptingState(Url);
15942
+ var S_URL_OPENANGLEBRACKET_Q = makeAcceptingState(Url);
15943
+ var S_URL_OPENPAREN_Q = makeAcceptingState(Url);
15944
+ var S_URL_OPENBRACE_SYMS = makeState();
15945
+ var S_URL_OPENBRACKET_SYMS = makeState();
15946
+ var S_URL_OPENANGLEBRACKET_SYMS = makeState();
15947
+ var S_URL_OPENPAREN_SYMS = makeState();
15948
+ var S_EMAIL_DOMAIN = makeState();
15949
+ var S_EMAIL_DOMAIN_DOT = makeState();
15950
+ var S_EMAIL = makeAcceptingState(Email);
15951
+ var S_EMAIL_COLON = makeState();
15952
+ var S_EMAIL_PORT = makeAcceptingState(Email);
15953
+ var S_MAILTO_EMAIL = makeAcceptingState(MailtoEmail);
15954
+ var S_MAILTO_EMAIL_NON_ACCEPTING = makeState();
15955
+ var S_LOCALPART = makeState();
15956
+ var S_LOCALPART_AT = makeState();
15957
+ var S_LOCALPART_DOT = makeState();
15958
+ var S_NL = makeAcceptingState(Nl);
15959
+ makeT(S_START, NL, S_NL);
15960
+ makeT(S_START, PROTOCOL, S_PROTOCOL);
15961
+ makeT(S_START, MAILTO, S_MAILTO);
15962
+ makeT(S_PROTOCOL, SLASH, S_PROTOCOL_SLASH);
15963
+ makeT(S_PROTOCOL_SLASH, SLASH, S_PROTOCOL_SLASH_SLASH);
15964
+ makeT(S_START, TLD, S_DOMAIN);
15965
+ makeT(S_START, DOMAIN, S_DOMAIN);
15966
+ makeT(S_START, LOCALHOST, S_TLD);
15967
+ makeT(S_START, NUM, S_DOMAIN);
15968
+ makeT(S_PROTOCOL_SLASH_SLASH, TLD, S_URL);
15969
+ makeT(S_PROTOCOL_SLASH_SLASH, DOMAIN, S_URL);
15970
+ makeT(S_PROTOCOL_SLASH_SLASH, NUM, S_URL);
15971
+ makeT(S_PROTOCOL_SLASH_SLASH, LOCALHOST, S_URL);
15972
+ makeT(S_DOMAIN, DOT, S_DOMAIN_DOT);
15973
+ makeT(S_EMAIL_DOMAIN, DOT, S_EMAIL_DOMAIN_DOT);
15974
+ makeT(S_DOMAIN_DOT, TLD, S_TLD);
15975
+ makeT(S_DOMAIN_DOT, DOMAIN, S_DOMAIN);
15976
+ makeT(S_DOMAIN_DOT, NUM, S_DOMAIN);
15977
+ makeT(S_DOMAIN_DOT, LOCALHOST, S_DOMAIN);
15978
+ makeT(S_EMAIL_DOMAIN_DOT, TLD, S_EMAIL);
15979
+ makeT(S_EMAIL_DOMAIN_DOT, DOMAIN, S_EMAIL_DOMAIN);
15980
+ makeT(S_EMAIL_DOMAIN_DOT, NUM, S_EMAIL_DOMAIN);
15981
+ makeT(S_EMAIL_DOMAIN_DOT, LOCALHOST, S_EMAIL_DOMAIN);
15982
+ makeT(S_TLD, DOT, S_DOMAIN_DOT);
15983
+ makeT(S_EMAIL, DOT, S_EMAIL_DOMAIN_DOT);
15984
+ makeT(S_TLD, COLON, S_TLD_COLON);
15985
+ makeT(S_TLD, SLASH, S_URL);
15986
+ makeT(S_TLD_COLON, NUM, S_TLD_PORT);
15987
+ makeT(S_TLD_PORT, SLASH, S_URL);
15988
+ makeT(S_EMAIL, COLON, S_EMAIL_COLON);
15989
+ makeT(S_EMAIL_COLON, NUM, S_EMAIL_PORT);
15990
+ var qsAccepting = [AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, DOMAIN, EQUALS, HYPHEN, LOCALHOST, NUM, PERCENT, PIPE, PLUS, POUND, PROTOCOL, SLASH, SYM, TILDE, TLD, UNDERSCORE];
15991
+ var qsNonAccepting = [APOSTROPHE, CLOSEANGLEBRACKET, CLOSEBRACE, CLOSEBRACKET, CLOSEPAREN, COLON, COMMA, DOT, EXCLAMATION, OPENANGLEBRACKET, OPENBRACE, OPENBRACKET, OPENPAREN, QUERY, QUOTE, SEMI];
15992
+ makeT(S_URL, OPENBRACE, S_URL_OPENBRACE);
15993
+ makeT(S_URL, OPENBRACKET, S_URL_OPENBRACKET);
15994
+ makeT(S_URL, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);
15995
+ makeT(S_URL, OPENPAREN, S_URL_OPENPAREN);
15996
+ makeT(S_URL_NON_ACCEPTING, OPENBRACE, S_URL_OPENBRACE);
15997
+ makeT(S_URL_NON_ACCEPTING, OPENBRACKET, S_URL_OPENBRACKET);
15998
+ makeT(S_URL_NON_ACCEPTING, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);
15999
+ makeT(S_URL_NON_ACCEPTING, OPENPAREN, S_URL_OPENPAREN);
16000
+ makeT(S_URL_OPENBRACE, CLOSEBRACE, S_URL);
16001
+ makeT(S_URL_OPENBRACKET, CLOSEBRACKET, S_URL);
16002
+ makeT(S_URL_OPENANGLEBRACKET, CLOSEANGLEBRACKET, S_URL);
16003
+ makeT(S_URL_OPENPAREN, CLOSEPAREN, S_URL);
16004
+ makeT(S_URL_OPENBRACE_Q, CLOSEBRACE, S_URL);
16005
+ makeT(S_URL_OPENBRACKET_Q, CLOSEBRACKET, S_URL);
16006
+ makeT(S_URL_OPENANGLEBRACKET_Q, CLOSEANGLEBRACKET, S_URL);
16007
+ makeT(S_URL_OPENPAREN_Q, CLOSEPAREN, S_URL);
16008
+ makeT(S_URL_OPENBRACE_SYMS, CLOSEBRACE, S_URL);
16009
+ makeT(S_URL_OPENBRACKET_SYMS, CLOSEBRACKET, S_URL);
16010
+ makeT(S_URL_OPENANGLEBRACKET_SYMS, CLOSEANGLEBRACKET, S_URL);
16011
+ makeT(S_URL_OPENPAREN_SYMS, CLOSEPAREN, S_URL);
16012
+ makeMultiT(S_URL_OPENBRACE, qsAccepting, S_URL_OPENBRACE_Q);
16013
+ makeMultiT(S_URL_OPENBRACKET, qsAccepting, S_URL_OPENBRACKET_Q);
16014
+ makeMultiT(S_URL_OPENANGLEBRACKET, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
16015
+ makeMultiT(S_URL_OPENPAREN, qsAccepting, S_URL_OPENPAREN_Q);
16016
+ makeMultiT(S_URL_OPENBRACE, qsNonAccepting, S_URL_OPENBRACE_SYMS);
16017
+ makeMultiT(S_URL_OPENBRACKET, qsNonAccepting, S_URL_OPENBRACKET_SYMS);
16018
+ makeMultiT(S_URL_OPENANGLEBRACKET, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);
16019
+ makeMultiT(S_URL_OPENPAREN, qsNonAccepting, S_URL_OPENPAREN_SYMS);
16020
+ makeMultiT(S_URL_OPENBRACE_Q, qsAccepting, S_URL_OPENBRACE_Q);
16021
+ makeMultiT(S_URL_OPENBRACKET_Q, qsAccepting, S_URL_OPENBRACKET_Q);
16022
+ makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
16023
+ makeMultiT(S_URL_OPENPAREN_Q, qsAccepting, S_URL_OPENPAREN_Q);
16024
+ makeMultiT(S_URL_OPENBRACE_Q, qsNonAccepting, S_URL_OPENBRACE_Q);
16025
+ makeMultiT(S_URL_OPENBRACKET_Q, qsNonAccepting, S_URL_OPENBRACKET_Q);
16026
+ makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsNonAccepting, S_URL_OPENANGLEBRACKET_Q);
16027
+ makeMultiT(S_URL_OPENPAREN_Q, qsNonAccepting, S_URL_OPENPAREN_Q);
16028
+ makeMultiT(S_URL_OPENBRACE_SYMS, qsAccepting, S_URL_OPENBRACE_Q);
16029
+ makeMultiT(S_URL_OPENBRACKET_SYMS, qsAccepting, S_URL_OPENBRACKET_Q);
16030
+ makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
16031
+ makeMultiT(S_URL_OPENPAREN_SYMS, qsAccepting, S_URL_OPENPAREN_Q);
16032
+ makeMultiT(S_URL_OPENBRACE_SYMS, qsNonAccepting, S_URL_OPENBRACE_SYMS);
16033
+ makeMultiT(S_URL_OPENBRACKET_SYMS, qsNonAccepting, S_URL_OPENBRACKET_SYMS);
16034
+ makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);
16035
+ makeMultiT(S_URL_OPENPAREN_SYMS, qsNonAccepting, S_URL_OPENPAREN_SYMS);
16036
+ makeMultiT(S_URL, qsAccepting, S_URL);
16037
+ makeMultiT(S_URL_NON_ACCEPTING, qsAccepting, S_URL);
16038
+ makeMultiT(S_URL, qsNonAccepting, S_URL_NON_ACCEPTING);
16039
+ makeMultiT(S_URL_NON_ACCEPTING, qsNonAccepting, S_URL_NON_ACCEPTING);
16040
+ makeT(S_MAILTO, TLD, S_MAILTO_EMAIL);
16041
+ makeT(S_MAILTO, DOMAIN, S_MAILTO_EMAIL);
16042
+ makeT(S_MAILTO, NUM, S_MAILTO_EMAIL);
16043
+ makeT(S_MAILTO, LOCALHOST, S_MAILTO_EMAIL);
16044
+ makeMultiT(S_MAILTO_EMAIL, qsAccepting, S_MAILTO_EMAIL);
16045
+ makeMultiT(S_MAILTO_EMAIL, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING);
16046
+ makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsAccepting, S_MAILTO_EMAIL);
16047
+ makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING);
16048
+ var localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, CLOSEBRACE, DOLLAR, DOMAIN, EQUALS, HYPHEN, NUM, OPENBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, TLD, UNDERSCORE];
16049
+ makeMultiT(S_DOMAIN, localpartAccepting, S_LOCALPART);
16050
+ makeT(S_DOMAIN, AT, S_LOCALPART_AT);
16051
+ makeMultiT(S_TLD, localpartAccepting, S_LOCALPART);
16052
+ makeT(S_TLD, AT, S_LOCALPART_AT);
16053
+ makeMultiT(S_DOMAIN_DOT, localpartAccepting, S_LOCALPART);
16054
+ makeMultiT(S_LOCALPART, localpartAccepting, S_LOCALPART);
16055
+ makeT(S_LOCALPART, AT, S_LOCALPART_AT);
16056
+ makeT(S_LOCALPART, DOT, S_LOCALPART_DOT);
16057
+ makeMultiT(S_LOCALPART_DOT, localpartAccepting, S_LOCALPART);
16058
+ makeT(S_LOCALPART_AT, TLD, S_EMAIL_DOMAIN);
16059
+ makeT(S_LOCALPART_AT, DOMAIN, S_EMAIL_DOMAIN);
16060
+ makeT(S_LOCALPART_AT, NUM, S_EMAIL_DOMAIN);
16061
+ makeT(S_LOCALPART_AT, LOCALHOST, S_EMAIL);
16062
+ return S_START;
16063
+ }
16064
+ function run(start2, input, tokens) {
16065
+ var len = tokens.length;
16066
+ var cursor = 0;
16067
+ var multis = [];
16068
+ var textTokens = [];
16069
+ while (cursor < len) {
16070
+ var state = start2;
16071
+ var secondState = null;
16072
+ var nextState = null;
16073
+ var multiLength = 0;
16074
+ var latestAccepting = null;
16075
+ var sinceAccepts = -1;
16076
+ while (cursor < len && !(secondState = takeT(state, tokens[cursor].t))) {
16077
+ textTokens.push(tokens[cursor++]);
16078
+ }
16079
+ while (cursor < len && (nextState = secondState || takeT(state, tokens[cursor].t))) {
16080
+ secondState = null;
16081
+ state = nextState;
16082
+ if (state.accepts()) {
16083
+ sinceAccepts = 0;
16084
+ latestAccepting = state;
16085
+ } else if (sinceAccepts >= 0) {
16086
+ sinceAccepts++;
16019
16087
  }
16020
- ];
16021
- },
16022
- renderHTML({ HTMLAttributes: attrs }) {
16023
- return renderMark({ font_weight: attrs.value });
16024
- }
16025
- });
16026
- const FontSize = Mark2.create({
16027
- name: TextSettings.FONT_SIZE,
16028
- group: MarkGroups.SETTINGS,
16029
- addOptions: () => ({
16030
- minSize: 1,
16031
- maxSize: 100
16032
- }),
16033
- addAttributes() {
16034
- return {
16035
- mobile: { default: null },
16036
- tablet: { default: null },
16037
- desktop: { default: null }
16038
- };
16039
- },
16040
- addCommands() {
16041
- return {
16042
- getFontSize: createCommand(({ commands: commands2 }) => {
16043
- return commands2.getDeviceSettingMark(this.name, commands2.getDefaultFontSize());
16044
- }),
16045
- getDefaultFontSize: createCommand(({ commands: commands2 }) => {
16046
- const device = commands2.getDevice();
16047
- const preset = commands2.getPreset();
16048
- return computed(() => unref(preset)[unref(device)].font_size.replace("px", ""));
16049
- }),
16050
- applyFontSize: createCommand(({ commands: commands2 }, value) => {
16051
- const device = unref(commands2.getDevice());
16052
- commands2.applyMark(this.name, { [device]: value }, {
16053
- isAppliedToParent: (parentMark, mark) => {
16054
- if (parentMark.type.name !== mark.type.name)
16055
- return false;
16056
- return parentMark.attrs[device] === mark.attrs[device];
16057
- },
16058
- onAppliedToParent: ({ tr, node, position, mark }) => {
16059
- const attrs = { ...mark.attrs, [device]: null };
16060
- const canRemove = !Object.values(attrs).some((value2) => !!value2);
16061
- if (canRemove)
16062
- return false;
16063
- const updated = mark.type.create(attrs);
16064
- if (node.isText) {
16065
- tr.addMark(position, position + node.nodeSize, updated);
16066
- return;
16067
- }
16068
- tr.addNodeMark(position, updated);
16069
- }
16070
- });
16071
- }),
16072
- increaseFontSize: createCommand(({ commands: commands2 }) => {
16073
- const size2 = Number(unref(commands2.getFontSize()));
16074
- const nextSize = Math.min(size2 + 1, this.options.maxSize);
16075
- commands2.applyFontSize(String(nextSize));
16076
- }),
16077
- decreaseFontSize: createCommand(({ commands: commands2 }) => {
16078
- const size2 = Number(unref(commands2.getFontSize()));
16079
- const nextSize = Math.max(size2 - 1, this.options.minSize);
16080
- commands2.applyFontSize(String(nextSize));
16081
- })
16082
- };
16083
- },
16084
- addKeyboardShortcuts: () => ({
16085
- "Mod-Shift-=": createKeyboardShortcut("increaseFontSize"),
16086
- "Mod-Shift--": createKeyboardShortcut("decreaseFontSize")
16087
- }),
16088
- parseHTML() {
16089
- const parseSize = (value) => {
16090
- if (!value)
16091
- return null;
16092
- const wrapperEl = unref(this.options.wrapperRef);
16093
- const converted = convertFontSize(value, wrapperEl);
16094
- return String(converted);
16095
- };
16096
- return [
16097
- {
16098
- tag: '[style*="--zw-font-size"]',
16099
- getAttrs: ({ style: style2 }) => ({
16100
- mobile: parseSize(style2.getPropertyValue("--zw-font-size-mobile")),
16101
- tablet: parseSize(style2.getPropertyValue("--zw-font-size-tablet")),
16102
- desktop: parseSize(style2.getPropertyValue("--zw-font-size-desktop"))
16103
- })
16104
- },
16105
- {
16106
- style: "font-size",
16107
- getAttrs: (input) => {
16108
- const value = parseSize(input);
16109
- return { desktop: value, tablet: value, mobile: null };
16110
- }
16088
+ cursor++;
16089
+ multiLength++;
16090
+ }
16091
+ if (sinceAccepts < 0) {
16092
+ for (var i = cursor - multiLength; i < cursor; i++) {
16093
+ textTokens.push(tokens[i]);
16111
16094
  }
16112
- ];
16113
- },
16114
- renderHTML({ HTMLAttributes: attrs }) {
16115
- const addUnits = (value) => value ? `${value}px` : null;
16116
- return renderMark({
16117
- font_size_mobile: addUnits(attrs.mobile),
16118
- font_size_tablet: addUnits(attrs.tablet),
16119
- font_size_desktop: addUnits(attrs.desktop)
16120
- });
16121
- }
16122
- });
16123
- const FontColor = Mark2.create({
16124
- name: TextSettings.FONT_COLOR,
16125
- group: MarkGroups.SETTINGS,
16126
- addAttributes: () => ({
16127
- value: { required: true }
16128
- }),
16129
- addCommands() {
16130
- return {
16131
- getFontColor: createCommand(({ commands: commands2 }) => {
16132
- return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontColor());
16133
- }),
16134
- getDefaultFontColor: createCommand(({ commands: commands2 }) => {
16135
- const preset = commands2.getPreset();
16136
- return computed(() => unref(preset).common.color);
16137
- }),
16138
- applyFontColor: createCommand(({ commands: commands2 }, value) => {
16139
- commands2.applyMark(this.name, { value });
16140
- })
16141
- };
16142
- },
16143
- parseHTML() {
16144
- const getAttrs = (value) => ({ value: convertColor(value) });
16145
- return [
16146
- {
16147
- style: "--zw-font-color",
16148
- getAttrs
16149
- },
16150
- {
16151
- style: "color",
16152
- getAttrs
16095
+ } else {
16096
+ if (textTokens.length > 0) {
16097
+ multis.push(parserCreateMultiToken(Text, input, textTokens));
16098
+ textTokens = [];
16153
16099
  }
16154
- ];
16155
- },
16156
- renderHTML({ HTMLAttributes: attrs }) {
16157
- return renderMark({ font_color: attrs.value });
16100
+ cursor -= sinceAccepts;
16101
+ multiLength -= sinceAccepts;
16102
+ var Multi = latestAccepting.t;
16103
+ var subtokens = tokens.slice(cursor - multiLength, cursor);
16104
+ multis.push(parserCreateMultiToken(Multi, input, subtokens));
16105
+ }
16106
+ }
16107
+ if (textTokens.length > 0) {
16108
+ multis.push(parserCreateMultiToken(Text, input, textTokens));
16109
+ }
16110
+ return multis;
16111
+ }
16112
+ function parserCreateMultiToken(Multi, input, tokens) {
16113
+ var startIdx = tokens[0].s;
16114
+ var endIdx = tokens[tokens.length - 1].e;
16115
+ var value = input.substr(startIdx, endIdx - startIdx);
16116
+ return new Multi(value, tokens);
16117
+ }
16118
+ var warn = typeof console !== "undefined" && console && console.warn || function() {
16119
+ };
16120
+ var INIT = {
16121
+ scanner: null,
16122
+ parser: null,
16123
+ pluginQueue: [],
16124
+ customProtocols: [],
16125
+ initialized: false
16126
+ };
16127
+ function reset() {
16128
+ INIT.scanner = null;
16129
+ INIT.parser = null;
16130
+ INIT.pluginQueue = [];
16131
+ INIT.customProtocols = [];
16132
+ INIT.initialized = false;
16133
+ }
16134
+ function registerCustomProtocol(protocol) {
16135
+ if (INIT.initialized) {
16136
+ warn('linkifyjs: already initialized - will not register custom protocol "'.concat(protocol, '" until you manually call linkify.init(). To avoid this warning, please register all custom protocols before invoking linkify the first time.'));
16137
+ }
16138
+ if (!/^[a-z-]+$/.test(protocol)) {
16139
+ throw Error("linkifyjs: protocols containing characters other than a-z or - (hyphen) are not supported");
16140
+ }
16141
+ INIT.customProtocols.push(protocol);
16142
+ }
16143
+ function init() {
16144
+ INIT.scanner = {
16145
+ start: init$2(INIT.customProtocols),
16146
+ tokens: text
16147
+ };
16148
+ INIT.parser = {
16149
+ start: init$1(),
16150
+ tokens: multi
16151
+ };
16152
+ var utils = {
16153
+ createTokenClass
16154
+ };
16155
+ for (var i = 0; i < INIT.pluginQueue.length; i++) {
16156
+ INIT.pluginQueue[i][1]({
16157
+ scanner: INIT.scanner,
16158
+ parser: INIT.parser,
16159
+ utils
16160
+ });
16158
16161
  }
16159
- });
16160
- const BackgroundColor = Mark2.create({
16161
- name: TextSettings.BACKGROUND_COLOR,
16162
- addAttributes: () => ({
16163
- value: { required: true }
16164
- }),
16165
- addCommands() {
16166
- return {
16167
- getBackgroundColor: createCommand(({ commands: commands2 }) => {
16168
- return commands2.getCommonSettingMark(this.name, "rgba(255, 255, 255, 0%)");
16169
- }),
16170
- applyBackgroundColor: createCommand(({ commands: commands2 }, value) => {
16171
- commands2.applyMark(this.name, { value });
16172
- })
16173
- };
16174
- },
16175
- parseHTML() {
16176
- const getAttrs = (value) => ({ value: convertColor(value) });
16177
- return [
16178
- {
16179
- style: "--zw-background-color",
16180
- getAttrs
16181
- },
16182
- {
16183
- style: "background-color",
16184
- getAttrs
16185
- }
16186
- ];
16187
- },
16188
- renderHTML({ HTMLAttributes: attrs }) {
16189
- return renderMark({ background_color: attrs.value });
16162
+ INIT.initialized = true;
16163
+ }
16164
+ function tokenize(str) {
16165
+ if (!INIT.initialized) {
16166
+ init();
16190
16167
  }
16191
- });
16192
- const DeviceManager = Extension.create({
16193
- name: "device_manager",
16194
- addCommands() {
16195
- return {
16196
- getDevice: createCommand(() => toRef(this.options, "device"))
16197
- };
16168
+ return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
16169
+ }
16170
+ function find$1(str) {
16171
+ var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
16172
+ var tokens = tokenize(str);
16173
+ var filtered = [];
16174
+ for (var i = 0; i < tokens.length; i++) {
16175
+ var token = tokens[i];
16176
+ if (token.isLink && (!type || token.t === type)) {
16177
+ filtered.push(token.toObject());
16178
+ }
16198
16179
  }
16199
- });
16200
- const FontStyle = Mark2.create({
16201
- name: TextSettings.FONT_STYLE,
16202
- group: MarkGroups.SETTINGS,
16203
- addAttributes: () => ({
16204
- italic: { required: true }
16205
- }),
16180
+ return filtered;
16181
+ }
16182
+ function test$1(str) {
16183
+ var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
16184
+ var tokens = tokenize(str);
16185
+ return tokens.length === 1 && tokens[0].isLink && (!type || tokens[0].t === type);
16186
+ }
16187
+ class PasteLinkPlugin extends ProseMirrorPlugin {
16188
+ addProps() {
16189
+ return { handlePaste: this._handlePaste };
16190
+ }
16191
+ _handlePaste(view, event, slice2) {
16192
+ if (view.state.selection.empty)
16193
+ return false;
16194
+ const textContent = slice2.content.textBetween(0, slice2.content.size).trim();
16195
+ const isLink = test$1(textContent);
16196
+ if (!textContent || !isLink)
16197
+ return false;
16198
+ const pastingLink = NodeSelector.query(slice2.content, {
16199
+ typeName: NodeTypes.TEXT,
16200
+ mark: { typeName: TextSettings.LINK },
16201
+ getMark: { typeName: TextSettings.LINK }
16202
+ });
16203
+ this.editor.commands.applyLink(pastingLink.attrs);
16204
+ return true;
16205
+ }
16206
+ }
16207
+ const NodeProcessor = Extension.create({
16208
+ name: "node_processor",
16206
16209
  addCommands() {
16207
16210
  return {
16208
- isItalic: createCommand(({ commands: commands2 }) => {
16209
- const selectionRef = commands2.getMark(this.name);
16210
- const defaultValueRef = commands2.getDefaultFontStyle();
16211
- return computed(() => {
16212
- var _a;
16213
- return ((_a = unref(selectionRef)) == null ? void 0 : _a.italic) ?? unref(defaultValueRef).italic;
16214
- });
16215
- }),
16216
- isItalicAvailable: createCommand(({ commands: commands2 }) => {
16217
- const fontRef = commands2.getFont();
16218
- const fontWeightRef = commands2.getFontWeight();
16219
- return computed(() => {
16220
- const font = unref(fontRef);
16221
- const weight = unref(fontWeightRef);
16222
- return font.isItalicSupported(weight) && !font.isWeightItalicOnly(weight);
16211
+ setBlockAttributes: createCommand(({ commands: commands2, state }, name, attrs, defaults2 = {}) => {
16212
+ const current = unref(commands2.getBlockAttributes(name)) ?? {};
16213
+ const { doc: doc2, tr } = state;
16214
+ const { from: from2, to } = tr.selection;
16215
+ doc2.nodesBetween(from2, to, (node, position) => {
16216
+ if (!NodeTypes.blocks.includes(node.type.name))
16217
+ return;
16218
+ tr.setNodeAttribute(position, name, { ...defaults2, ...current, ...attrs });
16223
16219
  });
16224
16220
  }),
16225
- getDefaultFontStyle: createCommand(({ commands: commands2 }) => {
16226
- const preset = commands2.getPreset();
16227
- return computed(() => ({
16228
- italic: unref(preset).common.font_style === "italic"
16229
- }));
16221
+ getBlockAttributes: createCommand(({ editor }, name, defaults2) => computed(() => {
16222
+ var _a;
16223
+ let attrs = Object.assign({}, defaults2 || {});
16224
+ for (const type of NodeTypes.blocks) {
16225
+ Object.assign(attrs, ((_a = editor.getAttributes(type)) == null ? void 0 : _a[name]) || {});
16226
+ }
16227
+ return Object.keys(attrs).length ? attrs : null;
16228
+ })),
16229
+ removeBlockAttributes: createCommand(({ commands: commands2 }, names) => {
16230
+ for (const type of NodeTypes.blocks) {
16231
+ commands2.resetAttributes(type, names);
16232
+ }
16230
16233
  }),
16231
- toggleItalic: createCommand(({ commands: commands2 }) => {
16232
- const isItalicAvailable = unref(commands2.isItalicAvailable());
16233
- if (!isItalicAvailable)
16234
+ applyMark: createCommand(({ state, commands: commands2 }, name, value, customizer = {}) => {
16235
+ const { tr, doc: doc2, schema } = state;
16236
+ const { $from, $to } = tr.selection;
16237
+ const linkMarkType = getMarkType(TextSettings.LINK, schema);
16238
+ const markType = getMarkType(name, schema);
16239
+ const markGroup = markType.spec.group || "";
16240
+ if (!markGroup.includes(MarkGroups.SETTINGS)) {
16241
+ return commands2.setMark(name, value);
16242
+ }
16243
+ if ($from.pos === $to.pos)
16234
16244
  return;
16235
- unref(commands2.isItalic()) ? commands2.removeItalic() : commands2.applyItalic();
16236
- }),
16237
- applyItalic: createCommand(({ commands: commands2 }) => {
16238
- commands2.applyMark(this.name, { italic: true });
16239
- }),
16240
- removeItalic: createCommand(({ commands: commands2 }) => {
16241
- commands2.applyMark(this.name, { italic: false });
16242
- })
16243
- };
16244
- },
16245
- addKeyboardShortcuts: () => ({
16246
- "Mod-i": createKeyboardShortcut("toggleItalic"),
16247
- "Mod-I": createKeyboardShortcut("toggleItalic")
16248
- }),
16249
- parseHTML() {
16250
- const getAttrs = (value) => ({ italic: value.includes("italic") });
16251
- return [
16252
- {
16253
- tag: "i",
16254
- attrs: { italic: true }
16255
- },
16256
- {
16257
- style: "--zw-font-style",
16258
- getAttrs
16259
- },
16260
- {
16261
- style: "font-style",
16262
- getAttrs
16263
- }
16264
- ];
16265
- },
16266
- renderHTML({ HTMLAttributes: attrs }) {
16267
- const font_style = attrs.italic ? "italic" : "normal";
16268
- return renderMark({ font_style });
16269
- }
16270
- });
16271
- const TextDecoration = Mark2.create({
16272
- name: TextSettings.TEXT_DECORATION,
16273
- priority: 1e3,
16274
- addAttributes: () => ({
16275
- underline: { default: false },
16276
- strike_through: { default: false }
16277
- }),
16278
- addCommands() {
16279
- return {
16280
- isUnderline: createCommand(({ commands: commands2 }) => {
16281
- const decoration = commands2.getTextDecoration();
16282
- return computed(() => unref(decoration).underline);
16283
- }),
16284
- isStrikeThrough: createCommand(({ commands: commands2 }) => {
16285
- const decoration = commands2.getTextDecoration();
16286
- return computed(() => unref(decoration).strike_through);
16245
+ const onAppliedToParent = (context) => {
16246
+ if (!customizer.onAppliedToParent || customizer.onAppliedToParent(context) === false) {
16247
+ const { tr: tr2, node, position, mark } = context;
16248
+ commands2._removeNodeMark({ tr: tr2, node, position, mark: mark.type });
16249
+ }
16250
+ };
16251
+ doc2.nodesBetween($from.pos, $to.pos, (node, position) => {
16252
+ if (node.type.name === NodeTypes.LIST)
16253
+ return;
16254
+ const initialMark = findMarkByType(node.marks, name);
16255
+ const applyingMark = markType.create({ ...(initialMark == null ? void 0 : initialMark.attrs) || {}, ...value });
16256
+ const textPosition = resolveTextPosition($from, $to, node, position);
16257
+ const isAppliedToParent = !linkMarkType.isInSet(node.marks) && isMarkAppliedToParent(tr.doc, position, applyingMark, customizer.isAppliedToParent);
16258
+ if (isAppliedToParent) {
16259
+ return onAppliedToParent({ tr, node, position, mark: applyingMark });
16260
+ }
16261
+ if (node.isText) {
16262
+ tr.addMark(textPosition.from, textPosition.to, applyingMark);
16263
+ return;
16264
+ }
16265
+ if (isNodeFullySelected(tr.doc, tr.selection, node, position)) {
16266
+ tr.addNodeMark(position, applyingMark);
16267
+ }
16268
+ });
16287
16269
  }),
16288
- getTextDecoration: createCommand(({ commands: commands2 }) => {
16289
- const selectionRef = commands2.getMark(this.name);
16290
- const defaultValueRef = commands2.getDefaultTextDecoration();
16270
+ getMarks: createCommand(({ editor }, name) => {
16271
+ const stateRef = toRef(editor, "state");
16291
16272
  return computed(() => {
16292
- const attrs = unref(selectionRef) ?? {};
16293
- const defaultValue = unref(defaultValueRef);
16294
- return {
16295
- underline: attrs.underline || defaultValue.underline,
16296
- strike_through: attrs.strike_through || defaultValue.strike_through
16297
- };
16273
+ const { selection, doc: doc2 } = unref(stateRef);
16274
+ const { from: from2, to } = unref(selection);
16275
+ const marks = [];
16276
+ doc2.nodesBetween(from2, to, (node) => {
16277
+ for (const mark of node.marks) {
16278
+ if (mark.type.name === name)
16279
+ marks.unshift(mark.attrs);
16280
+ }
16281
+ });
16282
+ return marks;
16298
16283
  });
16299
16284
  }),
16300
- isUnderlineCustomized: createCommand(({ commands: commands2 }) => {
16301
- const currentValue = commands2.isUnderline();
16302
- const defaultValue = commands2.getDefaultTextDecoration();
16303
- return computed(() => unref(currentValue) !== unref(defaultValue).underline);
16285
+ getMark: createCommand(({ commands: commands2 }, name) => {
16286
+ const marksRef = commands2.getMarks(name);
16287
+ return computed(() => unref(marksRef)[0] ?? null);
16304
16288
  }),
16305
- getDefaultTextDecoration: createCommand(({ commands: commands2 }) => {
16306
- const preset = commands2.getPreset();
16307
- return computed(() => {
16308
- const { text_decoration } = unref(preset).common;
16309
- return {
16310
- underline: text_decoration.includes("underline"),
16311
- strike_through: text_decoration.includes("line-through")
16312
- };
16289
+ hasMark: createCommand(({ commands: commands2 }, name) => {
16290
+ const mark = commands2.getMark(name);
16291
+ return computed(() => !!unref(mark));
16292
+ }),
16293
+ getCommonSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
16294
+ const selectionRef = commands2.getMark(name);
16295
+ return computed(() => {
16296
+ var _a;
16297
+ return ((_a = unref(selectionRef)) == null ? void 0 : _a.value) ?? unref(defaultRef);
16313
16298
  });
16314
16299
  }),
16315
- toggleUnderline: createCommand(({ commands: commands2 }) => {
16316
- commands2.toggleTextDecoration("underline");
16317
- }),
16318
- toggleStrikeThrough: createCommand(({ commands: commands2 }) => {
16319
- commands2.toggleTextDecoration("strike_through");
16300
+ getDeviceSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
16301
+ const selectionRef = commands2.getMarks(name);
16302
+ const deviceRef = commands2.getDevice();
16303
+ return computed(() => {
16304
+ for (const attrs of unref(selectionRef)) {
16305
+ const value = attrs[unref(deviceRef)];
16306
+ if (value)
16307
+ return value;
16308
+ }
16309
+ return unref(defaultRef);
16310
+ });
16320
16311
  }),
16321
- toggleTextDecoration: createCommand(({ commands: commands2 }, name, toEnable = null) => {
16322
- const value = unref(commands2.getTextDecoration());
16323
- const isEnabled = toEnable ?? !value[name];
16324
- commands2.applyMark(this.name, { [name]: isEnabled });
16312
+ removeAllMarks: createCommand(({ state, commands: commands2 }) => {
16313
+ const { tr, doc: doc2 } = state;
16314
+ const { from: from2, to } = tr.selection;
16315
+ doc2.nodesBetween(from2, to, (node, position) => {
16316
+ for (const mark of node.marks) {
16317
+ commands2._removeNodeMark({ tr, node, position, mark });
16318
+ }
16319
+ });
16325
16320
  }),
16326
- applyTextDecoration: createCommand(({ commands: commands2 }, name) => {
16327
- commands2.toggleTextDecoration(name, true);
16321
+ removeMarks: createCommand(({ state, commands: commands2 }, marks) => {
16322
+ const { tr, doc: doc2 } = state;
16323
+ const { from: from2, to } = tr.selection;
16324
+ doc2.nodesBetween(from2, to, (node, position) => {
16325
+ const removingMarks = node.marks.filter((mark) => marks.includes(mark.type.name));
16326
+ for (const mark of removingMarks) {
16327
+ commands2._removeNodeMark({ tr, node, position, mark });
16328
+ }
16329
+ });
16328
16330
  }),
16329
- removeTextDecoration: createCommand(({ commands: commands2 }, name) => {
16330
- commands2.toggleTextDecoration(name, false);
16331
+ _removeNodeMark: createCommand((context, { tr, node, position, mark }) => {
16332
+ return node.isText ? tr.removeMark(position, position + node.nodeSize, mark) : tr.removeNodeMark(position, mark);
16331
16333
  })
16332
16334
  };
16333
- },
16334
- addKeyboardShortcuts: () => ({
16335
- "Mod-u": createKeyboardShortcut("toggleUnderline"),
16336
- "Mod-U": createKeyboardShortcut("toggleUnderline")
16337
- }),
16338
- parseHTML() {
16339
- const getAttrs = (value) => {
16340
- const underline = value.includes("underline");
16341
- const strike_through = value.includes("line-through");
16342
- if (!underline && !strike_through) {
16343
- return false;
16344
- }
16345
- return { underline, strike_through };
16346
- };
16347
- return [
16348
- {
16349
- style: "--zw-text-decoration",
16350
- getAttrs
16351
- },
16352
- {
16353
- style: "text-decoration-line",
16354
- getAttrs
16355
- },
16356
- {
16357
- style: "text-decoration",
16358
- getAttrs
16359
- },
16360
- {
16361
- tag: "s",
16362
- attrs: {
16363
- underline: false,
16364
- strike_through: true
16365
- }
16366
- },
16367
- {
16368
- tag: "u",
16369
- attrs: {
16370
- underline: true,
16371
- strike_through: false
16372
- }
16373
- }
16374
- ];
16375
- },
16376
- renderHTML({ HTMLAttributes: attrs }) {
16377
- const decorations = [];
16378
- if (attrs.underline)
16379
- decorations.push("underline");
16380
- if (attrs.strike_through)
16381
- decorations.push("line-through");
16382
- if (!decorations.length)
16383
- decorations.push("none");
16384
- return renderMark({ text_decoration: decorations.join(" ") });
16385
16335
  }
16386
16336
  });
16387
- const CaseStyle = Extension.create({
16388
- name: "case_style",
16337
+ const TextProcessor = Extension.create({
16338
+ name: "text_processor",
16389
16339
  addCommands() {
16390
16340
  return {
16391
- applyCaseStyle: createCommand(({ commands: commands2 }, value) => {
16392
- switch (value) {
16393
- case CaseStyles.CAPITALIZE:
16394
- return commands2.applyCapitalize();
16395
- case CaseStyles.LOWERCASE:
16396
- return commands2.applyLowerCase();
16397
- case CaseStyles.UPPERCASE:
16398
- return commands2.applyUpperCase();
16399
- }
16400
- }),
16401
- applyCapitalize: createCommand(({ commands: commands2 }) => {
16402
- commands2.transformText(({ text: text2 }) => capitalize(text2));
16403
- }),
16404
- applyLowerCase: createCommand(({ commands: commands2 }) => {
16405
- commands2.transformText(({ text: text2 }) => text2.toLowerCase());
16341
+ getSelectedText: createCommand(({ state }) => {
16342
+ const { from: from2, to } = state.selection;
16343
+ return state.doc.textBetween(from2, to, " ");
16406
16344
  }),
16407
- applyUpperCase: createCommand(({ commands: commands2 }) => {
16408
- commands2.transformText(({ text: text2 }) => text2.toUpperCase());
16345
+ transformText: createCommand(({ state }, transform) => {
16346
+ const { $from, $to } = state.tr.selection;
16347
+ if ($from.pos === $to.pos)
16348
+ return;
16349
+ state.doc.nodesBetween($from.pos, $to.pos, (node, position) => {
16350
+ if (!node.isText)
16351
+ return;
16352
+ const textPosition = resolveTextPosition($from, $to, node, position);
16353
+ const substringFrom = Math.max(0, $from.pos - position);
16354
+ const substringTo = Math.max(0, $to.pos - position);
16355
+ const updatedText = transform({
16356
+ text: node.textContent.substring(substringFrom, substringTo)
16357
+ });
16358
+ const updatedNode = state.schema.text(updatedText, node.marks);
16359
+ state.tr.replaceWith(textPosition.from, textPosition.to, updatedNode);
16360
+ });
16409
16361
  })
16410
16362
  };
16411
16363
  }
16412
16364
  });
16413
- const DEFAULTS$1 = {
16414
- mobile: null,
16415
- tablet: null,
16416
- desktop: null
16417
- };
16418
- const Alignment = Extension.create({
16419
- name: TextSettings.ALIGNMENT,
16420
- addGlobalAttributes: () => [
16421
- {
16422
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
16423
- attributes: {
16424
- [TextSettings.ALIGNMENT]: {
16425
- isRequired: false,
16426
- parseHTML({ style: style2 }) {
16427
- const textAlign = convertAlignment(style2.textAlign);
16428
- if (textAlign) {
16429
- return { desktop: textAlign, tablet: textAlign, mobile: textAlign };
16430
- }
16431
- const mobile = style2.getPropertyValue("--zw-alignment-mobile") || null;
16432
- const tablet = style2.getPropertyValue("--zw-alignment-tablet") || null;
16433
- const desktop = style2.getPropertyValue("--zw-alignment-desktop") || null;
16434
- if (!mobile && !tablet && !desktop)
16435
- return null;
16436
- return { desktop, tablet, mobile };
16437
- },
16438
- renderHTML(attrs) {
16439
- if (!attrs.alignment)
16440
- return null;
16441
- return renderInlineSetting({
16442
- alignment_mobile: attrs.alignment.mobile,
16443
- alignment_tablet: attrs.alignment.tablet,
16444
- alignment_desktop: attrs.alignment.desktop
16445
- });
16446
- }
16447
- }
16448
- }
16449
- }
16450
- ],
16365
+ const SelectionProcessor = Extension.create({
16366
+ name: "selection_processor",
16367
+ addStorage: () => ({
16368
+ selection: null
16369
+ }),
16451
16370
  addCommands() {
16452
16371
  return {
16453
- toggleAlignment: createCommand(({ commands: commands2 }, value) => {
16454
- const currentValue = commands2.getAlignment();
16455
- const isCurrentValue = unref(currentValue) === value;
16456
- !isCurrentValue ? commands2.applyAlignment(value) : commands2.removeAlignment();
16457
- }),
16458
- applyAlignment: createCommand(({ commands: commands2 }, value) => {
16459
- const device = unref(commands2.getDevice());
16460
- commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS$1);
16372
+ storeSelection: createCommand(({ state }) => {
16373
+ this.storage.selection = state.selection;
16461
16374
  }),
16462
- removeAlignment: createCommand(({ commands: commands2 }) => commands2.removeBlockAttributes(this.name)),
16463
- getAlignment: createCommand(({ commands: commands2 }) => {
16464
- const attribute = commands2.getBlockAttributes(this.name, DEFAULTS$1);
16465
- const device = commands2.getDevice();
16466
- const defaultValue = commands2.getDefaultAlignment();
16467
- return computed(() => {
16468
- var _a;
16469
- return ((_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) ?? unref(defaultValue);
16470
- });
16375
+ restoreSelection: createCommand(({ commands: commands2 }) => {
16376
+ this.storage.selection && commands2.setTextSelection(this.storage.selection);
16471
16377
  }),
16472
- getDefaultAlignment: createCommand(({ commands: commands2 }) => {
16473
- const device = commands2.getDevice();
16474
- const preset = commands2.getPreset();
16475
- return computed(() => unref(preset)[unref(device)].alignment);
16476
- })
16477
- };
16478
- },
16479
- addKeyboardShortcuts: () => ({
16480
- "Mod-Shift-l": createKeyboardShortcut("applyAlignment", Alignments.LEFT),
16481
- "Mod-Shift-e": createKeyboardShortcut("applyAlignment", Alignments.CENTER),
16482
- "Mod-Shift-r": createKeyboardShortcut("applyAlignment", Alignments.RIGHT),
16483
- "Mod-Shift-j": createKeyboardShortcut("applyAlignment", Alignments.JUSTIFY)
16484
- })
16485
- });
16486
- const DEFAULTS = {
16487
- mobile: null,
16488
- tablet: null,
16489
- desktop: null
16490
- };
16491
- const LineHeight = Extension.create({
16492
- name: TextSettings.LINE_HEIGHT,
16493
- addGlobalAttributes() {
16494
- return [
16495
- {
16496
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
16497
- attributes: {
16498
- [TextSettings.LINE_HEIGHT]: {
16499
- isRequired: false,
16500
- parseHTML: (element) => {
16501
- if (element.matches('[style*="--zw-line-height"]')) {
16502
- const mobile = null;
16503
- const tablet = element.style.getPropertyValue("--zw-line-height-tablet") || null;
16504
- const desktop = element.style.getPropertyValue("--zw-line-height-desktop") || null;
16505
- return { mobile, tablet, desktop };
16506
- }
16507
- const value = element.style.lineHeight;
16508
- if (!value)
16509
- return null;
16510
- const wrapperEl = unref(this.options.wrapperRef);
16511
- const converted = convertLineHeight(value, element, wrapperEl);
16512
- return converted ? { desktop: converted, tablet: converted, mobile: null } : null;
16513
- },
16514
- renderHTML(attrs) {
16515
- if (!attrs.line_height)
16516
- return null;
16517
- return renderInlineSetting({
16518
- line_height_mobile: attrs.line_height.mobile,
16519
- line_height_tablet: attrs.line_height.tablet,
16520
- line_height_desktop: attrs.line_height.desktop
16521
- });
16522
- }
16378
+ expandSelection: createCommand(({ tr, commands: commands2 }, predicate) => {
16379
+ let from2 = tr.selection.from;
16380
+ let to = tr.selection.to;
16381
+ tr.doc.nodesBetween(from2, to, (node, position, parent) => {
16382
+ if (predicate({ node, parent })) {
16383
+ const offset2 = node.isText ? 0 : resolvePositionOffset(tr.doc, position);
16384
+ from2 = Math.min(from2, position + offset2);
16385
+ to = Math.max(to, position + node.nodeSize - offset2);
16523
16386
  }
16524
- }
16525
- }
16526
- ];
16527
- },
16528
- addCommands() {
16529
- return {
16530
- getLineHeight: createCommand(({ commands: commands2 }) => {
16531
- const attribute = commands2.getBlockAttributes(this.name, DEFAULTS);
16532
- const device = commands2.getDevice();
16533
- const defaultValue = commands2.getDefaultLineHeight();
16534
- return computed(() => {
16535
- var _a;
16536
- return ((_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) ?? unref(defaultValue);
16537
16387
  });
16388
+ commands2.setTextSelection({ from: from2, to });
16538
16389
  }),
16539
- getDefaultLineHeight: createCommand(({ commands: commands2 }) => {
16540
- const device = commands2.getDevice();
16541
- const preset = commands2.getPreset();
16542
- return computed(() => unref(preset)[unref(device)].line_height);
16543
- }),
16544
- applyLineHeight: createCommand(({ commands: commands2 }, value) => {
16545
- const device = unref(commands2.getDevice());
16546
- commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
16390
+ expandSelectionToBlock: createCommand(({ commands: commands2 }) => {
16391
+ commands2.expandSelection(({ parent }) => parent.type.name === NodeTypes.DOCUMENT);
16547
16392
  })
16548
16393
  };
16549
16394
  }
16550
16395
  });
16551
- const ListItem$1 = Node2.create({
16552
- name: "listItem",
16396
+ const Document$1 = Node2.create({
16397
+ name: "doc",
16398
+ topNode: true,
16399
+ content: "block+"
16400
+ });
16401
+ const Document = Document$1.extend({
16402
+ marks: MarkGroups.SETTINGS,
16403
+ onCreate() {
16404
+ this.editor.view.dom.addEventListener("click", (event) => {
16405
+ if (event.target.closest("a"))
16406
+ event.preventDefault();
16407
+ });
16408
+ }
16409
+ });
16410
+ const Paragraph$1 = Node2.create({
16411
+ name: "paragraph",
16412
+ priority: 1e3,
16553
16413
  addOptions() {
16554
16414
  return {
16555
16415
  HTMLAttributes: {}
16556
16416
  };
16557
16417
  },
16558
- content: "paragraph block*",
16559
- defining: true,
16418
+ group: "block",
16419
+ content: "inline*",
16560
16420
  parseHTML() {
16561
16421
  return [
16562
- {
16563
- tag: "li"
16564
- }
16422
+ { tag: "p" }
16565
16423
  ];
16566
16424
  },
16567
16425
  renderHTML({ HTMLAttributes }) {
16568
- return ["li", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
16426
+ return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
16427
+ },
16428
+ addCommands() {
16429
+ return {
16430
+ setParagraph: () => ({ commands: commands2 }) => {
16431
+ return commands2.setNode(this.name);
16432
+ }
16433
+ };
16569
16434
  },
16570
16435
  addKeyboardShortcuts() {
16571
16436
  return {
16572
- Enter: () => this.editor.commands.splitListItem(this.name),
16573
- Tab: () => this.editor.commands.sinkListItem(this.name),
16574
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
16437
+ "Mod-Alt-0": () => this.editor.commands.setParagraph()
16575
16438
  };
16576
16439
  }
16577
16440
  });
16578
- const ListItem = ListItem$1.extend({
16579
- name: NodeTypes.LIST_ITEM,
16580
- marks: MarkGroups.SETTINGS,
16581
- addCommands() {
16582
- const getItemPosition = ({ selection }) => selection.$cursor.before(selection.$cursor.depth - 1);
16583
- return {
16584
- listItemNewline: createCommand(({ commands: commands2, tr }) => {
16585
- const initialNode = tr.doc.nodeAt(getItemPosition(tr));
16586
- const isEmptyParagraph = !tr.selection.$cursor.node().textContent;
16587
- if (isEmptyParagraph)
16588
- return false;
16589
- commands2.splitListItem(this.name);
16590
- const position = getItemPosition(tr);
16591
- for (const mark of initialNode.marks) {
16592
- tr.addNodeMark(position, copyMark(mark));
16593
- }
16594
- return true;
16595
- })
16596
- };
16597
- },
16441
+ const Paragraph = Paragraph$1.extend({
16442
+ marks: MarkGroups.ALL,
16598
16443
  addOptions: () => ({
16599
16444
  HTMLAttributes: { class: "zw-style" }
16600
- }),
16601
- addKeyboardShortcuts: () => ({
16602
- Enter: (context) => {
16603
- var _a;
16604
- const { state, commands: commands2 } = context.editor;
16605
- const isListSelected = (_a = state.selection.$cursor) == null ? void 0 : _a.path.some((node) => {
16606
- var _a2;
16607
- return ((_a2 = node.type) == null ? void 0 : _a2.name) === NodeTypes.LIST;
16608
- });
16609
- if (isListSelected)
16610
- return commands2.listItemNewline();
16611
- }
16612
16445
  })
16613
16446
  });
16614
- const List = Node2.create({
16615
- name: NodeTypes.LIST,
16616
- content: `${NodeTypes.LIST_ITEM}+`,
16617
- group: "block list",
16618
- marks: MarkGroups.SETTINGS,
16619
- addExtensions: () => [
16620
- ListItem
16621
- ],
16622
- addOptions: () => ({
16623
- baseClass: "",
16624
- presetClass: ""
16625
- }),
16626
- addAttributes: () => ({
16627
- bullet: {
16628
- default: { type: ListTypes.DISC }
16629
- }
16630
- }),
16631
- parseHTML() {
16632
- const HTML_TYPES = {
16633
- a: ListTypes.ROMAN,
16634
- i: ListTypes.LATIN,
16635
- "1": ListTypes.DECIMAL
16447
+ const Heading$1 = Node2.create({
16448
+ name: "heading",
16449
+ addOptions() {
16450
+ return {
16451
+ levels: [1, 2, 3, 4, 5, 6],
16452
+ HTMLAttributes: {}
16636
16453
  };
16637
- const getBulletType = (element) => {
16638
- for (const type of ListTypes.values) {
16639
- const bulletClass = `.${this.options.baseClass}${type}`;
16640
- if (element.matches(bulletClass))
16641
- return type;
16642
- if (HTML_TYPES[element.type.toLowerCase()] === type)
16643
- return type;
16454
+ },
16455
+ content: "inline*",
16456
+ group: "block",
16457
+ defining: true,
16458
+ addAttributes() {
16459
+ return {
16460
+ level: {
16461
+ default: 1,
16462
+ rendered: false
16644
16463
  }
16645
16464
  };
16646
- return [
16647
- {
16648
- tag: "ol",
16649
- getAttrs: (element) => ({
16650
- bullet: { type: getBulletType(element) || ListTypes.DECIMAL }
16651
- })
16652
- },
16653
- {
16654
- tag: "ul",
16655
- getAttrs: (element) => ({
16656
- bullet: { type: getBulletType(element) || ListTypes.DISC }
16657
- })
16658
- }
16659
- ];
16660
16465
  },
16661
- renderHTML({ HTMLAttributes: attrs }) {
16662
- const classes = [
16663
- this.options.baseClass + attrs.bullet.type,
16664
- this.options.presetClass
16665
- ];
16666
- const isOrdered = ListTypes.ordered.includes(attrs.bullet.type);
16667
- return [isOrdered ? "ol" : "ul", { class: classes.join(" ") }, 0];
16466
+ parseHTML() {
16467
+ return this.options.levels.map((level) => ({
16468
+ tag: `h${level}`,
16469
+ attrs: { level }
16470
+ }));
16471
+ },
16472
+ renderHTML({ node, HTMLAttributes }) {
16473
+ const hasLevel = this.options.levels.includes(node.attrs.level);
16474
+ const level = hasLevel ? node.attrs.level : this.options.levels[0];
16475
+ return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
16668
16476
  },
16669
16477
  addCommands() {
16670
16478
  return {
16671
- getListType: createCommand(({ commands: commands2 }) => {
16672
- const attribute = commands2.getBlockAttributes("bullet", { type: null });
16673
- return computed(() => unref(attribute).type ?? null);
16674
- }),
16675
- applyList: createCommand(({ commands: commands2, chain }, type) => {
16676
- const currentType = unref(commands2.getListType());
16677
- if (currentType === type) {
16678
- commands2.removeList();
16679
- return;
16680
- }
16681
- return chain().applyDefaultPreset().toggleList(NodeTypes.LIST, NodeTypes.LIST_ITEM).setBlockAttributes("bullet", { type }).command(({ commands: commands3, tr }) => commands3._bubbleListItemMarks(tr)).run();
16682
- }),
16683
- _bubbleListItemMarks: createCommand((_, tr) => {
16684
- const { doc: doc2, selection } = tr;
16685
- const from2 = selection.$from.start();
16686
- const to = selection.$to.end();
16687
- function canBubbleMark(node, childMark) {
16688
- if (TextSettings.inlineMarks.includes(childMark.type))
16689
- return false;
16690
- if (childMark.type.isInSet(node.marks))
16691
- return false;
16692
- for (const child of node.content.content) {
16693
- if (!child.childCount)
16694
- continue;
16695
- if (!child.marks)
16696
- return false;
16697
- if (!childMark.isInSet(child.marks))
16698
- return false;
16699
- }
16700
- return true;
16701
- }
16702
- doc2.nodesBetween(from2, to, (node, position) => {
16703
- if (node.type.name === NodeTypes.LIST)
16704
- return;
16705
- if (node.type.name !== NodeTypes.LIST_ITEM)
16706
- return false;
16707
- const bubbled = [];
16708
- node.forEach((child) => {
16709
- for (const childMark of child.marks) {
16710
- if (childMark.isInSet(bubbled)) {
16711
- tr.removeNodeMark(position + 1, childMark);
16712
- continue;
16713
- }
16714
- if (canBubbleMark(node, childMark)) {
16715
- tr.removeNodeMark(position + 1, childMark);
16716
- tr.addNodeMark(position, copyMark(childMark));
16717
- bubbled.push(childMark);
16718
- }
16719
- }
16720
- });
16479
+ setHeading: (attributes) => ({ commands: commands2 }) => {
16480
+ if (!this.options.levels.includes(attributes.level)) {
16721
16481
  return false;
16722
- });
16723
- }),
16724
- removeList: createCommand(({ commands: commands2, state }) => {
16725
- const { tr, doc: doc2, selection } = state;
16726
- const from2 = selection.$from.start();
16727
- const to = selection.$to.end();
16728
- doc2.nodesBetween(from2, to, (node, position, parent) => {
16729
- if ([NodeTypes.LIST, NodeTypes.LIST_ITEM].includes(node.type.name))
16730
- return;
16731
- if (parent.type.name !== NodeTypes.LIST_ITEM)
16732
- return false;
16733
- const addingMarks = parent.marks.filter(function(mark) {
16734
- return !mark.type.isInSet(node.marks);
16735
- });
16736
- for (const mark of addingMarks) {
16737
- tr.addNodeMark(position, copyMark(mark));
16738
- }
16482
+ }
16483
+ return commands2.setNode(this.name, attributes);
16484
+ },
16485
+ toggleHeading: (attributes) => ({ commands: commands2 }) => {
16486
+ if (!this.options.levels.includes(attributes.level)) {
16739
16487
  return false;
16740
- });
16741
- commands2.liftListItem(NodeTypes.LIST_ITEM);
16742
- })
16488
+ }
16489
+ return commands2.toggleNode(this.name, "paragraph", attributes);
16490
+ }
16743
16491
  };
16744
16492
  },
16493
+ addKeyboardShortcuts() {
16494
+ return this.options.levels.reduce((items, level) => ({
16495
+ ...items,
16496
+ ...{
16497
+ [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
16498
+ }
16499
+ }), {});
16500
+ },
16745
16501
  addInputRules() {
16746
- const wrappingListRule = (bullet, regex) => wrappingInputRule({
16747
- find: regex,
16748
- type: this.type,
16749
- getAttributes: { bullet: { type: bullet } },
16750
- joinPredicate: (_, { attrs }) => attrs.bullet.type === bullet
16502
+ return this.options.levels.map((level) => {
16503
+ return textblockTypeInputRule({
16504
+ find: new RegExp(`^(#{1,${level}})\\s$`),
16505
+ type: this.type,
16506
+ getAttributes: {
16507
+ level
16508
+ }
16509
+ });
16751
16510
  });
16752
- return [
16753
- wrappingListRule(ListTypes.DISC, /^\s*([-+*])\s$/),
16754
- wrappingListRule(ListTypes.DECIMAL, /^(\d+)\.\s$/),
16755
- wrappingListRule(ListTypes.LATIN, /^([ivx]{1,3})\.\s$/i),
16756
- wrappingListRule(ListTypes.ROMAN, /^([a-z])\.\s$/i)
16757
- ];
16758
16511
  }
16759
16512
  });
16760
- function State(token) {
16761
- this.j = {};
16762
- this.jr = [];
16763
- this.jd = null;
16764
- this.t = token;
16765
- }
16766
- State.prototype = {
16767
- accepts: function accepts() {
16768
- return !!this.t;
16769
- },
16770
- tt: function tt(input, tokenOrState) {
16771
- if (tokenOrState && tokenOrState.j) {
16772
- this.j[input] = tokenOrState;
16773
- return tokenOrState;
16774
- }
16775
- var token = tokenOrState;
16776
- var nextState = this.j[input];
16777
- if (nextState) {
16778
- if (token) {
16779
- nextState.t = token;
16780
- }
16781
- return nextState;
16782
- }
16783
- nextState = makeState();
16784
- var templateState = takeT(this, input);
16785
- if (templateState) {
16786
- Object.assign(nextState.j, templateState.j);
16787
- nextState.jr.append(templateState.jr);
16788
- nextState.jr = templateState.jd;
16789
- nextState.t = token || templateState.t;
16790
- } else {
16791
- nextState.t = token;
16792
- }
16793
- this.j[input] = nextState;
16794
- return nextState;
16795
- }
16796
- };
16797
- var makeState = function makeState2() {
16798
- return new State();
16799
- };
16800
- var makeAcceptingState = function makeAcceptingState2(token) {
16801
- return new State(token);
16802
- };
16803
- var makeT = function makeT2(startState, input, nextState) {
16804
- if (!startState.j[input]) {
16805
- startState.j[input] = nextState;
16806
- }
16807
- };
16808
- var makeRegexT = function makeRegexT2(startState, regex, nextState) {
16809
- startState.jr.push([regex, nextState]);
16810
- };
16811
- var takeT = function takeT2(state, input) {
16812
- var nextState = state.j[input];
16813
- if (nextState) {
16814
- return nextState;
16815
- }
16816
- for (var i = 0; i < state.jr.length; i++) {
16817
- var regex = state.jr[i][0];
16818
- var _nextState = state.jr[i][1];
16819
- if (regex.test(input)) {
16820
- return _nextState;
16821
- }
16822
- }
16823
- return state.jd;
16824
- };
16825
- var makeMultiT = function makeMultiT2(startState, chars, nextState) {
16826
- for (var i = 0; i < chars.length; i++) {
16827
- makeT(startState, chars[i], nextState);
16828
- }
16829
- };
16830
- var makeBatchT = function makeBatchT2(startState, transitions) {
16831
- for (var i = 0; i < transitions.length; i++) {
16832
- var input = transitions[i][0];
16833
- var nextState = transitions[i][1];
16834
- makeT(startState, input, nextState);
16835
- }
16836
- };
16837
- var makeChainT = function makeChainT2(state, str, endState, defaultStateFactory) {
16838
- var i = 0, len = str.length, nextState;
16839
- while (i < len && (nextState = state.j[str[i]])) {
16840
- state = nextState;
16841
- i++;
16842
- }
16843
- if (i >= len) {
16844
- return [];
16845
- }
16846
- while (i < len - 1) {
16847
- nextState = defaultStateFactory();
16848
- makeT(state, str[i], nextState);
16849
- state = nextState;
16850
- i++;
16513
+ const Heading = Heading$1.extend({
16514
+ marks: MarkGroups.ALL,
16515
+ addOptions: () => ({
16516
+ levels: [1, 2, 3, 4],
16517
+ HTMLAttributes: { class: "zw-style" }
16518
+ })
16519
+ });
16520
+ const ProseMirrorPlugins = Extension.create({
16521
+ name: "prose_mirror_plugins",
16522
+ addProseMirrorPlugins() {
16523
+ return [
16524
+ PastePlugin.create(this.editor),
16525
+ PlaceholderPlugin.create(this.editor)
16526
+ ];
16851
16527
  }
16852
- makeT(state, str[len - 1], endState);
16853
- };
16854
- var DOMAIN = "DOMAIN";
16855
- var LOCALHOST = "LOCALHOST";
16856
- var TLD = "TLD";
16857
- var NUM = "NUM";
16858
- var PROTOCOL = "PROTOCOL";
16859
- var MAILTO = "MAILTO";
16860
- var WS = "WS";
16861
- var NL = "NL";
16862
- var OPENBRACE = "OPENBRACE";
16863
- var OPENBRACKET = "OPENBRACKET";
16864
- var OPENANGLEBRACKET = "OPENANGLEBRACKET";
16865
- var OPENPAREN = "OPENPAREN";
16866
- var CLOSEBRACE = "CLOSEBRACE";
16867
- var CLOSEBRACKET = "CLOSEBRACKET";
16868
- var CLOSEANGLEBRACKET = "CLOSEANGLEBRACKET";
16869
- var CLOSEPAREN = "CLOSEPAREN";
16870
- var AMPERSAND = "AMPERSAND";
16871
- var APOSTROPHE = "APOSTROPHE";
16872
- var ASTERISK = "ASTERISK";
16873
- var AT = "AT";
16874
- var BACKSLASH = "BACKSLASH";
16875
- var BACKTICK = "BACKTICK";
16876
- var CARET = "CARET";
16877
- var COLON = "COLON";
16878
- var COMMA = "COMMA";
16879
- var DOLLAR = "DOLLAR";
16880
- var DOT = "DOT";
16881
- var EQUALS = "EQUALS";
16882
- var EXCLAMATION = "EXCLAMATION";
16883
- var HYPHEN = "HYPHEN";
16884
- var PERCENT = "PERCENT";
16885
- var PIPE = "PIPE";
16886
- var PLUS = "PLUS";
16887
- var POUND = "POUND";
16888
- var QUERY = "QUERY";
16889
- var QUOTE = "QUOTE";
16890
- var SEMI = "SEMI";
16891
- var SLASH = "SLASH";
16892
- var TILDE = "TILDE";
16893
- var UNDERSCORE = "UNDERSCORE";
16894
- var SYM = "SYM";
16895
- var text = /* @__PURE__ */ Object.freeze({
16896
- __proto__: null,
16897
- DOMAIN,
16898
- LOCALHOST,
16899
- TLD,
16900
- NUM,
16901
- PROTOCOL,
16902
- MAILTO,
16903
- WS,
16904
- NL,
16905
- OPENBRACE,
16906
- OPENBRACKET,
16907
- OPENANGLEBRACKET,
16908
- OPENPAREN,
16909
- CLOSEBRACE,
16910
- CLOSEBRACKET,
16911
- CLOSEANGLEBRACKET,
16912
- CLOSEPAREN,
16913
- AMPERSAND,
16914
- APOSTROPHE,
16915
- ASTERISK,
16916
- AT,
16917
- BACKSLASH,
16918
- BACKTICK,
16919
- CARET,
16920
- COLON,
16921
- COMMA,
16922
- DOLLAR,
16923
- DOT,
16924
- EQUALS,
16925
- EXCLAMATION,
16926
- HYPHEN,
16927
- PERCENT,
16928
- PIPE,
16929
- PLUS,
16930
- POUND,
16931
- QUERY,
16932
- QUOTE,
16933
- SEMI,
16934
- SLASH,
16935
- TILDE,
16936
- UNDERSCORE,
16937
- SYM
16938
16528
  });
16939
- var tlds = "aaa aarp abarth abb abbott abbvie abc able abogado abudhabi ac academy accenture accountant accountants aco actor ad adac ads adult ae aeg aero aetna af afamilycompany afl africa ag agakhan agency ai aig airbus airforce airtel akdn al alfaromeo alibaba alipay allfinanz allstate ally alsace alstom am amazon americanexpress americanfamily amex amfam amica amsterdam analytics android anquan anz ao aol apartments app apple aq aquarelle ar arab aramco archi army arpa art arte as asda asia associates at athleta attorney au auction audi audible audio auspost author auto autos avianca aw aws ax axa az azure ba baby baidu banamex bananarepublic band bank bar barcelona barclaycard barclays barefoot bargains baseball basketball bauhaus bayern bb bbc bbt bbva bcg bcn bd be beats beauty beer bentley berlin best bestbuy bet bf bg bh bharti bi bible bid bike bing bingo bio biz bj black blackfriday blockbuster blog bloomberg blue bm bms bmw bn bnpparibas bo boats boehringer bofa bom bond boo book booking bosch bostik boston bot boutique box br bradesco bridgestone broadway broker brother brussels bs bt budapest bugatti build builders business buy buzz bv bw by bz bzh ca cab cafe cal call calvinklein cam camera camp cancerresearch canon capetown capital capitalone car caravan cards care career careers cars casa case cash casino cat catering catholic cba cbn cbre cbs cc cd center ceo cern cf cfa cfd cg ch chanel channel charity chase chat cheap chintai christmas chrome church ci cipriani circle cisco citadel citi citic city cityeats ck cl claims cleaning click clinic clinique clothing cloud club clubmed cm cn co coach codes coffee college cologne com comcast commbank community company compare computer comsec condos construction consulting contact contractors cooking cookingchannel cool coop corsica country coupon coupons courses cpa cr credit creditcard creditunion cricket crown crs cruise cruises csc cu cuisinella cv cw cx cy cymru cyou cz dabur dad dance data date dating datsun day dclk dds de deal dealer deals degree delivery dell deloitte delta democrat dental dentist desi design dev dhl diamonds diet digital direct directory discount discover dish diy dj dk dm dnp do docs doctor dog domains dot download drive dtv dubai duck dunlop dupont durban dvag dvr dz earth eat ec eco edeka edu education ee eg email emerck energy engineer engineering enterprises epson equipment er ericsson erni es esq estate et etisalat eu eurovision eus events exchange expert exposed express extraspace fage fail fairwinds faith family fan fans farm farmers fashion fast fedex feedback ferrari ferrero fi fiat fidelity fido film final finance financial fire firestone firmdale fish fishing fit fitness fj fk flickr flights flir florist flowers fly fm fo foo food foodnetwork football ford forex forsale forum foundation fox fr free fresenius frl frogans frontdoor frontier ftr fujitsu fujixerox fun fund furniture futbol fyi ga gal gallery gallo gallup game games gap garden gay gb gbiz gd gdn ge gea gent genting george gf gg ggee gh gi gift gifts gives giving gl glade glass gle global globo gm gmail gmbh gmo gmx gn godaddy gold goldpoint golf goo goodyear goog google gop got gov gp gq gr grainger graphics gratis green gripe grocery group gs gt gu guardian gucci guge guide guitars guru gw gy hair hamburg hangout haus hbo hdfc hdfcbank health healthcare help helsinki here hermes hgtv hiphop hisamitsu hitachi hiv hk hkt hm hn hockey holdings holiday homedepot homegoods homes homesense honda horse hospital host hosting hot hoteles hotels hotmail house how hr hsbc ht hu hughes hyatt hyundai ibm icbc ice icu id ie ieee ifm ikano il im imamat imdb immo immobilien in inc industries infiniti info ing ink institute insurance insure int international intuit investments io ipiranga iq ir irish is ismaili ist istanbul it itau itv iveco jaguar java jcb je jeep jetzt jewelry jio jll jm jmp jnj jo jobs joburg jot joy jp jpmorgan jprs juegos juniper kaufen kddi ke kerryhotels kerrylogistics kerryproperties kfh kg kh ki kia kim kinder kindle kitchen kiwi km kn koeln komatsu kosher kp kpmg kpn kr krd kred kuokgroup kw ky kyoto kz la lacaixa lamborghini lamer lancaster lancia land landrover lanxess lasalle lat latino latrobe law lawyer lb lc lds lease leclerc lefrak legal lego lexus lgbt li lidl life lifeinsurance lifestyle lighting like lilly limited limo lincoln linde link lipsy live living lixil lk llc llp loan loans locker locus loft lol london lotte lotto love lpl lplfinancial lr ls lt ltd ltda lu lundbeck luxe luxury lv ly ma macys madrid maif maison makeup man management mango map market marketing markets marriott marshalls maserati mattel mba mc mckinsey md me med media meet melbourne meme memorial men menu merckmsd mg mh miami microsoft mil mini mint mit mitsubishi mk ml mlb mls mm mma mn mo mobi mobile moda moe moi mom monash money monster mormon mortgage moscow moto motorcycles mov movie mp mq mr ms msd mt mtn mtr mu museum mutual mv mw mx my mz na nab nagoya name nationwide natura navy nba nc ne nec net netbank netflix network neustar new news next nextdirect nexus nf nfl ng ngo nhk ni nico nike nikon ninja nissan nissay nl no nokia northwesternmutual norton now nowruz nowtv np nr nra nrw ntt nu nyc nz obi observer off office okinawa olayan olayangroup oldnavy ollo om omega one ong onl online onyourside ooo open oracle orange org organic origins osaka otsuka ott ovh pa page panasonic paris pars partners parts party passagens pay pccw pe pet pf pfizer pg ph pharmacy phd philips phone photo photography photos physio pics pictet pictures pid pin ping pink pioneer pizza pk pl place play playstation plumbing plus pm pn pnc pohl poker politie porn post pr pramerica praxi press prime pro prod productions prof progressive promo properties property protection pru prudential ps pt pub pw pwc py qa qpon quebec quest qvc racing radio raid re read realestate realtor realty recipes red redstone redumbrella rehab reise reisen reit reliance ren rent rentals repair report republican rest restaurant review reviews rexroth rich richardli ricoh ril rio rip rmit ro rocher rocks rodeo rogers room rs rsvp ru rugby ruhr run rw rwe ryukyu sa saarland safe safety sakura sale salon samsclub samsung sandvik sandvikcoromant sanofi sap sarl sas save saxo sb sbi sbs sc sca scb schaeffler schmidt scholarships school schule schwarz science scjohnson scot sd se search seat secure security seek select sener services ses seven sew sex sexy sfr sg sh shangrila sharp shaw shell shia shiksha shoes shop shopping shouji show showtime si silk sina singles site sj sk ski skin sky skype sl sling sm smart smile sn sncf so soccer social softbank software sohu solar solutions song sony soy spa space sport spot spreadbetting sr srl ss st stada staples star statebank statefarm stc stcgroup stockholm storage store stream studio study style su sucks supplies supply support surf surgery suzuki sv swatch swiftcover swiss sx sy sydney systems sz tab taipei talk taobao target tatamotors tatar tattoo tax taxi tc tci td tdk team tech technology tel temasek tennis teva tf tg th thd theater theatre tiaa tickets tienda tiffany tips tires tirol tj tjmaxx tjx tk tkmaxx tl tm tmall tn to today tokyo tools top toray toshiba total tours town toyota toys tr trade trading training travel travelchannel travelers travelersinsurance trust trv tt tube tui tunes tushu tv tvs tw tz ua ubank ubs ug uk unicom university uno uol ups us uy uz va vacations vana vanguard vc ve vegas ventures verisign versicherung vet vg vi viajes video vig viking villas vin vip virgin visa vision viva vivo vlaanderen vn vodka volkswagen volvo vote voting voto voyage vu vuelos wales walmart walter wang wanggou watch watches weather weatherchannel webcam weber website wed wedding weibo weir wf whoswho wien wiki williamhill win windows wine winners wme wolterskluwer woodside work works world wow ws wtc wtf xbox xerox xfinity xihuan xin xxx xyz yachts yahoo yamaxun yandex ye yodobashi yoga yokohama you youtube yt yun za zappos zara zero zip zm zone zuerich zw vermögensberater-ctb vermögensberatung-pwb ελ ευ бг бел дети ею католик ком қаз мкд мон москва онлайн орг рус рф сайт срб укр გე հայ ישראל קום ابوظبي اتصالات ارامكو الاردن البحرين الجزائر السعودية العليان المغرب امارات ایران بارت بازار بھارت بيتك پاکستان ڀارت تونس سودان سورية شبكة عراق عرب عمان فلسطين قطر كاثوليك كوم مصر مليسيا موريتانيا موقع همراه कॉम नेट भारत भारतम् भारोत संगठन বাংলা ভারত ভাৰত ਭਾਰਤ ભારત ଭାରତ இந்தியா இலங்கை சிங்கப்பூர் భారత్ ಭಾರತ ഭാരതം ලංකා คอม ไทย ລາວ 닷넷 닷컴 삼성 한국 アマゾン グーグル クラウド コム ストア セール ファッション ポイント みんな 世界 中信 中国 中國 中文网 亚马逊 企业 佛山 信息 健康 八卦 公司 公益 台湾 台灣 商城 商店 商标 嘉里 嘉里大酒店 在线 大众汽车 大拿 天主教 娱乐 家電 广东 微博 慈善 我爱你 手机 招聘 政务 政府 新加坡 新闻 时尚 書籍 机构 淡马锡 游戏 澳門 点看 移动 组织机构 网址 网店 网站 网络 联通 诺基亚 谷歌 购物 通販 集团 電訊盈科 飞利浦 食品 餐厅 香格里拉 香港".split(" ");
16940
- var LETTER = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/;
16941
- var EMOJI = /(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEDD-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE74\uDE78-\uDE7C\uDE80-\uDE86\uDE90-\uDEAC\uDEB0-\uDEBA\uDEC0-\uDEC5\uDED0-\uDED9\uDEE0-\uDEE7\uDEF0-\uDEF6])/;
16942
- var EMOJI_VARIATION = /\uFE0F/;
16943
- var DIGIT = /\d/;
16944
- var SPACE = /\s/;
16945
- function init$2() {
16946
- var customProtocols = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
16947
- var S_START = makeState();
16948
- var S_NUM = makeAcceptingState(NUM);
16949
- var S_DOMAIN = makeAcceptingState(DOMAIN);
16950
- var S_DOMAIN_HYPHEN = makeState();
16951
- var S_WS = makeAcceptingState(WS);
16952
- var DOMAIN_REGEX_TRANSITIONS = [[DIGIT, S_DOMAIN], [LETTER, S_DOMAIN], [EMOJI, S_DOMAIN], [EMOJI_VARIATION, S_DOMAIN]];
16953
- var makeDomainState = function makeDomainState2() {
16954
- var state = makeAcceptingState(DOMAIN);
16955
- state.j = {
16956
- "-": S_DOMAIN_HYPHEN
16529
+ const buildCoreExtensions = () => [
16530
+ Document,
16531
+ Paragraph,
16532
+ Heading,
16533
+ Text$1,
16534
+ History,
16535
+ NodeProcessor,
16536
+ TextProcessor,
16537
+ SelectionProcessor,
16538
+ ProseMirrorPlugins
16539
+ ];
16540
+ const FontFamily = Mark2.create({
16541
+ name: TextSettings.FONT_FAMILY,
16542
+ group: MarkGroups.SETTINGS,
16543
+ addOptions: () => ({
16544
+ fonts: []
16545
+ }),
16546
+ addAttributes: () => ({
16547
+ value: { required: true }
16548
+ }),
16549
+ addCommands() {
16550
+ return {
16551
+ applyFontFamily: createCommand(({ commands: commands2 }, value) => {
16552
+ commands2.applyMark(this.name, { value });
16553
+ const font = commands2.findFontByName(value);
16554
+ let fontWeight = unref(commands2.getFontWeight());
16555
+ if (!font.isWeightSupported(fontWeight)) {
16556
+ fontWeight = font.findClosestWeight(fontWeight);
16557
+ commands2.applyFontWeight(fontWeight);
16558
+ }
16559
+ if (!font.isItalicSupported(fontWeight)) {
16560
+ commands2.removeItalic();
16561
+ }
16562
+ }),
16563
+ getFont: createCommand(({ commands: commands2 }) => {
16564
+ const defaultPreset = unref(this.options.defaultPreset);
16565
+ const defaultFont = commands2.findFontByName(defaultPreset.common.font_family);
16566
+ const fontFamily = commands2.getFontFamily();
16567
+ return computed(() => commands2.findFontByName(unref(fontFamily)) || defaultFont);
16568
+ }),
16569
+ findFontByName: createCommand((_, name) => {
16570
+ return this.options.fonts.find((font) => font.name === name);
16571
+ }),
16572
+ getFontFamily: createCommand(({ commands: commands2 }) => {
16573
+ return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontFamily());
16574
+ }),
16575
+ getDefaultFontFamily: createCommand(({ commands: commands2 }) => {
16576
+ const preset = commands2.getPreset();
16577
+ return computed(() => unref(preset).common.font_family);
16578
+ })
16957
16579
  };
16958
- state.jr = [].concat(DOMAIN_REGEX_TRANSITIONS);
16959
- return state;
16960
- };
16961
- var makeNearDomainState = function makeNearDomainState2(token) {
16962
- var state = makeDomainState();
16963
- state.t = token;
16964
- return state;
16965
- };
16966
- makeBatchT(S_START, [["'", makeAcceptingState(APOSTROPHE)], ["{", makeAcceptingState(OPENBRACE)], ["[", makeAcceptingState(OPENBRACKET)], ["<", makeAcceptingState(OPENANGLEBRACKET)], ["(", makeAcceptingState(OPENPAREN)], ["}", makeAcceptingState(CLOSEBRACE)], ["]", makeAcceptingState(CLOSEBRACKET)], [">", makeAcceptingState(CLOSEANGLEBRACKET)], [")", makeAcceptingState(CLOSEPAREN)], ["&", makeAcceptingState(AMPERSAND)], ["*", makeAcceptingState(ASTERISK)], ["@", makeAcceptingState(AT)], ["`", makeAcceptingState(BACKTICK)], ["^", makeAcceptingState(CARET)], [":", makeAcceptingState(COLON)], [",", makeAcceptingState(COMMA)], ["$", makeAcceptingState(DOLLAR)], [".", makeAcceptingState(DOT)], ["=", makeAcceptingState(EQUALS)], ["!", makeAcceptingState(EXCLAMATION)], ["-", makeAcceptingState(HYPHEN)], ["%", makeAcceptingState(PERCENT)], ["|", makeAcceptingState(PIPE)], ["+", makeAcceptingState(PLUS)], ["#", makeAcceptingState(POUND)], ["?", makeAcceptingState(QUERY)], ['"', makeAcceptingState(QUOTE)], ["/", makeAcceptingState(SLASH)], [";", makeAcceptingState(SEMI)], ["~", makeAcceptingState(TILDE)], ["_", makeAcceptingState(UNDERSCORE)], ["\\", makeAcceptingState(BACKSLASH)]]);
16967
- makeT(S_START, "\n", makeAcceptingState(NL));
16968
- makeRegexT(S_START, SPACE, S_WS);
16969
- makeT(S_WS, "\n", makeState());
16970
- makeRegexT(S_WS, SPACE, S_WS);
16971
- for (var i = 0; i < tlds.length; i++) {
16972
- makeChainT(S_START, tlds[i], makeNearDomainState(TLD), makeDomainState);
16973
- }
16974
- var S_PROTOCOL_FILE = makeDomainState();
16975
- var S_PROTOCOL_FTP = makeDomainState();
16976
- var S_PROTOCOL_HTTP = makeDomainState();
16977
- var S_MAILTO = makeDomainState();
16978
- makeChainT(S_START, "file", S_PROTOCOL_FILE, makeDomainState);
16979
- makeChainT(S_START, "ftp", S_PROTOCOL_FTP, makeDomainState);
16980
- makeChainT(S_START, "http", S_PROTOCOL_HTTP, makeDomainState);
16981
- makeChainT(S_START, "mailto", S_MAILTO, makeDomainState);
16982
- var S_PROTOCOL_SECURE = makeDomainState();
16983
- var S_FULL_PROTOCOL = makeAcceptingState(PROTOCOL);
16984
- var S_FULL_MAILTO = makeAcceptingState(MAILTO);
16985
- makeT(S_PROTOCOL_FTP, "s", S_PROTOCOL_SECURE);
16986
- makeT(S_PROTOCOL_FTP, ":", S_FULL_PROTOCOL);
16987
- makeT(S_PROTOCOL_HTTP, "s", S_PROTOCOL_SECURE);
16988
- makeT(S_PROTOCOL_HTTP, ":", S_FULL_PROTOCOL);
16989
- makeT(S_PROTOCOL_FILE, ":", S_FULL_PROTOCOL);
16990
- makeT(S_PROTOCOL_SECURE, ":", S_FULL_PROTOCOL);
16991
- makeT(S_MAILTO, ":", S_FULL_MAILTO);
16992
- var S_CUSTOM_PROTOCOL = makeDomainState();
16993
- for (var _i = 0; _i < customProtocols.length; _i++) {
16994
- makeChainT(S_START, customProtocols[_i], S_CUSTOM_PROTOCOL, makeDomainState);
16580
+ },
16581
+ parseHTML() {
16582
+ const getAttrs = (input) => ({ value: input.replace(/["']/g, "") });
16583
+ return [
16584
+ {
16585
+ style: "--zw-font-family",
16586
+ getAttrs
16587
+ },
16588
+ {
16589
+ style: "font-family",
16590
+ getAttrs
16591
+ }
16592
+ ];
16593
+ },
16594
+ renderHTML({ HTMLAttributes: attrs }) {
16595
+ const font_family = attrs.value ? `"${attrs.value}"` : null;
16596
+ return renderMark({ font_family });
16995
16597
  }
16996
- makeT(S_CUSTOM_PROTOCOL, ":", S_FULL_PROTOCOL);
16997
- makeChainT(S_START, "localhost", makeNearDomainState(LOCALHOST), makeDomainState);
16998
- makeRegexT(S_START, DIGIT, S_NUM);
16999
- makeRegexT(S_START, LETTER, S_DOMAIN);
17000
- makeRegexT(S_START, EMOJI, S_DOMAIN);
17001
- makeRegexT(S_START, EMOJI_VARIATION, S_DOMAIN);
17002
- makeRegexT(S_NUM, DIGIT, S_NUM);
17003
- makeRegexT(S_NUM, LETTER, S_DOMAIN);
17004
- makeRegexT(S_NUM, EMOJI, S_DOMAIN);
17005
- makeRegexT(S_NUM, EMOJI_VARIATION, S_DOMAIN);
17006
- makeT(S_NUM, "-", S_DOMAIN_HYPHEN);
17007
- makeT(S_DOMAIN, "-", S_DOMAIN_HYPHEN);
17008
- makeT(S_DOMAIN_HYPHEN, "-", S_DOMAIN_HYPHEN);
17009
- makeRegexT(S_DOMAIN, DIGIT, S_DOMAIN);
17010
- makeRegexT(S_DOMAIN, LETTER, S_DOMAIN);
17011
- makeRegexT(S_DOMAIN, EMOJI, S_DOMAIN);
17012
- makeRegexT(S_DOMAIN, EMOJI_VARIATION, S_DOMAIN);
17013
- makeRegexT(S_DOMAIN_HYPHEN, DIGIT, S_DOMAIN);
17014
- makeRegexT(S_DOMAIN_HYPHEN, LETTER, S_DOMAIN);
17015
- makeRegexT(S_DOMAIN_HYPHEN, EMOJI, S_DOMAIN);
17016
- makeRegexT(S_DOMAIN_HYPHEN, EMOJI_VARIATION, S_DOMAIN);
17017
- S_START.jd = makeAcceptingState(SYM);
17018
- return S_START;
17019
- }
17020
- function run$1(start2, str) {
17021
- var iterable = stringToArray(str.replace(/[A-Z]/g, function(c) {
17022
- return c.toLowerCase();
17023
- }));
17024
- var charCount = iterable.length;
17025
- var tokens = [];
17026
- var cursor = 0;
17027
- var charCursor = 0;
17028
- while (charCursor < charCount) {
17029
- var state = start2;
17030
- var nextState = null;
17031
- var tokenLength = 0;
17032
- var latestAccepting = null;
17033
- var sinceAccepts = -1;
17034
- var charsSinceAccepts = -1;
17035
- while (charCursor < charCount && (nextState = takeT(state, iterable[charCursor]))) {
17036
- state = nextState;
17037
- if (state.accepts()) {
17038
- sinceAccepts = 0;
17039
- charsSinceAccepts = 0;
17040
- latestAccepting = state;
17041
- } else if (sinceAccepts >= 0) {
17042
- sinceAccepts += iterable[charCursor].length;
17043
- charsSinceAccepts++;
16598
+ });
16599
+ const StylePreset = Extension.create({
16600
+ name: TextSettings.STYLE_PRESET,
16601
+ addGlobalAttributes() {
16602
+ return [
16603
+ {
16604
+ types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
16605
+ attributes: {
16606
+ preset: {
16607
+ isRequired: false,
16608
+ default: { id: this.options.defaultId },
16609
+ parseHTML: (element) => {
16610
+ const presets = unref(this.options.presets);
16611
+ if (element.parentElement.tagName === "LI")
16612
+ return null;
16613
+ for (const { id: id2, node, fallbackClass } of presets) {
16614
+ if (fallbackClass && element.classList.contains(fallbackClass)) {
16615
+ return { id: id2 };
16616
+ }
16617
+ const presetSelector = this.options.styleRenderer.makePresetCssClass({ id: id2 });
16618
+ if (element.matches(presetSelector))
16619
+ return { id: id2 };
16620
+ if (element.tagName === `H${node == null ? void 0 : node.level}`)
16621
+ return { id: id2 };
16622
+ }
16623
+ return element.tagName === "P" ? { id: this.options.defaultId } : null;
16624
+ },
16625
+ renderHTML: (attrs) => {
16626
+ if (!attrs.preset)
16627
+ return null;
16628
+ return { class: this.options.styleRenderer.makePresetHtmlClass(attrs.preset) };
16629
+ }
16630
+ }
16631
+ }
17044
16632
  }
17045
- tokenLength += iterable[charCursor].length;
17046
- cursor += iterable[charCursor].length;
17047
- charCursor++;
16633
+ ];
16634
+ },
16635
+ addCommands() {
16636
+ function findPresetById(presets, id2) {
16637
+ return presets.find((preset) => id2 === preset.id);
17048
16638
  }
17049
- cursor -= sinceAccepts;
17050
- charCursor -= charsSinceAccepts;
17051
- tokenLength -= sinceAccepts;
17052
- tokens.push({
17053
- t: latestAccepting.t,
17054
- v: str.substr(cursor - tokenLength, tokenLength),
17055
- s: cursor - tokenLength,
17056
- e: cursor
17057
- });
17058
- }
17059
- return tokens;
17060
- }
17061
- function stringToArray(str) {
17062
- var result = [];
17063
- var len = str.length;
17064
- var index = 0;
17065
- while (index < len) {
17066
- var first2 = str.charCodeAt(index);
17067
- var second = void 0;
17068
- var char = first2 < 55296 || first2 > 56319 || index + 1 === len || (second = str.charCodeAt(index + 1)) < 56320 || second > 57343 ? str[index] : str.slice(index, index + 2);
17069
- result.push(char);
17070
- index += char.length;
16639
+ function mergeSettings(source, target) {
16640
+ const settings = {};
16641
+ for (const name of Object.keys(source)) {
16642
+ const sourceValue = source[name];
16643
+ const targetValue = target[name];
16644
+ const isInherit = !targetValue || targetValue.toLowerCase() === "inherit";
16645
+ settings[name] = isInherit ? sourceValue : targetValue;
16646
+ }
16647
+ return settings;
16648
+ }
16649
+ return {
16650
+ getPresetList: createCommand(() => computed(() => {
16651
+ return this.options.presets.filter((preset) => !preset.hidden);
16652
+ })),
16653
+ getPreset: createCommand(({ commands: commands2 }) => {
16654
+ const selectionRef = commands2.getBlockAttributes("preset", { id: this.options.defaultId });
16655
+ const presetsRef = commands2.getPresetList();
16656
+ const isLinkRef = commands2.isLink();
16657
+ const linkPresetRef = commands2.getLinkPreset();
16658
+ return computed(() => {
16659
+ const preset = findPresetById(unref(presetsRef), unref(selectionRef).id);
16660
+ if (!unref(isLinkRef))
16661
+ return preset;
16662
+ const linkPreset = unref(linkPresetRef);
16663
+ return {
16664
+ id: preset.id,
16665
+ common: mergeSettings(preset.common, linkPreset.common),
16666
+ mobile: mergeSettings(preset.mobile, linkPreset.mobile),
16667
+ tablet: mergeSettings(preset.tablet, linkPreset.tablet),
16668
+ desktop: mergeSettings(preset.desktop, linkPreset.desktop)
16669
+ };
16670
+ });
16671
+ }),
16672
+ applyPreset: createCommand(({ commands: commands2, chain }, presetId) => {
16673
+ var _a;
16674
+ const presets = unref(commands2.getPresetList());
16675
+ const preset = findPresetById(presets, presetId);
16676
+ const nodeType = ((_a = preset.node) == null ? void 0 : _a.type) ?? NodeTypes.PARAGRAPH;
16677
+ const attrs = {
16678
+ preset: { id: presetId }
16679
+ };
16680
+ if (preset.node) {
16681
+ attrs.level = preset.node.level;
16682
+ }
16683
+ for (const textAttribute of TextSettings.attributes) {
16684
+ attrs[textAttribute] = unref(commands2.getBlockAttributes(textAttribute));
16685
+ }
16686
+ chain().removeList().setNode(nodeType, attrs).run();
16687
+ }),
16688
+ applyDefaultPreset: createCommand(({ commands: commands2 }) => {
16689
+ commands2.applyPreset(this.options.defaultId);
16690
+ }),
16691
+ removePreset: createCommand(({ commands: commands2 }) => {
16692
+ commands2.setNode(NodeTypes.PARAGRAPH, { preset: null });
16693
+ }),
16694
+ getPresetCustomization: createCommand(({ editor, commands: commands2 }) => {
16695
+ const state = toRef(editor, "state");
16696
+ return computed(() => {
16697
+ const { selection, doc: doc2 } = unref(state);
16698
+ const { from: from2, to } = selection;
16699
+ return commands2._getSettingCustomization(doc2, from2, to);
16700
+ });
16701
+ }),
16702
+ isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
16703
+ const customization = commands2.getPresetCustomization();
16704
+ const group = TextSettings.attributes.includes(name) ? "attributes" : "marks";
16705
+ return computed(() => {
16706
+ var _a;
16707
+ return ((_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) ?? false;
16708
+ });
16709
+ }),
16710
+ getContentCustomization: createCommand(({ editor, commands: commands2 }) => {
16711
+ const state = toRef(editor, "state");
16712
+ return computed(() => {
16713
+ const { doc: doc2 } = unref(state);
16714
+ return commands2._getSettingCustomization(doc2, 0, doc2.content.size);
16715
+ });
16716
+ }),
16717
+ _getSettingCustomization: createCommand((_, doc2, from2, to) => {
16718
+ const marks = /* @__PURE__ */ new Set();
16719
+ const attributes = /* @__PURE__ */ new Set();
16720
+ doc2.nodesBetween(from2, to, (node) => {
16721
+ for (const [name, value] of Object.entries(node.attrs)) {
16722
+ const isSetting = TextSettings.attributes.includes(name);
16723
+ if (isSetting && value)
16724
+ attributes.add(name);
16725
+ }
16726
+ for (const { type } of node.marks) {
16727
+ if (TextSettings.marks.includes(type.name)) {
16728
+ marks.add(type.name);
16729
+ }
16730
+ }
16731
+ });
16732
+ return {
16733
+ attributes: Array.from(attributes),
16734
+ marks: Array.from(marks)
16735
+ };
16736
+ }),
16737
+ removePresetCustomization: createCommand(({ chain }) => {
16738
+ chain().storeSelection().expandSelectionToBlock().removeMarks(TextSettings.marks).resetAttributes(NodeTypes.PARAGRAPH, TextSettings.attributes).resetAttributes(NodeTypes.HEADING, TextSettings.attributes).restoreSelection().run();
16739
+ }),
16740
+ removeFormat: createCommand(({ chain }) => {
16741
+ chain().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run();
16742
+ })
16743
+ };
16744
+ },
16745
+ onCreate() {
16746
+ this.options.styleRenderer.inject(ContextWindow.head, this.options.presets);
17071
16747
  }
17072
- return result;
17073
- }
17074
- function _typeof(obj) {
17075
- "@babel/helpers - typeof";
17076
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
17077
- _typeof = function(obj2) {
17078
- return typeof obj2;
16748
+ });
16749
+ const FontWeight = Mark2.create({
16750
+ name: TextSettings.FONT_WEIGHT,
16751
+ group: MarkGroups.SETTINGS,
16752
+ addAttributes: () => ({
16753
+ value: { required: true }
16754
+ }),
16755
+ addCommands() {
16756
+ return {
16757
+ applyFontWeight: createCommand(({ commands: commands2 }, value) => {
16758
+ commands2.applyMark(this.name, { value });
16759
+ const font = unref(commands2.getFont());
16760
+ if (!font.isItalicSupported(value)) {
16761
+ commands2.removeItalic();
16762
+ }
16763
+ }),
16764
+ toggleBold: createCommand(({ commands: commands2 }) => {
16765
+ const currentWeight = unref(commands2.getFontWeight());
16766
+ const currentFont = unref(commands2.getFont());
16767
+ const isBold = Number(currentWeight) >= 600;
16768
+ const wantedWeight = isBold ? "400" : "700";
16769
+ const nextWeight = currentFont.findClosestWeight(wantedWeight);
16770
+ commands2.applyFontWeight(nextWeight);
16771
+ }),
16772
+ getFontWeight: createCommand(({ commands: commands2 }) => {
16773
+ const selectionRef = commands2.getCommonSettingMark(this.name, commands2.getDefaultFontWeight());
16774
+ const fontRef = commands2.getFont();
16775
+ return computed(() => {
16776
+ const weight = unref(selectionRef);
16777
+ const font = unref(fontRef);
16778
+ return font.isWeightSupported(weight) ? weight : font.findClosestWeight(weight);
16779
+ });
16780
+ }),
16781
+ getDefaultFontWeight: createCommand(({ commands: commands2 }) => {
16782
+ const preset = commands2.getPreset();
16783
+ return computed(() => unref(preset).common.font_weight);
16784
+ })
17079
16785
  };
17080
- } else {
17081
- _typeof = function(obj2) {
17082
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
16786
+ },
16787
+ addKeyboardShortcuts: () => ({
16788
+ "Mod-b": createKeyboardShortcut("toggleBold"),
16789
+ "Mod-B": createKeyboardShortcut("toggleBold")
16790
+ }),
16791
+ parseHTML() {
16792
+ const getAttrs = (value) => {
16793
+ if (value === "bold")
16794
+ return { value: "700" };
16795
+ return Number(value) ? { value } : false;
17083
16796
  };
16797
+ return [
16798
+ {
16799
+ style: "--zw-font-weight",
16800
+ getAttrs
16801
+ },
16802
+ {
16803
+ style: "font-weight",
16804
+ getAttrs
16805
+ },
16806
+ {
16807
+ tag: "b",
16808
+ attrs: { value: "700" }
16809
+ },
16810
+ {
16811
+ tag: "strong",
16812
+ attrs: { value: "700" }
16813
+ }
16814
+ ];
16815
+ },
16816
+ renderHTML({ HTMLAttributes: attrs }) {
16817
+ return renderMark({ font_weight: attrs.value });
17084
16818
  }
17085
- return _typeof(obj);
17086
- }
17087
- var defaults = {
17088
- defaultProtocol: "http",
17089
- events: null,
17090
- format: noop$1,
17091
- formatHref: noop$1,
17092
- nl2br: false,
17093
- tagName: "a",
17094
- target: null,
17095
- rel: null,
17096
- validate: true,
17097
- truncate: 0,
17098
- className: null,
17099
- attributes: null,
17100
- ignoreTags: []
17101
- };
17102
- function Options(opts) {
17103
- opts = opts || {};
17104
- this.defaultProtocol = "defaultProtocol" in opts ? opts.defaultProtocol : defaults.defaultProtocol;
17105
- this.events = "events" in opts ? opts.events : defaults.events;
17106
- this.format = "format" in opts ? opts.format : defaults.format;
17107
- this.formatHref = "formatHref" in opts ? opts.formatHref : defaults.formatHref;
17108
- this.nl2br = "nl2br" in opts ? opts.nl2br : defaults.nl2br;
17109
- this.tagName = "tagName" in opts ? opts.tagName : defaults.tagName;
17110
- this.target = "target" in opts ? opts.target : defaults.target;
17111
- this.rel = "rel" in opts ? opts.rel : defaults.rel;
17112
- this.validate = "validate" in opts ? opts.validate : defaults.validate;
17113
- this.truncate = "truncate" in opts ? opts.truncate : defaults.truncate;
17114
- this.className = "className" in opts ? opts.className : defaults.className;
17115
- this.attributes = opts.attributes || defaults.attributes;
17116
- this.ignoreTags = [];
17117
- var ignoredTags = "ignoreTags" in opts ? opts.ignoreTags : defaults.ignoreTags;
17118
- for (var i = 0; i < ignoredTags.length; i++) {
17119
- this.ignoreTags.push(ignoredTags[i].toUpperCase());
16819
+ });
16820
+ const FontSize = Mark2.create({
16821
+ name: TextSettings.FONT_SIZE,
16822
+ group: MarkGroups.SETTINGS,
16823
+ addOptions: () => ({
16824
+ minSize: 1,
16825
+ maxSize: 100
16826
+ }),
16827
+ addAttributes() {
16828
+ return {
16829
+ mobile: { default: null },
16830
+ tablet: { default: null },
16831
+ desktop: { default: null }
16832
+ };
16833
+ },
16834
+ addCommands() {
16835
+ return {
16836
+ getFontSize: createCommand(({ commands: commands2 }) => {
16837
+ return commands2.getDeviceSettingMark(this.name, commands2.getDefaultFontSize());
16838
+ }),
16839
+ getDefaultFontSize: createCommand(({ commands: commands2 }) => {
16840
+ const device = commands2.getDevice();
16841
+ const preset = commands2.getPreset();
16842
+ return computed(() => unref(preset)[unref(device)].font_size.replace("px", ""));
16843
+ }),
16844
+ applyFontSize: createCommand(({ commands: commands2 }, value) => {
16845
+ const device = unref(commands2.getDevice());
16846
+ commands2.applyMark(this.name, { [device]: value }, {
16847
+ isAppliedToParent: (parentMark, mark) => {
16848
+ if (parentMark.type.name !== mark.type.name)
16849
+ return false;
16850
+ return parentMark.attrs[device] === mark.attrs[device];
16851
+ },
16852
+ onAppliedToParent: ({ tr, node, position, mark }) => {
16853
+ const attrs = { ...mark.attrs, [device]: null };
16854
+ const canRemove = !Object.values(attrs).some((value2) => !!value2);
16855
+ if (canRemove)
16856
+ return false;
16857
+ const updated = mark.type.create(attrs);
16858
+ if (node.isText) {
16859
+ tr.addMark(position, position + node.nodeSize, updated);
16860
+ return;
16861
+ }
16862
+ tr.addNodeMark(position, updated);
16863
+ }
16864
+ });
16865
+ }),
16866
+ increaseFontSize: createCommand(({ commands: commands2 }) => {
16867
+ const size2 = Number(unref(commands2.getFontSize()));
16868
+ const nextSize = Math.min(size2 + 1, this.options.maxSize);
16869
+ commands2.applyFontSize(String(nextSize));
16870
+ }),
16871
+ decreaseFontSize: createCommand(({ commands: commands2 }) => {
16872
+ const size2 = Number(unref(commands2.getFontSize()));
16873
+ const nextSize = Math.max(size2 - 1, this.options.minSize);
16874
+ commands2.applyFontSize(String(nextSize));
16875
+ })
16876
+ };
16877
+ },
16878
+ addKeyboardShortcuts: () => ({
16879
+ "Mod-Shift-=": createKeyboardShortcut("increaseFontSize"),
16880
+ "Mod-Shift--": createKeyboardShortcut("decreaseFontSize")
16881
+ }),
16882
+ parseHTML() {
16883
+ const parseSize = (value) => {
16884
+ if (!value)
16885
+ return null;
16886
+ const wrapperEl = unref(this.options.wrapperRef);
16887
+ const converted = convertFontSize(value, wrapperEl);
16888
+ return String(converted);
16889
+ };
16890
+ return [
16891
+ {
16892
+ tag: '[style*="--zw-font-size"]',
16893
+ getAttrs: ({ style: style2 }) => ({
16894
+ mobile: parseSize(style2.getPropertyValue("--zw-font-size-mobile")),
16895
+ tablet: parseSize(style2.getPropertyValue("--zw-font-size-tablet")),
16896
+ desktop: parseSize(style2.getPropertyValue("--zw-font-size-desktop"))
16897
+ })
16898
+ },
16899
+ {
16900
+ style: "font-size",
16901
+ getAttrs: (input) => {
16902
+ const value = parseSize(input);
16903
+ return { desktop: value, tablet: value, mobile: null };
16904
+ }
16905
+ }
16906
+ ];
16907
+ },
16908
+ renderHTML({ HTMLAttributes: attrs }) {
16909
+ const addUnits = (value) => value ? `${value}px` : null;
16910
+ return renderMark({
16911
+ font_size_mobile: addUnits(attrs.mobile),
16912
+ font_size_tablet: addUnits(attrs.tablet),
16913
+ font_size_desktop: addUnits(attrs.desktop)
16914
+ });
17120
16915
  }
17121
- }
17122
- Options.prototype = {
17123
- resolve: function resolve(token) {
17124
- var href = token.toHref(this.defaultProtocol);
16916
+ });
16917
+ const FontColor = Mark2.create({
16918
+ name: TextSettings.FONT_COLOR,
16919
+ group: MarkGroups.SETTINGS,
16920
+ addAttributes: () => ({
16921
+ value: { required: true }
16922
+ }),
16923
+ addCommands() {
17125
16924
  return {
17126
- formatted: this.get("format", token.toString(), token),
17127
- formattedHref: this.get("formatHref", href, token),
17128
- tagName: this.get("tagName", href, token),
17129
- className: this.get("className", href, token),
17130
- target: this.get("target", href, token),
17131
- rel: this.get("rel", href, token),
17132
- events: this.getObject("events", href, token),
17133
- attributes: this.getObject("attributes", href, token),
17134
- truncate: this.get("truncate", href, token)
16925
+ getFontColor: createCommand(({ commands: commands2 }) => {
16926
+ return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontColor());
16927
+ }),
16928
+ getDefaultFontColor: createCommand(({ commands: commands2 }) => {
16929
+ const preset = commands2.getPreset();
16930
+ return computed(() => unref(preset).common.color);
16931
+ }),
16932
+ applyFontColor: createCommand(({ commands: commands2 }, value) => {
16933
+ commands2.applyMark(this.name, { value });
16934
+ })
17135
16935
  };
17136
16936
  },
17137
- check: function check(token) {
17138
- return this.get("validate", token.toString(), token);
16937
+ parseHTML() {
16938
+ const getAttrs = (value) => ({ value: convertColor(value) });
16939
+ return [
16940
+ {
16941
+ style: "--zw-font-color",
16942
+ getAttrs
16943
+ },
16944
+ {
16945
+ style: "color",
16946
+ getAttrs
16947
+ }
16948
+ ];
17139
16949
  },
17140
- get: function get2(key, operator, token) {
17141
- var option = this[key];
17142
- if (!option) {
17143
- return option;
17144
- }
17145
- var optionValue;
17146
- switch (_typeof(option)) {
17147
- case "function":
17148
- return option(operator, token.t);
17149
- case "object":
17150
- optionValue = token.t in option ? option[token.t] : defaults[key];
17151
- return typeof optionValue === "function" ? optionValue(operator, token.t) : optionValue;
17152
- }
17153
- return option;
16950
+ renderHTML({ HTMLAttributes: attrs }) {
16951
+ return renderMark({ font_color: attrs.value });
16952
+ }
16953
+ });
16954
+ const BackgroundColor = Mark2.create({
16955
+ name: TextSettings.BACKGROUND_COLOR,
16956
+ addAttributes: () => ({
16957
+ value: { required: true }
16958
+ }),
16959
+ addCommands() {
16960
+ return {
16961
+ getBackgroundColor: createCommand(({ commands: commands2 }) => {
16962
+ return commands2.getCommonSettingMark(this.name, "rgba(255, 255, 255, 0%)");
16963
+ }),
16964
+ applyBackgroundColor: createCommand(({ commands: commands2 }, value) => {
16965
+ commands2.applyMark(this.name, { value });
16966
+ })
16967
+ };
17154
16968
  },
17155
- getObject: function getObject(key, operator, token) {
17156
- var option = this[key];
17157
- return typeof option === "function" ? option(operator, token.t) : option;
16969
+ parseHTML() {
16970
+ const getAttrs = (value) => ({ value: convertColor(value) });
16971
+ return [
16972
+ {
16973
+ style: "--zw-background-color",
16974
+ getAttrs
16975
+ },
16976
+ {
16977
+ style: "background-color",
16978
+ getAttrs
16979
+ }
16980
+ ];
16981
+ },
16982
+ renderHTML({ HTMLAttributes: attrs }) {
16983
+ return renderMark({ background_color: attrs.value });
17158
16984
  }
17159
- };
17160
- function noop$1(val) {
17161
- return val;
17162
- }
17163
- function inherits(parent, child) {
17164
- var props = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
17165
- var extended = Object.create(parent.prototype);
17166
- for (var p in props) {
17167
- extended[p] = props[p];
16985
+ });
16986
+ const DeviceManager = Extension.create({
16987
+ name: "device_manager",
16988
+ addCommands() {
16989
+ return {
16990
+ getDevice: createCommand(() => toRef(this.options, "device"))
16991
+ };
17168
16992
  }
17169
- extended.constructor = child;
17170
- child.prototype = extended;
17171
- return child;
17172
- }
17173
- function MultiToken() {
17174
- }
17175
- MultiToken.prototype = {
17176
- t: "token",
17177
- isLink: false,
17178
- toString: function toString() {
17179
- return this.v;
17180
- },
17181
- toHref: function toHref() {
17182
- return this.toString();
16993
+ });
16994
+ const FontStyle = Mark2.create({
16995
+ name: TextSettings.FONT_STYLE,
16996
+ group: MarkGroups.SETTINGS,
16997
+ addAttributes: () => ({
16998
+ italic: { required: true }
16999
+ }),
17000
+ addCommands() {
17001
+ return {
17002
+ isItalic: createCommand(({ commands: commands2 }) => {
17003
+ const selectionRef = commands2.getMark(this.name);
17004
+ const defaultValueRef = commands2.getDefaultFontStyle();
17005
+ return computed(() => {
17006
+ var _a;
17007
+ return ((_a = unref(selectionRef)) == null ? void 0 : _a.italic) ?? unref(defaultValueRef).italic;
17008
+ });
17009
+ }),
17010
+ isItalicAvailable: createCommand(({ commands: commands2 }) => {
17011
+ const fontRef = commands2.getFont();
17012
+ const fontWeightRef = commands2.getFontWeight();
17013
+ return computed(() => {
17014
+ const font = unref(fontRef);
17015
+ const weight = unref(fontWeightRef);
17016
+ return font.isItalicSupported(weight) && !font.isWeightItalicOnly(weight);
17017
+ });
17018
+ }),
17019
+ getDefaultFontStyle: createCommand(({ commands: commands2 }) => {
17020
+ const preset = commands2.getPreset();
17021
+ return computed(() => ({
17022
+ italic: unref(preset).common.font_style === "italic"
17023
+ }));
17024
+ }),
17025
+ toggleItalic: createCommand(({ commands: commands2 }) => {
17026
+ const isItalicAvailable = unref(commands2.isItalicAvailable());
17027
+ if (!isItalicAvailable)
17028
+ return;
17029
+ unref(commands2.isItalic()) ? commands2.removeItalic() : commands2.applyItalic();
17030
+ }),
17031
+ applyItalic: createCommand(({ commands: commands2 }) => {
17032
+ commands2.applyMark(this.name, { italic: true });
17033
+ }),
17034
+ removeItalic: createCommand(({ commands: commands2 }) => {
17035
+ commands2.applyMark(this.name, { italic: false });
17036
+ })
17037
+ };
17183
17038
  },
17184
- startIndex: function startIndex() {
17185
- return this.tk[0].s;
17039
+ addKeyboardShortcuts: () => ({
17040
+ "Mod-i": createKeyboardShortcut("toggleItalic"),
17041
+ "Mod-I": createKeyboardShortcut("toggleItalic")
17042
+ }),
17043
+ parseHTML() {
17044
+ const getAttrs = (value) => ({ italic: value.includes("italic") });
17045
+ return [
17046
+ {
17047
+ tag: "i",
17048
+ attrs: { italic: true }
17049
+ },
17050
+ {
17051
+ style: "--zw-font-style",
17052
+ getAttrs
17053
+ },
17054
+ {
17055
+ style: "font-style",
17056
+ getAttrs
17057
+ }
17058
+ ];
17186
17059
  },
17187
- endIndex: function endIndex() {
17188
- return this.tk[this.tk.length - 1].e;
17060
+ renderHTML({ HTMLAttributes: attrs }) {
17061
+ const font_style = attrs.italic ? "italic" : "normal";
17062
+ return renderMark({ font_style });
17063
+ }
17064
+ });
17065
+ const TextDecoration = Mark2.create({
17066
+ name: TextSettings.TEXT_DECORATION,
17067
+ priority: 1e3,
17068
+ addAttributes: () => ({
17069
+ underline: { default: false },
17070
+ strike_through: { default: false }
17071
+ }),
17072
+ addCommands() {
17073
+ return {
17074
+ isUnderline: createCommand(({ commands: commands2 }) => {
17075
+ const decoration = commands2.getTextDecoration();
17076
+ return computed(() => unref(decoration).underline);
17077
+ }),
17078
+ isStrikeThrough: createCommand(({ commands: commands2 }) => {
17079
+ const decoration = commands2.getTextDecoration();
17080
+ return computed(() => unref(decoration).strike_through);
17081
+ }),
17082
+ getTextDecoration: createCommand(({ commands: commands2 }) => {
17083
+ const selectionRef = commands2.getMark(this.name);
17084
+ const defaultValueRef = commands2.getDefaultTextDecoration();
17085
+ return computed(() => {
17086
+ const attrs = unref(selectionRef) ?? {};
17087
+ const defaultValue = unref(defaultValueRef);
17088
+ return {
17089
+ underline: attrs.underline || defaultValue.underline,
17090
+ strike_through: attrs.strike_through || defaultValue.strike_through
17091
+ };
17092
+ });
17093
+ }),
17094
+ isUnderlineCustomized: createCommand(({ commands: commands2 }) => {
17095
+ const currentValue = commands2.isUnderline();
17096
+ const defaultValue = commands2.getDefaultTextDecoration();
17097
+ return computed(() => unref(currentValue) !== unref(defaultValue).underline);
17098
+ }),
17099
+ getDefaultTextDecoration: createCommand(({ commands: commands2 }) => {
17100
+ const preset = commands2.getPreset();
17101
+ return computed(() => {
17102
+ const { text_decoration } = unref(preset).common;
17103
+ return {
17104
+ underline: text_decoration.includes("underline"),
17105
+ strike_through: text_decoration.includes("line-through")
17106
+ };
17107
+ });
17108
+ }),
17109
+ toggleUnderline: createCommand(({ commands: commands2 }) => {
17110
+ commands2.toggleTextDecoration("underline");
17111
+ }),
17112
+ toggleStrikeThrough: createCommand(({ commands: commands2 }) => {
17113
+ commands2.toggleTextDecoration("strike_through");
17114
+ }),
17115
+ toggleTextDecoration: createCommand(({ commands: commands2 }, name, toEnable = null) => {
17116
+ const value = unref(commands2.getTextDecoration());
17117
+ const isEnabled = toEnable ?? !value[name];
17118
+ commands2.applyMark(this.name, { [name]: isEnabled });
17119
+ }),
17120
+ applyTextDecoration: createCommand(({ commands: commands2 }, name) => {
17121
+ commands2.toggleTextDecoration(name, true);
17122
+ }),
17123
+ removeTextDecoration: createCommand(({ commands: commands2 }, name) => {
17124
+ commands2.toggleTextDecoration(name, false);
17125
+ })
17126
+ };
17189
17127
  },
17190
- toObject: function toObject() {
17191
- var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults.defaultProtocol;
17192
- return {
17193
- type: this.t,
17194
- value: this.v,
17195
- isLink: this.isLink,
17196
- href: this.toHref(protocol),
17197
- start: this.startIndex(),
17198
- end: this.endIndex()
17128
+ addKeyboardShortcuts: () => ({
17129
+ "Mod-u": createKeyboardShortcut("toggleUnderline"),
17130
+ "Mod-U": createKeyboardShortcut("toggleUnderline")
17131
+ }),
17132
+ parseHTML() {
17133
+ const getAttrs = (value) => {
17134
+ const underline = value.includes("underline");
17135
+ const strike_through = value.includes("line-through");
17136
+ if (!underline && !strike_through) {
17137
+ return false;
17138
+ }
17139
+ return { underline, strike_through };
17199
17140
  };
17141
+ return [
17142
+ {
17143
+ style: "--zw-text-decoration",
17144
+ getAttrs
17145
+ },
17146
+ {
17147
+ style: "text-decoration-line",
17148
+ getAttrs
17149
+ },
17150
+ {
17151
+ style: "text-decoration",
17152
+ getAttrs
17153
+ },
17154
+ {
17155
+ tag: "s",
17156
+ attrs: {
17157
+ underline: false,
17158
+ strike_through: true
17159
+ }
17160
+ },
17161
+ {
17162
+ tag: "u",
17163
+ attrs: {
17164
+ underline: true,
17165
+ strike_through: false
17166
+ }
17167
+ }
17168
+ ];
17169
+ },
17170
+ renderHTML({ HTMLAttributes: attrs }) {
17171
+ const decorations = [];
17172
+ if (attrs.underline)
17173
+ decorations.push("underline");
17174
+ if (attrs.strike_through)
17175
+ decorations.push("line-through");
17176
+ if (!decorations.length)
17177
+ decorations.push("none");
17178
+ return renderMark({ text_decoration: decorations.join(" ") });
17200
17179
  }
17201
- };
17202
- function createTokenClass(type, props) {
17203
- function Token(value, tokens) {
17204
- this.t = type;
17205
- this.v = value;
17206
- this.tk = tokens;
17207
- }
17208
- inherits(MultiToken, Token, props);
17209
- return Token;
17210
- }
17211
- var MailtoEmail = createTokenClass("email", {
17212
- isLink: true
17213
17180
  });
17214
- var Email = createTokenClass("email", {
17215
- isLink: true,
17216
- toHref: function toHref2() {
17217
- return "mailto:" + this.toString();
17181
+ const CaseStyle = Extension.create({
17182
+ name: "case_style",
17183
+ addCommands() {
17184
+ return {
17185
+ applyCaseStyle: createCommand(({ commands: commands2 }, value) => {
17186
+ switch (value) {
17187
+ case CaseStyles.CAPITALIZE:
17188
+ return commands2.applyCapitalize();
17189
+ case CaseStyles.LOWERCASE:
17190
+ return commands2.applyLowerCase();
17191
+ case CaseStyles.UPPERCASE:
17192
+ return commands2.applyUpperCase();
17193
+ }
17194
+ }),
17195
+ applyCapitalize: createCommand(({ commands: commands2 }) => {
17196
+ commands2.transformText(({ text: text2 }) => capitalize(text2));
17197
+ }),
17198
+ applyLowerCase: createCommand(({ commands: commands2 }) => {
17199
+ commands2.transformText(({ text: text2 }) => text2.toLowerCase());
17200
+ }),
17201
+ applyUpperCase: createCommand(({ commands: commands2 }) => {
17202
+ commands2.transformText(({ text: text2 }) => text2.toUpperCase());
17203
+ })
17204
+ };
17218
17205
  }
17219
17206
  });
17220
- var Text = createTokenClass("text");
17221
- var Nl = createTokenClass("nl");
17222
- var Url = createTokenClass("url", {
17223
- isLink: true,
17224
- toHref: function toHref3() {
17225
- var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults.defaultProtocol;
17226
- var tokens = this.tk;
17227
- var hasProtocol2 = false;
17228
- var hasSlashSlash = false;
17229
- var result = [];
17230
- var i = 0;
17231
- while (tokens[i].t === PROTOCOL) {
17232
- hasProtocol2 = true;
17233
- result.push(tokens[i].v);
17234
- i++;
17235
- }
17236
- while (tokens[i].t === SLASH) {
17237
- hasSlashSlash = true;
17238
- result.push(tokens[i].v);
17239
- i++;
17240
- }
17241
- for (; i < tokens.length; i++) {
17242
- result.push(tokens[i].v);
17243
- }
17244
- result = result.join("");
17245
- if (!(hasProtocol2 || hasSlashSlash)) {
17246
- result = "".concat(protocol, "://").concat(result);
17207
+ const DEFAULTS$1 = {
17208
+ mobile: null,
17209
+ tablet: null,
17210
+ desktop: null
17211
+ };
17212
+ const Alignment = Extension.create({
17213
+ name: TextSettings.ALIGNMENT,
17214
+ addGlobalAttributes: () => [
17215
+ {
17216
+ types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
17217
+ attributes: {
17218
+ [TextSettings.ALIGNMENT]: {
17219
+ isRequired: false,
17220
+ parseHTML({ style: style2 }) {
17221
+ const textAlign = convertAlignment(style2.textAlign);
17222
+ if (textAlign) {
17223
+ return { desktop: textAlign, tablet: textAlign, mobile: textAlign };
17224
+ }
17225
+ const mobile = style2.getPropertyValue("--zw-alignment-mobile") || null;
17226
+ const tablet = style2.getPropertyValue("--zw-alignment-tablet") || null;
17227
+ const desktop = style2.getPropertyValue("--zw-alignment-desktop") || null;
17228
+ if (!mobile && !tablet && !desktop)
17229
+ return null;
17230
+ return { desktop, tablet, mobile };
17231
+ },
17232
+ renderHTML(attrs) {
17233
+ if (!attrs.alignment)
17234
+ return null;
17235
+ return renderInlineSetting({
17236
+ alignment_mobile: attrs.alignment.mobile,
17237
+ alignment_tablet: attrs.alignment.tablet,
17238
+ alignment_desktop: attrs.alignment.desktop
17239
+ });
17240
+ }
17241
+ }
17242
+ }
17247
17243
  }
17248
- return result;
17244
+ ],
17245
+ addCommands() {
17246
+ return {
17247
+ toggleAlignment: createCommand(({ commands: commands2 }, value) => {
17248
+ const currentValue = commands2.getAlignment();
17249
+ const isCurrentValue = unref(currentValue) === value;
17250
+ !isCurrentValue ? commands2.applyAlignment(value) : commands2.removeAlignment();
17251
+ }),
17252
+ applyAlignment: createCommand(({ commands: commands2 }, value) => {
17253
+ const device = unref(commands2.getDevice());
17254
+ commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS$1);
17255
+ }),
17256
+ removeAlignment: createCommand(({ commands: commands2 }) => commands2.removeBlockAttributes(this.name)),
17257
+ getAlignment: createCommand(({ commands: commands2 }) => {
17258
+ const attribute = commands2.getBlockAttributes(this.name, DEFAULTS$1);
17259
+ const device = commands2.getDevice();
17260
+ const defaultValue = commands2.getDefaultAlignment();
17261
+ return computed(() => {
17262
+ var _a;
17263
+ return ((_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) ?? unref(defaultValue);
17264
+ });
17265
+ }),
17266
+ getDefaultAlignment: createCommand(({ commands: commands2 }) => {
17267
+ const device = commands2.getDevice();
17268
+ const preset = commands2.getPreset();
17269
+ return computed(() => unref(preset)[unref(device)].alignment);
17270
+ })
17271
+ };
17249
17272
  },
17250
- hasProtocol: function hasProtocol() {
17251
- return this.tk[0].t === PROTOCOL;
17273
+ addKeyboardShortcuts: () => ({
17274
+ "Mod-Shift-l": createKeyboardShortcut("applyAlignment", Alignments.LEFT),
17275
+ "Mod-Shift-e": createKeyboardShortcut("applyAlignment", Alignments.CENTER),
17276
+ "Mod-Shift-r": createKeyboardShortcut("applyAlignment", Alignments.RIGHT),
17277
+ "Mod-Shift-j": createKeyboardShortcut("applyAlignment", Alignments.JUSTIFY)
17278
+ })
17279
+ });
17280
+ const DEFAULTS = {
17281
+ mobile: null,
17282
+ tablet: null,
17283
+ desktop: null
17284
+ };
17285
+ const LineHeight = Extension.create({
17286
+ name: TextSettings.LINE_HEIGHT,
17287
+ addGlobalAttributes() {
17288
+ return [
17289
+ {
17290
+ types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
17291
+ attributes: {
17292
+ [TextSettings.LINE_HEIGHT]: {
17293
+ isRequired: false,
17294
+ parseHTML: (element) => {
17295
+ if (element.matches('[style*="--zw-line-height"]')) {
17296
+ const mobile = null;
17297
+ const tablet = element.style.getPropertyValue("--zw-line-height-tablet") || null;
17298
+ const desktop = element.style.getPropertyValue("--zw-line-height-desktop") || null;
17299
+ return { mobile, tablet, desktop };
17300
+ }
17301
+ const value = element.style.lineHeight;
17302
+ if (!value)
17303
+ return null;
17304
+ const wrapperEl = unref(this.options.wrapperRef);
17305
+ const converted = convertLineHeight(value, element, wrapperEl);
17306
+ return converted ? { desktop: converted, tablet: converted, mobile: null } : null;
17307
+ },
17308
+ renderHTML(attrs) {
17309
+ if (!attrs.line_height)
17310
+ return null;
17311
+ return renderInlineSetting({
17312
+ line_height_mobile: attrs.line_height.mobile,
17313
+ line_height_tablet: attrs.line_height.tablet,
17314
+ line_height_desktop: attrs.line_height.desktop
17315
+ });
17316
+ }
17317
+ }
17318
+ }
17319
+ }
17320
+ ];
17321
+ },
17322
+ addCommands() {
17323
+ return {
17324
+ getLineHeight: createCommand(({ commands: commands2 }) => {
17325
+ const attribute = commands2.getBlockAttributes(this.name, DEFAULTS);
17326
+ const device = commands2.getDevice();
17327
+ const defaultValue = commands2.getDefaultLineHeight();
17328
+ return computed(() => {
17329
+ var _a;
17330
+ return ((_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) ?? unref(defaultValue);
17331
+ });
17332
+ }),
17333
+ getDefaultLineHeight: createCommand(({ commands: commands2 }) => {
17334
+ const device = commands2.getDevice();
17335
+ const preset = commands2.getPreset();
17336
+ return computed(() => unref(preset)[unref(device)].line_height);
17337
+ }),
17338
+ applyLineHeight: createCommand(({ commands: commands2 }, value) => {
17339
+ const device = unref(commands2.getDevice());
17340
+ commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
17341
+ })
17342
+ };
17252
17343
  }
17253
17344
  });
17254
- var multi = /* @__PURE__ */ Object.freeze({
17255
- __proto__: null,
17256
- MultiToken,
17257
- Base: MultiToken,
17258
- createTokenClass,
17259
- MailtoEmail,
17260
- Email,
17261
- Text,
17262
- Nl,
17263
- Url
17345
+ const ListItem$1 = Node2.create({
17346
+ name: "listItem",
17347
+ addOptions() {
17348
+ return {
17349
+ HTMLAttributes: {}
17350
+ };
17351
+ },
17352
+ content: "paragraph block*",
17353
+ defining: true,
17354
+ parseHTML() {
17355
+ return [
17356
+ {
17357
+ tag: "li"
17358
+ }
17359
+ ];
17360
+ },
17361
+ renderHTML({ HTMLAttributes }) {
17362
+ return ["li", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
17363
+ },
17364
+ addKeyboardShortcuts() {
17365
+ return {
17366
+ Enter: () => this.editor.commands.splitListItem(this.name),
17367
+ Tab: () => this.editor.commands.sinkListItem(this.name),
17368
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
17369
+ };
17370
+ }
17264
17371
  });
17265
- function init$1() {
17266
- var S_START = makeState();
17267
- var S_PROTOCOL = makeState();
17268
- var S_MAILTO = makeState();
17269
- var S_PROTOCOL_SLASH = makeState();
17270
- var S_PROTOCOL_SLASH_SLASH = makeState();
17271
- var S_DOMAIN = makeState();
17272
- var S_DOMAIN_DOT = makeState();
17273
- var S_TLD = makeAcceptingState(Url);
17274
- var S_TLD_COLON = makeState();
17275
- var S_TLD_PORT = makeAcceptingState(Url);
17276
- var S_URL = makeAcceptingState(Url);
17277
- var S_URL_NON_ACCEPTING = makeState();
17278
- var S_URL_OPENBRACE = makeState();
17279
- var S_URL_OPENBRACKET = makeState();
17280
- var S_URL_OPENANGLEBRACKET = makeState();
17281
- var S_URL_OPENPAREN = makeState();
17282
- var S_URL_OPENBRACE_Q = makeAcceptingState(Url);
17283
- var S_URL_OPENBRACKET_Q = makeAcceptingState(Url);
17284
- var S_URL_OPENANGLEBRACKET_Q = makeAcceptingState(Url);
17285
- var S_URL_OPENPAREN_Q = makeAcceptingState(Url);
17286
- var S_URL_OPENBRACE_SYMS = makeState();
17287
- var S_URL_OPENBRACKET_SYMS = makeState();
17288
- var S_URL_OPENANGLEBRACKET_SYMS = makeState();
17289
- var S_URL_OPENPAREN_SYMS = makeState();
17290
- var S_EMAIL_DOMAIN = makeState();
17291
- var S_EMAIL_DOMAIN_DOT = makeState();
17292
- var S_EMAIL = makeAcceptingState(Email);
17293
- var S_EMAIL_COLON = makeState();
17294
- var S_EMAIL_PORT = makeAcceptingState(Email);
17295
- var S_MAILTO_EMAIL = makeAcceptingState(MailtoEmail);
17296
- var S_MAILTO_EMAIL_NON_ACCEPTING = makeState();
17297
- var S_LOCALPART = makeState();
17298
- var S_LOCALPART_AT = makeState();
17299
- var S_LOCALPART_DOT = makeState();
17300
- var S_NL = makeAcceptingState(Nl);
17301
- makeT(S_START, NL, S_NL);
17302
- makeT(S_START, PROTOCOL, S_PROTOCOL);
17303
- makeT(S_START, MAILTO, S_MAILTO);
17304
- makeT(S_PROTOCOL, SLASH, S_PROTOCOL_SLASH);
17305
- makeT(S_PROTOCOL_SLASH, SLASH, S_PROTOCOL_SLASH_SLASH);
17306
- makeT(S_START, TLD, S_DOMAIN);
17307
- makeT(S_START, DOMAIN, S_DOMAIN);
17308
- makeT(S_START, LOCALHOST, S_TLD);
17309
- makeT(S_START, NUM, S_DOMAIN);
17310
- makeT(S_PROTOCOL_SLASH_SLASH, TLD, S_URL);
17311
- makeT(S_PROTOCOL_SLASH_SLASH, DOMAIN, S_URL);
17312
- makeT(S_PROTOCOL_SLASH_SLASH, NUM, S_URL);
17313
- makeT(S_PROTOCOL_SLASH_SLASH, LOCALHOST, S_URL);
17314
- makeT(S_DOMAIN, DOT, S_DOMAIN_DOT);
17315
- makeT(S_EMAIL_DOMAIN, DOT, S_EMAIL_DOMAIN_DOT);
17316
- makeT(S_DOMAIN_DOT, TLD, S_TLD);
17317
- makeT(S_DOMAIN_DOT, DOMAIN, S_DOMAIN);
17318
- makeT(S_DOMAIN_DOT, NUM, S_DOMAIN);
17319
- makeT(S_DOMAIN_DOT, LOCALHOST, S_DOMAIN);
17320
- makeT(S_EMAIL_DOMAIN_DOT, TLD, S_EMAIL);
17321
- makeT(S_EMAIL_DOMAIN_DOT, DOMAIN, S_EMAIL_DOMAIN);
17322
- makeT(S_EMAIL_DOMAIN_DOT, NUM, S_EMAIL_DOMAIN);
17323
- makeT(S_EMAIL_DOMAIN_DOT, LOCALHOST, S_EMAIL_DOMAIN);
17324
- makeT(S_TLD, DOT, S_DOMAIN_DOT);
17325
- makeT(S_EMAIL, DOT, S_EMAIL_DOMAIN_DOT);
17326
- makeT(S_TLD, COLON, S_TLD_COLON);
17327
- makeT(S_TLD, SLASH, S_URL);
17328
- makeT(S_TLD_COLON, NUM, S_TLD_PORT);
17329
- makeT(S_TLD_PORT, SLASH, S_URL);
17330
- makeT(S_EMAIL, COLON, S_EMAIL_COLON);
17331
- makeT(S_EMAIL_COLON, NUM, S_EMAIL_PORT);
17332
- var qsAccepting = [AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, DOMAIN, EQUALS, HYPHEN, LOCALHOST, NUM, PERCENT, PIPE, PLUS, POUND, PROTOCOL, SLASH, SYM, TILDE, TLD, UNDERSCORE];
17333
- var qsNonAccepting = [APOSTROPHE, CLOSEANGLEBRACKET, CLOSEBRACE, CLOSEBRACKET, CLOSEPAREN, COLON, COMMA, DOT, EXCLAMATION, OPENANGLEBRACKET, OPENBRACE, OPENBRACKET, OPENPAREN, QUERY, QUOTE, SEMI];
17334
- makeT(S_URL, OPENBRACE, S_URL_OPENBRACE);
17335
- makeT(S_URL, OPENBRACKET, S_URL_OPENBRACKET);
17336
- makeT(S_URL, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);
17337
- makeT(S_URL, OPENPAREN, S_URL_OPENPAREN);
17338
- makeT(S_URL_NON_ACCEPTING, OPENBRACE, S_URL_OPENBRACE);
17339
- makeT(S_URL_NON_ACCEPTING, OPENBRACKET, S_URL_OPENBRACKET);
17340
- makeT(S_URL_NON_ACCEPTING, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);
17341
- makeT(S_URL_NON_ACCEPTING, OPENPAREN, S_URL_OPENPAREN);
17342
- makeT(S_URL_OPENBRACE, CLOSEBRACE, S_URL);
17343
- makeT(S_URL_OPENBRACKET, CLOSEBRACKET, S_URL);
17344
- makeT(S_URL_OPENANGLEBRACKET, CLOSEANGLEBRACKET, S_URL);
17345
- makeT(S_URL_OPENPAREN, CLOSEPAREN, S_URL);
17346
- makeT(S_URL_OPENBRACE_Q, CLOSEBRACE, S_URL);
17347
- makeT(S_URL_OPENBRACKET_Q, CLOSEBRACKET, S_URL);
17348
- makeT(S_URL_OPENANGLEBRACKET_Q, CLOSEANGLEBRACKET, S_URL);
17349
- makeT(S_URL_OPENPAREN_Q, CLOSEPAREN, S_URL);
17350
- makeT(S_URL_OPENBRACE_SYMS, CLOSEBRACE, S_URL);
17351
- makeT(S_URL_OPENBRACKET_SYMS, CLOSEBRACKET, S_URL);
17352
- makeT(S_URL_OPENANGLEBRACKET_SYMS, CLOSEANGLEBRACKET, S_URL);
17353
- makeT(S_URL_OPENPAREN_SYMS, CLOSEPAREN, S_URL);
17354
- makeMultiT(S_URL_OPENBRACE, qsAccepting, S_URL_OPENBRACE_Q);
17355
- makeMultiT(S_URL_OPENBRACKET, qsAccepting, S_URL_OPENBRACKET_Q);
17356
- makeMultiT(S_URL_OPENANGLEBRACKET, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
17357
- makeMultiT(S_URL_OPENPAREN, qsAccepting, S_URL_OPENPAREN_Q);
17358
- makeMultiT(S_URL_OPENBRACE, qsNonAccepting, S_URL_OPENBRACE_SYMS);
17359
- makeMultiT(S_URL_OPENBRACKET, qsNonAccepting, S_URL_OPENBRACKET_SYMS);
17360
- makeMultiT(S_URL_OPENANGLEBRACKET, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);
17361
- makeMultiT(S_URL_OPENPAREN, qsNonAccepting, S_URL_OPENPAREN_SYMS);
17362
- makeMultiT(S_URL_OPENBRACE_Q, qsAccepting, S_URL_OPENBRACE_Q);
17363
- makeMultiT(S_URL_OPENBRACKET_Q, qsAccepting, S_URL_OPENBRACKET_Q);
17364
- makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
17365
- makeMultiT(S_URL_OPENPAREN_Q, qsAccepting, S_URL_OPENPAREN_Q);
17366
- makeMultiT(S_URL_OPENBRACE_Q, qsNonAccepting, S_URL_OPENBRACE_Q);
17367
- makeMultiT(S_URL_OPENBRACKET_Q, qsNonAccepting, S_URL_OPENBRACKET_Q);
17368
- makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsNonAccepting, S_URL_OPENANGLEBRACKET_Q);
17369
- makeMultiT(S_URL_OPENPAREN_Q, qsNonAccepting, S_URL_OPENPAREN_Q);
17370
- makeMultiT(S_URL_OPENBRACE_SYMS, qsAccepting, S_URL_OPENBRACE_Q);
17371
- makeMultiT(S_URL_OPENBRACKET_SYMS, qsAccepting, S_URL_OPENBRACKET_Q);
17372
- makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsAccepting, S_URL_OPENANGLEBRACKET_Q);
17373
- makeMultiT(S_URL_OPENPAREN_SYMS, qsAccepting, S_URL_OPENPAREN_Q);
17374
- makeMultiT(S_URL_OPENBRACE_SYMS, qsNonAccepting, S_URL_OPENBRACE_SYMS);
17375
- makeMultiT(S_URL_OPENBRACKET_SYMS, qsNonAccepting, S_URL_OPENBRACKET_SYMS);
17376
- makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);
17377
- makeMultiT(S_URL_OPENPAREN_SYMS, qsNonAccepting, S_URL_OPENPAREN_SYMS);
17378
- makeMultiT(S_URL, qsAccepting, S_URL);
17379
- makeMultiT(S_URL_NON_ACCEPTING, qsAccepting, S_URL);
17380
- makeMultiT(S_URL, qsNonAccepting, S_URL_NON_ACCEPTING);
17381
- makeMultiT(S_URL_NON_ACCEPTING, qsNonAccepting, S_URL_NON_ACCEPTING);
17382
- makeT(S_MAILTO, TLD, S_MAILTO_EMAIL);
17383
- makeT(S_MAILTO, DOMAIN, S_MAILTO_EMAIL);
17384
- makeT(S_MAILTO, NUM, S_MAILTO_EMAIL);
17385
- makeT(S_MAILTO, LOCALHOST, S_MAILTO_EMAIL);
17386
- makeMultiT(S_MAILTO_EMAIL, qsAccepting, S_MAILTO_EMAIL);
17387
- makeMultiT(S_MAILTO_EMAIL, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING);
17388
- makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsAccepting, S_MAILTO_EMAIL);
17389
- makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING);
17390
- var localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, CLOSEBRACE, DOLLAR, DOMAIN, EQUALS, HYPHEN, NUM, OPENBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, TLD, UNDERSCORE];
17391
- makeMultiT(S_DOMAIN, localpartAccepting, S_LOCALPART);
17392
- makeT(S_DOMAIN, AT, S_LOCALPART_AT);
17393
- makeMultiT(S_TLD, localpartAccepting, S_LOCALPART);
17394
- makeT(S_TLD, AT, S_LOCALPART_AT);
17395
- makeMultiT(S_DOMAIN_DOT, localpartAccepting, S_LOCALPART);
17396
- makeMultiT(S_LOCALPART, localpartAccepting, S_LOCALPART);
17397
- makeT(S_LOCALPART, AT, S_LOCALPART_AT);
17398
- makeT(S_LOCALPART, DOT, S_LOCALPART_DOT);
17399
- makeMultiT(S_LOCALPART_DOT, localpartAccepting, S_LOCALPART);
17400
- makeT(S_LOCALPART_AT, TLD, S_EMAIL_DOMAIN);
17401
- makeT(S_LOCALPART_AT, DOMAIN, S_EMAIL_DOMAIN);
17402
- makeT(S_LOCALPART_AT, NUM, S_EMAIL_DOMAIN);
17403
- makeT(S_LOCALPART_AT, LOCALHOST, S_EMAIL);
17404
- return S_START;
17405
- }
17406
- function run(start2, input, tokens) {
17407
- var len = tokens.length;
17408
- var cursor = 0;
17409
- var multis = [];
17410
- var textTokens = [];
17411
- while (cursor < len) {
17412
- var state = start2;
17413
- var secondState = null;
17414
- var nextState = null;
17415
- var multiLength = 0;
17416
- var latestAccepting = null;
17417
- var sinceAccepts = -1;
17418
- while (cursor < len && !(secondState = takeT(state, tokens[cursor].t))) {
17419
- textTokens.push(tokens[cursor++]);
17372
+ const ListItem = ListItem$1.extend({
17373
+ name: NodeTypes.LIST_ITEM,
17374
+ marks: MarkGroups.SETTINGS,
17375
+ addCommands() {
17376
+ const getItemPosition = ({ selection }) => selection.$cursor.before(selection.$cursor.depth - 1);
17377
+ return {
17378
+ listItemNewline: createCommand(({ commands: commands2, tr }) => {
17379
+ const initialNode = tr.doc.nodeAt(getItemPosition(tr));
17380
+ const isEmptyParagraph = !tr.selection.$cursor.node().textContent;
17381
+ if (isEmptyParagraph)
17382
+ return false;
17383
+ commands2.splitListItem(this.name);
17384
+ const position = getItemPosition(tr);
17385
+ for (const mark of initialNode.marks) {
17386
+ tr.addNodeMark(position, copyMark(mark));
17387
+ }
17388
+ return true;
17389
+ })
17390
+ };
17391
+ },
17392
+ addOptions: () => ({
17393
+ HTMLAttributes: { class: "zw-style" }
17394
+ }),
17395
+ addKeyboardShortcuts: () => ({
17396
+ Enter: (context) => {
17397
+ var _a;
17398
+ const { state, commands: commands2 } = context.editor;
17399
+ const isListSelected = (_a = state.selection.$cursor) == null ? void 0 : _a.path.some((node) => {
17400
+ var _a2;
17401
+ return ((_a2 = node.type) == null ? void 0 : _a2.name) === NodeTypes.LIST;
17402
+ });
17403
+ if (isListSelected)
17404
+ return commands2.listItemNewline();
17420
17405
  }
17421
- while (cursor < len && (nextState = secondState || takeT(state, tokens[cursor].t))) {
17422
- secondState = null;
17423
- state = nextState;
17424
- if (state.accepts()) {
17425
- sinceAccepts = 0;
17426
- latestAccepting = state;
17427
- } else if (sinceAccepts >= 0) {
17428
- sinceAccepts++;
17429
- }
17430
- cursor++;
17431
- multiLength++;
17406
+ })
17407
+ });
17408
+ const List = Node2.create({
17409
+ name: NodeTypes.LIST,
17410
+ content: `${NodeTypes.LIST_ITEM}+`,
17411
+ group: "block list",
17412
+ marks: MarkGroups.SETTINGS,
17413
+ addExtensions: () => [
17414
+ ListItem
17415
+ ],
17416
+ addOptions: () => ({
17417
+ baseClass: "",
17418
+ presetClass: ""
17419
+ }),
17420
+ addAttributes: () => ({
17421
+ bullet: {
17422
+ default: { type: ListTypes.DISC }
17432
17423
  }
17433
- if (sinceAccepts < 0) {
17434
- for (var i = cursor - multiLength; i < cursor; i++) {
17435
- textTokens.push(tokens[i]);
17424
+ }),
17425
+ parseHTML() {
17426
+ const HTML_TYPES = {
17427
+ a: ListTypes.ROMAN,
17428
+ i: ListTypes.LATIN,
17429
+ "1": ListTypes.DECIMAL
17430
+ };
17431
+ const getBulletType = (element) => {
17432
+ for (const type of ListTypes.values) {
17433
+ const bulletClass = `.${this.options.baseClass}${type}`;
17434
+ if (element.matches(bulletClass))
17435
+ return type;
17436
+ if (HTML_TYPES[element.type.toLowerCase()] === type)
17437
+ return type;
17436
17438
  }
17437
- } else {
17438
- if (textTokens.length > 0) {
17439
- multis.push(parserCreateMultiToken(Text, input, textTokens));
17440
- textTokens = [];
17439
+ };
17440
+ return [
17441
+ {
17442
+ tag: "ol",
17443
+ getAttrs: (element) => ({
17444
+ bullet: { type: getBulletType(element) || ListTypes.DECIMAL }
17445
+ })
17446
+ },
17447
+ {
17448
+ tag: "ul",
17449
+ getAttrs: (element) => ({
17450
+ bullet: { type: getBulletType(element) || ListTypes.DISC }
17451
+ })
17441
17452
  }
17442
- cursor -= sinceAccepts;
17443
- multiLength -= sinceAccepts;
17444
- var Multi = latestAccepting.t;
17445
- var subtokens = tokens.slice(cursor - multiLength, cursor);
17446
- multis.push(parserCreateMultiToken(Multi, input, subtokens));
17447
- }
17448
- }
17449
- if (textTokens.length > 0) {
17450
- multis.push(parserCreateMultiToken(Text, input, textTokens));
17451
- }
17452
- return multis;
17453
- }
17454
- function parserCreateMultiToken(Multi, input, tokens) {
17455
- var startIdx = tokens[0].s;
17456
- var endIdx = tokens[tokens.length - 1].e;
17457
- var value = input.substr(startIdx, endIdx - startIdx);
17458
- return new Multi(value, tokens);
17459
- }
17460
- var warn = typeof console !== "undefined" && console && console.warn || function() {
17461
- };
17462
- var INIT = {
17463
- scanner: null,
17464
- parser: null,
17465
- pluginQueue: [],
17466
- customProtocols: [],
17467
- initialized: false
17468
- };
17469
- function reset() {
17470
- INIT.scanner = null;
17471
- INIT.parser = null;
17472
- INIT.pluginQueue = [];
17473
- INIT.customProtocols = [];
17474
- INIT.initialized = false;
17475
- }
17476
- function registerCustomProtocol(protocol) {
17477
- if (INIT.initialized) {
17478
- warn('linkifyjs: already initialized - will not register custom protocol "'.concat(protocol, '" until you manually call linkify.init(). To avoid this warning, please register all custom protocols before invoking linkify the first time.'));
17479
- }
17480
- if (!/^[a-z-]+$/.test(protocol)) {
17481
- throw Error("linkifyjs: protocols containing characters other than a-z or - (hyphen) are not supported");
17482
- }
17483
- INIT.customProtocols.push(protocol);
17484
- }
17485
- function init() {
17486
- INIT.scanner = {
17487
- start: init$2(INIT.customProtocols),
17488
- tokens: text
17489
- };
17490
- INIT.parser = {
17491
- start: init$1(),
17492
- tokens: multi
17493
- };
17494
- var utils = {
17495
- createTokenClass
17496
- };
17497
- for (var i = 0; i < INIT.pluginQueue.length; i++) {
17498
- INIT.pluginQueue[i][1]({
17499
- scanner: INIT.scanner,
17500
- parser: INIT.parser,
17501
- utils
17453
+ ];
17454
+ },
17455
+ renderHTML({ HTMLAttributes: attrs }) {
17456
+ const classes = [
17457
+ this.options.baseClass + attrs.bullet.type,
17458
+ this.options.presetClass
17459
+ ];
17460
+ const isOrdered = ListTypes.ordered.includes(attrs.bullet.type);
17461
+ return [isOrdered ? "ol" : "ul", { class: classes.join(" ") }, 0];
17462
+ },
17463
+ addCommands() {
17464
+ return {
17465
+ getListType: createCommand(({ commands: commands2 }) => {
17466
+ const attribute = commands2.getBlockAttributes("bullet", { type: null });
17467
+ return computed(() => unref(attribute).type ?? null);
17468
+ }),
17469
+ applyList: createCommand(({ commands: commands2, chain }, type) => {
17470
+ const currentType = unref(commands2.getListType());
17471
+ if (currentType === type) {
17472
+ commands2.removeList();
17473
+ return;
17474
+ }
17475
+ return chain().applyDefaultPreset().toggleList(NodeTypes.LIST, NodeTypes.LIST_ITEM).setBlockAttributes("bullet", { type }).command(({ commands: commands3, tr }) => commands3._bubbleListItemMarks(tr)).run();
17476
+ }),
17477
+ _bubbleListItemMarks: createCommand((_, tr) => {
17478
+ const { doc: doc2, selection } = tr;
17479
+ const from2 = selection.$from.start();
17480
+ const to = selection.$to.end();
17481
+ function canBubbleMark(node, childMark) {
17482
+ if (TextSettings.inlineMarks.includes(childMark.type))
17483
+ return false;
17484
+ if (childMark.type.isInSet(node.marks))
17485
+ return false;
17486
+ for (const child of node.content.content) {
17487
+ if (!child.childCount)
17488
+ continue;
17489
+ if (!child.marks)
17490
+ return false;
17491
+ if (!childMark.isInSet(child.marks))
17492
+ return false;
17493
+ }
17494
+ return true;
17495
+ }
17496
+ doc2.nodesBetween(from2, to, (node, position) => {
17497
+ if (node.type.name === NodeTypes.LIST)
17498
+ return;
17499
+ if (node.type.name !== NodeTypes.LIST_ITEM)
17500
+ return false;
17501
+ const bubbled = [];
17502
+ node.forEach((child) => {
17503
+ for (const childMark of child.marks) {
17504
+ if (childMark.isInSet(bubbled)) {
17505
+ tr.removeNodeMark(position + 1, childMark);
17506
+ continue;
17507
+ }
17508
+ if (canBubbleMark(node, childMark)) {
17509
+ tr.removeNodeMark(position + 1, childMark);
17510
+ tr.addNodeMark(position, copyMark(childMark));
17511
+ bubbled.push(childMark);
17512
+ }
17513
+ }
17514
+ });
17515
+ return false;
17516
+ });
17517
+ }),
17518
+ removeList: createCommand(({ commands: commands2, state }) => {
17519
+ const { tr, doc: doc2, selection } = state;
17520
+ const from2 = selection.$from.start();
17521
+ const to = selection.$to.end();
17522
+ doc2.nodesBetween(from2, to, (node, position, parent) => {
17523
+ if ([NodeTypes.LIST, NodeTypes.LIST_ITEM].includes(node.type.name))
17524
+ return;
17525
+ if (parent.type.name !== NodeTypes.LIST_ITEM)
17526
+ return false;
17527
+ const addingMarks = parent.marks.filter(function(mark) {
17528
+ return !mark.type.isInSet(node.marks);
17529
+ });
17530
+ for (const mark of addingMarks) {
17531
+ tr.addNodeMark(position, copyMark(mark));
17532
+ }
17533
+ return false;
17534
+ });
17535
+ commands2.liftListItem(NodeTypes.LIST_ITEM);
17536
+ })
17537
+ };
17538
+ },
17539
+ addInputRules() {
17540
+ const wrappingListRule = (bullet, regex) => wrappingInputRule({
17541
+ find: regex,
17542
+ type: this.type,
17543
+ getAttributes: { bullet: { type: bullet } },
17544
+ joinPredicate: (_, { attrs }) => attrs.bullet.type === bullet
17502
17545
  });
17546
+ return [
17547
+ wrappingListRule(ListTypes.DISC, /^\s*([-+*])\s$/),
17548
+ wrappingListRule(ListTypes.DECIMAL, /^(\d+)\.\s$/),
17549
+ wrappingListRule(ListTypes.LATIN, /^([ivx]{1,3})\.\s$/i),
17550
+ wrappingListRule(ListTypes.ROMAN, /^([a-z])\.\s$/i)
17551
+ ];
17503
17552
  }
17504
- INIT.initialized = true;
17505
- }
17506
- function tokenize(str) {
17507
- if (!INIT.initialized) {
17508
- init();
17509
- }
17510
- return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
17511
- }
17512
- function find$1(str) {
17513
- var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
17514
- var tokens = tokenize(str);
17515
- var filtered = [];
17516
- for (var i = 0; i < tokens.length; i++) {
17517
- var token = tokens[i];
17518
- if (token.isLink && (!type || token.t === type)) {
17519
- filtered.push(token.toObject());
17520
- }
17521
- }
17522
- return filtered;
17523
- }
17524
- function test$1(str) {
17525
- var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
17526
- var tokens = tokenize(str);
17527
- return tokens.length === 1 && tokens[0].isLink && (!type || tokens[0].t === type);
17528
- }
17553
+ });
17529
17554
  function autolink(options) {
17530
17555
  return new Plugin({
17531
17556
  key: new PluginKey("autolink"),
@@ -17755,11 +17780,13 @@ const Link$1 = Mark2.create({
17755
17780
  });
17756
17781
  const Link = Link$1.extend({
17757
17782
  name: TextSettings.LINK,
17783
+ addPasteRules: null,
17758
17784
  addOptions() {
17759
17785
  var _a;
17760
17786
  return {
17761
17787
  ...(_a = this.parent) == null ? void 0 : _a.call(this),
17762
- openOnClick: false
17788
+ openOnClick: false,
17789
+ linkOnPaste: false
17763
17790
  };
17764
17791
  },
17765
17792
  addAttributes() {
@@ -17792,9 +17819,7 @@ const Link = Link$1.extend({
17792
17819
  };
17793
17820
  },
17794
17821
  addCommands() {
17795
- var _a;
17796
17822
  return {
17797
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
17798
17823
  applyLink: createCommand(({ commands: commands2, chain }, attributes) => {
17799
17824
  commands2.setMeta("preventAutolink", true);
17800
17825
  if (!commands2.getSelectedText()) {
@@ -17803,7 +17828,9 @@ const Link = Link$1.extend({
17803
17828
  ]));
17804
17829
  }
17805
17830
  return chain().applyMark(this.name, attributes).expandSelectionToLink().command(({ tr }) => {
17806
- tr.insertText(attributes.text, tr.selection.from, tr.selection.to);
17831
+ if (attributes.text) {
17832
+ tr.insertText(attributes.text, tr.selection.from, tr.selection.to);
17833
+ }
17807
17834
  return true;
17808
17835
  }).run();
17809
17836
  }),
@@ -17814,11 +17841,16 @@ const Link = Link$1.extend({
17814
17841
  getLinkPreset: createCommand(() => computed(() => this.options.preset))
17815
17842
  };
17816
17843
  },
17844
+ addProseMirrorPlugins() {
17845
+ return [
17846
+ ...this.parent(),
17847
+ PasteLinkPlugin.create(this.editor)
17848
+ ];
17849
+ },
17817
17850
  renderHTML({ HTMLAttributes: attrs }) {
17818
17851
  const href = attrs.destination === LinkDestinations.BLOCK ? `#${attrs.href}` : attrs.href;
17819
17852
  const presetClass = unref(this.options.basePresetClass) + unref(this.options.preset).id;
17820
- const classes = `${presetClass} zw-style`;
17821
- const linkAttrs = { href, target: attrs.target, class: classes };
17853
+ const linkAttrs = { href, target: attrs.target, class: `${presetClass} zw-style` };
17822
17854
  return ["a", linkAttrs, 0];
17823
17855
  }
17824
17856
  });
@@ -19382,6 +19414,48 @@ class StylePresetRenderer {
19382
19414
  return this.makePresetHtmlClass(preset).split(" ").map((part) => `.${part}`).join("");
19383
19415
  }
19384
19416
  }
19417
+ const _NodeSelector = class {
19418
+ static get instance() {
19419
+ this._instance ?? (this._instance = new _NodeSelector());
19420
+ return this._instance;
19421
+ }
19422
+ static query(containerNode, selector) {
19423
+ return this.instance.query(containerNode, selector);
19424
+ }
19425
+ query(containerNode, selector) {
19426
+ let found2 = null;
19427
+ containerNode.descendants((node) => {
19428
+ if (found2)
19429
+ return false;
19430
+ if (this.matchNode(node, selector)) {
19431
+ found2 = node;
19432
+ return false;
19433
+ }
19434
+ });
19435
+ if (!found2)
19436
+ return null;
19437
+ if (!selector.getMark)
19438
+ return found2;
19439
+ return this.getMark(found2, selector.getMark);
19440
+ }
19441
+ matchNode(node, selector) {
19442
+ if (selector.typeName && selector.typeName !== node.type.name) {
19443
+ return false;
19444
+ }
19445
+ if (selector.mark && !this.getMark(node, selector.mark)) {
19446
+ return false;
19447
+ }
19448
+ return true;
19449
+ }
19450
+ getMark(node, selector) {
19451
+ return node.marks.find((mark) => this.matchMark(mark, selector)) || null;
19452
+ }
19453
+ matchMark(mark, selector) {
19454
+ return mark.type.name === selector.typeName;
19455
+ }
19456
+ };
19457
+ let NodeSelector = _NodeSelector;
19458
+ __publicField(NodeSelector, "_instance");
19385
19459
  function convertFontSize(value, wrapperEl) {
19386
19460
  if (!value.includes("em"))
19387
19461
  return parseInt(value);