PageSourceSearch

https://survivalbrasil.org/assets/controllers/admin/tinymce_controller-ed3017a3.js

js survivalbrasil.org collected 2026-09-25 18:53:14 UTC 1,802 bytes, 40 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3/*
4  Turbo does not re-run the layout's tinymce init script on later visits, so a
5  textarea on a freshly-loaded page has no editor. This controller re-inits on
6  every connect, merging window.tinymceOptions (the layout's one rendering of
7  CMS::TinyMce.options, see app/lib/cms/tiny_mce.rb) with the menubar/toolbar/
8  plugin config TinyMCERails keeps from config/tinymce.yml.
9  setup can't travel through that JSON, since TinyMCE needs it as a real
10  function, so its logic is kept here, matching
11  CMS::TinyMce#link_preview_card_setup.
12*/
13
14// Connects to data-controller="admin--tinymce"
15export default class extends Controller {
16  connect () {
17    const opts = {
18      ...window.tinymceOptions,
19      // Auto-tags links to survival-international domains as previewable, unless a link
20      // already has an explicit preview-card-link/no-preview-card-link class.
21      setup: function (editor) {
22        const survivalDomains = ['survival.es', 'survival.it', 'survivalinternational.fr', 'survivalinternational.de', 'survivalinternational.org', 'survivalbrasil.org'];
23        editor.on('init', function () {
24          editor.getDoc().querySelectorAll('a[href]').forEach(function (link) {
25            if (link.classList.contains('preview-card-link') || link.classList.contains('no-preview-card-link')) { return; }
26            const href = link.getAttribute('href') || '';
27            const isSurvivalDomain = survivalDomains.some(function (domain) { return href.indexOf(domain) !== -1; });
28            if (!isSurvivalDomain) { return; }
29            link.classList.add('preview-card-link');
30          });
31        });
32      }
33    }
34    tinymce.init({ ...TinyMCERails.configuration.default, ...opts });
35  }
36
37  disconnect () {
38    tinymce.remove();
39  }
40}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.