MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / insertIntoForumEditor

Function insertIntoForumEditor

nodeImage.js:501–517  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

499 return null;
500 }
501 function insertIntoForumEditor(text) {
502 var cm = findForumEditor();
503 if (!cm) return false;
504 if (typeof cm.replaceSelection === 'function') {
505 cm.replaceSelection(text);
506 if (typeof cm.focus === 'function') cm.focus();
507 return true;
508 }
509 if (cm.hasFocus && typeof cm.getCursor === 'function' && typeof cm.replaceRange === 'function') {
510 var from = cm.getCursor();
511 var to = cm.somethingSelected() ? cm.getSelection() : from;
512 cm.replaceRange(text, from, to);
513 if (typeof cm.focus === 'function') cm.focus();
514 return true;
515 }
516 return false;
517 }
518 function copyText(t, onOk, onErr) {
519 if (navigator.clipboard && navigator.clipboard.writeText) {
520 navigator.clipboard.writeText(t).then(onOk).catch(onErr);

Callers 3

stepFunction · 0.85
appendImageDetailCardFunction · 0.85

Calls 1

findForumEditorFunction · 0.85

Tested by

no test coverage detected