wordpress editor hook and regex to parse content for attribute values
-
Anyone have examples of hooks to parse the editor’s contents before tloaded and parse through it for regex’d values to change. I am inserting html content and an inline style. I need to add the already saved css to be loaded as a style in the editor on load.
menu: [{ text: 'Orbit Spinner', onclick: function() { editor.windowManager.open({ title: 'Insert Orbit Spinner Icon', body: [ { type: 'ColorPicker', name: 'color', label: 'Orbit Spinner Icon Color Picker' }, { type: 'listbox', name: 'pixel_size', label: 'Size', 'values': [{ text: '55px', value: '55px' }, { text: '25px', value: '25px' }, { text: '100px', value: '100px' }, ] }, ], onsubmit: function(e) { var random_string_thingy; random_string_thingy = Math.random().toString(36).substring(7); tinyMCE.activeEditor.dom.addStyle('.orbit-spinner-' + random_string_thingy + ' .orbit:nth-child(-n+3){border-color:' + e.data.color + '!important;}.orbit-spinner-' + random_string_thingy + ' {height:' + e.data.pixel_size + '!important;width:' + e.data.pixel_size + '!important;}'); editor.insertContent('<div class="orbit-spinner orbit-spinner-' + random_string_thingy + '"><div class="orbit"></div><div class="orbit"></div><div class="orbit"></div></div><style>.orbit-spinner-' + random_string_thingy + ' .orbit:nth-child(-n+3){border-color:' + e.data.color + '!important;}.orbit-spinner-' + random_string_thingy + ' {height:' + e.data.pixel_size + '!important;width:' + e.data.pixel_size + '!important;}</style>'); } }); } },
I can add the css to the div’s attributes and add it to the list of elements to preserve the data.
data-es=".orbit-spinner-' + random_string_thingy + ' .orbit:nth-child(-n+3){border-color:' + e.data.color + '!important;}.orbit-spinner-' + random_string_thingy + ' {height:' + e.data.pixel_size + '!important;width:' + e.data.pixel_size + '!important;}"
Looking for the hook to parse the post content before the editor loads mostly but anything might help.
- The topic ‘wordpress editor hook and regex to parse content for attribute values’ is closed to new replies.